diff options
Diffstat (limited to 'src/firejail/fs_whitelist.c')
-rw-r--r-- | src/firejail/fs_whitelist.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/firejail/fs_whitelist.c b/src/firejail/fs_whitelist.c index 60bb0f6ed..754714943 100644 --- a/src/firejail/fs_whitelist.c +++ b/src/firejail/fs_whitelist.c | |||
@@ -27,6 +27,12 @@ | |||
27 | #include <fcntl.h> | 27 | #include <fcntl.h> |
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | 29 | ||
30 | // mountinfo functionality test; | ||
31 | // 1. enable TEST_MOUNTINFO definition | ||
32 | // 2. set a symlink in /tmp: ln -s /etc /tmp/etc | ||
33 | // 3. run firejail --debug --whitelist=/tmp/etc | ||
34 | //#define TEST_MOUNTINFO | ||
35 | |||
30 | static char *dentry[] = { | 36 | static char *dentry[] = { |
31 | "Downloads", | 37 | "Downloads", |
32 | "Загрузки", | 38 | "Загрузки", |
@@ -204,8 +210,10 @@ static void whitelist_path(ProfileEntry *entry) { | |||
204 | } | 210 | } |
205 | else if (entry->tmp_dir) { | 211 | else if (entry->tmp_dir) { |
206 | fname = path + 5; // strlen("/tmp/") | 212 | fname = path + 5; // strlen("/tmp/") |
213 | #ifndef TEST_MOUNTINFO | ||
207 | if (*fname == '\0') | 214 | if (*fname == '\0') |
208 | goto errexit; | 215 | goto errexit; |
216 | #endif | ||
209 | 217 | ||
210 | if (asprintf(&wfile, "%s/%s", RUN_WHITELIST_TMP_DIR, fname) == -1) | 218 | if (asprintf(&wfile, "%s/%s", RUN_WHITELIST_TMP_DIR, fname) == -1) |
211 | errExit("asprintf"); | 219 | errExit("asprintf"); |
@@ -516,10 +524,13 @@ void fs_whitelist(void) { | |||
516 | else if (strncmp(new_name, "/tmp/", 5) == 0) { | 524 | else if (strncmp(new_name, "/tmp/", 5) == 0) { |
517 | entry->tmp_dir = 1; | 525 | entry->tmp_dir = 1; |
518 | tmp_dir = 1; | 526 | tmp_dir = 1; |
527 | |||
528 | #ifndef TEST_MOUNTINFO | ||
519 | // both path and absolute path are under /tmp | 529 | // both path and absolute path are under /tmp |
520 | if (strncmp(fname, "/tmp/", 5) != 0) { | 530 | if (strncmp(fname, "/tmp/", 5) != 0) { |
521 | goto errexit; | 531 | goto errexit; |
522 | } | 532 | } |
533 | #endif | ||
523 | } | 534 | } |
524 | else if (strncmp(new_name, "/media/", 7) == 0) { | 535 | else if (strncmp(new_name, "/media/", 7) == 0) { |
525 | entry->media_dir = 1; | 536 | entry->media_dir = 1; |