Skip to content

Commit 988a27c

Browse files
ensure_dir: respect umask for created directory modes, fixes #6400
we tried to be very private / secure here, but that created the issue that a less secure umask (like e.g. 0o007) just did not work. to make the umask work, we must start from 0o777 mode and let the umask do its work, like e.g. 0o777 & ~0o007 --> 0o770. with borg's default umask of 0o077, it usually ends up being 0o700, so only permissions for the user (not group, not others).
1 parent 6a57186 commit 988a27c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/borg/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,12 @@ def prune_split(archives, pattern, n, skip=[]):
513513
return keep
514514

515515

516-
def ensure_dir(path, mode=stat.S_IRWXU, pretty_deadly=True):
516+
def ensure_dir(path, mode=stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO, pretty_deadly=True):
517517
"""
518518
Ensures that the dir exists with the right permissions.
519519
1) Make sure the directory exists in a race-free operation
520520
2) If mode is not None and the directory has been created, give the right
521-
permissions to the leaf directory
521+
permissions to the leaf directory. The current umask value is masked out first.
522522
3) If pretty_deadly is True, catch exceptions, reraise them with a pretty
523523
message.
524524
Returns if the directory has been created and has the right permissions,

0 commit comments

Comments
 (0)