diff options
author | avoidr <avoidr@users.noreply.github.com> | 2015-11-20 00:33:42 +0100 |
---|---|---|
committer | avoidr <avoidr@users.noreply.github.com> | 2015-11-20 00:33:42 +0100 |
commit | cc34d9759c418d75e3d9a9d6e45fb2e440378777 (patch) | |
tree | cd560065b81d38df53b84b3f7ee412e43c7cbb59 | |
parent | fix directory ownership for --whitelist command (diff) | |
download | firejail-cc34d9759c418d75e3d9a9d6e45fb2e440378777.tar.gz firejail-cc34d9759c418d75e3d9a9d6e45fb2e440378777.tar.zst firejail-cc34d9759c418d75e3d9a9d6e45fb2e440378777.zip |
keep original file permissions
-rw-r--r-- | src/firejail/fs_whitelist.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/firejail/fs_whitelist.c b/src/firejail/fs_whitelist.c index fccb82735..740bdab3e 100644 --- a/src/firejail/fs_whitelist.c +++ b/src/firejail/fs_whitelist.c | |||
@@ -27,12 +27,9 @@ | |||
27 | #include <fcntl.h> | 27 | #include <fcntl.h> |
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | 29 | ||
30 | static int mkpath(const char* path) { | 30 | static int mkpath(const char* path, mode_t mode) { |
31 | assert(path && *path); | 31 | assert(path && *path); |
32 | 32 | ||
33 | // create directories with a 0755 mode | ||
34 | mode_t mode = 0755; | ||
35 | |||
36 | // create directories with uid/gid as root or as current user if inside home directory | 33 | // create directories with uid/gid as root or as current user if inside home directory |
37 | uid_t uid = getuid(); | 34 | uid_t uid = getuid(); |
38 | gid_t gid = getgid(); | 35 | gid_t gid = getgid(); |
@@ -142,7 +139,7 @@ static void whitelist_path(ProfileEntry *entry) { | |||
142 | } | 139 | } |
143 | 140 | ||
144 | // create the path if necessary | 141 | // create the path if necessary |
145 | mkpath(path); | 142 | mkpath(path, s.st_mode); |
146 | 143 | ||
147 | // process directory | 144 | // process directory |
148 | if (S_ISDIR(s.st_mode)) { | 145 | if (S_ISDIR(s.st_mode)) { |
@@ -417,7 +414,7 @@ void fs_whitelist(void) { | |||
417 | struct stat s; | 414 | struct stat s; |
418 | if (stat(entry->link, &s) != 0) { | 415 | if (stat(entry->link, &s) != 0) { |
419 | // create the path if necessary | 416 | // create the path if necessary |
420 | mkpath(entry->link); | 417 | mkpath(entry->link, s.st_mode); |
421 | 418 | ||
422 | int rv = symlink(entry->data + 10, entry->link); | 419 | int rv = symlink(entry->data + 10, entry->link); |
423 | if (rv) | 420 | if (rv) |