From 5eb993c4bb3e3ffbacb4b23ef97d5de2be713d9a Mon Sep 17 00:00:00 2001 From: Andreas Rogge Date: Tue, 17 Dec 2019 17:25:49 +0100 Subject: [PATCH] findlib: parent dirs should have consistent mode Previously when creating parent directories Bareos handled the deepest parent directory special and set permissions on it. This surfaced when selecting only files, but not directories to restore. In that case the directory that contains the files got a mode that was derived from the file mode of the file being restored when the parent directory was created. While this in itself is already inconsistent, the effective mode was also calculated by adding S_IWUSR and S_IXUSR which did not take group or other in account. This patch now makes sure that no permission on parent directories is set explicitly, so you just get what the effective uid, gid and umask will produce. (cherry picked from commit 705860721722284540ef8d74461c5a7b772c6da1) --- src/findlib/mkpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/findlib/mkpath.c b/src/findlib/mkpath.c index ad971243400..7bc33059e62 100644 --- a/src/findlib/mkpath.c +++ b/src/findlib/mkpath.c @@ -262,7 +262,7 @@ bool makepath(ATTR *attr, const char *apath, mode_t mode, mode_t parent_mode, /* * Set for final component */ - if (i < ndir && new_dir[i++]) { + if (i < ndir && new_dir[i++] && !keep_dir_modes) { set_own_mod(attr, path, owner, group, mode); }