diff options
Diffstat (limited to 'src/firejail/fs_whitelist.c')
-rw-r--r-- | src/firejail/fs_whitelist.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/firejail/fs_whitelist.c b/src/firejail/fs_whitelist.c index 37894fee1..465eaa7c8 100644 --- a/src/firejail/fs_whitelist.c +++ b/src/firejail/fs_whitelist.c | |||
@@ -46,7 +46,7 @@ static char *resolve_downloads(void) { | |||
46 | errExit("asprintf"); | 46 | errExit("asprintf"); |
47 | 47 | ||
48 | if (stat(fname, &s) == 0) { | 48 | if (stat(fname, &s) == 0) { |
49 | if (arg_debug) | 49 | if (arg_debug || arg_debug_whitelists) |
50 | printf("Downloads directory resolved as \"%s\"\n", fname); | 50 | printf("Downloads directory resolved as \"%s\"\n", fname); |
51 | 51 | ||
52 | char *rv; | 52 | char *rv; |
@@ -86,10 +86,10 @@ static char *resolve_downloads(void) { | |||
86 | if (ptr2) { | 86 | if (ptr2) { |
87 | fclose(fp); | 87 | fclose(fp); |
88 | *ptr2 = '\0'; | 88 | *ptr2 = '\0'; |
89 | if (arg_debug) | 89 | if (arg_debug || arg_debug_whitelists) |
90 | printf("extracted %s from ~/.config/user-dirs.dirs\n", ptr1); | 90 | printf("extracted %s from ~/.config/user-dirs.dirs\n", ptr1); |
91 | if (strlen(ptr1) != 0) { | 91 | if (strlen(ptr1) != 0) { |
92 | if (arg_debug) | 92 | if (arg_debug || arg_debug_whitelists) |
93 | printf("Downloads directory resolved as \"%s\"\n", ptr1); | 93 | printf("Downloads directory resolved as \"%s\"\n", ptr1); |
94 | 94 | ||
95 | if (asprintf(&fname, "%s/%s", cfg.homedir, ptr1) == -1) | 95 | if (asprintf(&fname, "%s/%s", cfg.homedir, ptr1) == -1) |
@@ -244,11 +244,11 @@ static void whitelist_path(ProfileEntry *entry) { | |||
244 | // check if the file exists | 244 | // check if the file exists |
245 | struct stat s; | 245 | struct stat s; |
246 | if (wfile && stat(wfile, &s) == 0) { | 246 | if (wfile && stat(wfile, &s) == 0) { |
247 | if (arg_debug) | 247 | if (arg_debug || arg_debug_whitelists) |
248 | printf("Whitelisting %s\n", path); | 248 | printf("Whitelisting %s\n", path); |
249 | } | 249 | } |
250 | else { | 250 | else { |
251 | if (arg_debug) { | 251 | if (arg_debug || arg_debug_whitelists) { |
252 | fprintf(stderr, "Warning: %s is an invalid file, skipping...\n", path); | 252 | fprintf(stderr, "Warning: %s is an invalid file, skipping...\n", path); |
253 | } | 253 | } |
254 | return; | 254 | return; |
@@ -341,7 +341,7 @@ void fs_whitelist(void) { | |||
341 | char *fname = realpath(new_name, NULL); | 341 | char *fname = realpath(new_name, NULL); |
342 | if (!fname) { | 342 | if (!fname) { |
343 | // file not found, blank the entry in the list and continue | 343 | // file not found, blank the entry in the list and continue |
344 | if (arg_debug) { | 344 | if (arg_debug || arg_debug_whitelists) { |
345 | printf("Removed whitelist path: %s\n", entry->data); | 345 | printf("Removed whitelist path: %s\n", entry->data); |
346 | printf("\texpanded: %s\n", new_name); | 346 | printf("\texpanded: %s\n", new_name); |
347 | printf("\treal path: (null)\n"); | 347 | printf("\treal path: (null)\n"); |
@@ -360,7 +360,7 @@ void fs_whitelist(void) { | |||
360 | if (strncmp(new_name, cfg.homedir, strlen(cfg.homedir)) == 0) { | 360 | if (strncmp(new_name, cfg.homedir, strlen(cfg.homedir)) == 0) { |
361 | // whitelisting home directory is disabled if --private or --private-home option is present | 361 | // whitelisting home directory is disabled if --private or --private-home option is present |
362 | if (arg_private) { | 362 | if (arg_private) { |
363 | if (arg_debug) | 363 | if (arg_debug || arg_debug_whitelists) |
364 | printf("Removed whitelist path %s, --private option is present\n", entry->data); | 364 | printf("Removed whitelist path %s, --private option is present\n", entry->data); |
365 | 365 | ||
366 | *entry->data = '\0'; | 366 | *entry->data = '\0'; |
@@ -425,7 +425,7 @@ void fs_whitelist(void) { | |||
425 | if (asprintf(&newdata, "whitelist %s", fname) == -1) | 425 | if (asprintf(&newdata, "whitelist %s", fname) == -1) |
426 | errExit("asprintf"); | 426 | errExit("asprintf"); |
427 | entry->data = newdata; | 427 | entry->data = newdata; |
428 | if (arg_debug) | 428 | if (arg_debug || arg_debug_whitelists) |
429 | printf("Replaced whitelist path: %s\n", entry->data); | 429 | printf("Replaced whitelist path: %s\n", entry->data); |
430 | } | 430 | } |
431 | free(fname); | 431 | free(fname); |
@@ -469,7 +469,7 @@ void fs_whitelist(void) { | |||
469 | errExit("mount bind"); | 469 | errExit("mount bind"); |
470 | 470 | ||
471 | // mount tmpfs on /tmp | 471 | // mount tmpfs on /tmp |
472 | if (arg_debug) | 472 | if (arg_debug || arg_debug_whitelists) |
473 | printf("Mounting tmpfs on /tmp directory\n"); | 473 | printf("Mounting tmpfs on /tmp directory\n"); |
474 | if (mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=777,gid=0") < 0) | 474 | if (mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=777,gid=0") < 0) |
475 | errExit("mounting tmpfs on /tmp"); | 475 | errExit("mounting tmpfs on /tmp"); |
@@ -491,7 +491,7 @@ void fs_whitelist(void) { | |||
491 | errExit("mount bind"); | 491 | errExit("mount bind"); |
492 | 492 | ||
493 | // mount tmpfs on /media | 493 | // mount tmpfs on /media |
494 | if (arg_debug) | 494 | if (arg_debug || arg_debug_whitelists) |
495 | printf("Mounting tmpfs on /media directory\n"); | 495 | printf("Mounting tmpfs on /media directory\n"); |
496 | if (mount("tmpfs", "/media", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) | 496 | if (mount("tmpfs", "/media", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) |
497 | errExit("mounting tmpfs on /media"); | 497 | errExit("mounting tmpfs on /media"); |
@@ -513,7 +513,7 @@ void fs_whitelist(void) { | |||
513 | errExit("mount bind"); | 513 | errExit("mount bind"); |
514 | 514 | ||
515 | // mount tmpfs on /var | 515 | // mount tmpfs on /var |
516 | if (arg_debug) | 516 | if (arg_debug || arg_debug_whitelists) |
517 | printf("Mounting tmpfs on /var directory\n"); | 517 | printf("Mounting tmpfs on /var directory\n"); |
518 | if (mount("tmpfs", "/var", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) | 518 | if (mount("tmpfs", "/var", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) |
519 | errExit("mounting tmpfs on /var"); | 519 | errExit("mounting tmpfs on /var"); |
@@ -535,7 +535,7 @@ void fs_whitelist(void) { | |||
535 | errExit("mount bind"); | 535 | errExit("mount bind"); |
536 | 536 | ||
537 | // mount tmpfs on /dev | 537 | // mount tmpfs on /dev |
538 | if (arg_debug) | 538 | if (arg_debug || arg_debug_whitelists) |
539 | printf("Mounting tmpfs on /dev directory\n"); | 539 | printf("Mounting tmpfs on /dev directory\n"); |
540 | if (mount("tmpfs", "/dev", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) | 540 | if (mount("tmpfs", "/dev", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) |
541 | errExit("mounting tmpfs on /dev"); | 541 | errExit("mounting tmpfs on /dev"); |
@@ -557,7 +557,7 @@ void fs_whitelist(void) { | |||
557 | errExit("mount bind"); | 557 | errExit("mount bind"); |
558 | 558 | ||
559 | // mount tmpfs on /opt | 559 | // mount tmpfs on /opt |
560 | if (arg_debug) | 560 | if (arg_debug || arg_debug_whitelists) |
561 | printf("Mounting tmpfs on /opt directory\n"); | 561 | printf("Mounting tmpfs on /opt directory\n"); |
562 | if (mount("tmpfs", "/opt", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) | 562 | if (mount("tmpfs", "/opt", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) |
563 | errExit("mounting tmpfs on /opt"); | 563 | errExit("mounting tmpfs on /opt"); |
@@ -588,7 +588,7 @@ void fs_whitelist(void) { | |||
588 | int rv = symlink(entry->data + 10, entry->link); | 588 | int rv = symlink(entry->data + 10, entry->link); |
589 | if (rv) | 589 | if (rv) |
590 | fprintf(stderr, "Warning cannot create symbolic link %s\n", entry->link); | 590 | fprintf(stderr, "Warning cannot create symbolic link %s\n", entry->link); |
591 | else if (arg_debug) | 591 | else if (arg_debug || arg_debug_whitelists) |
592 | printf("Created symbolic link %s -> %s\n", entry->link, entry->data + 10); | 592 | printf("Created symbolic link %s -> %s\n", entry->link, entry->data + 10); |
593 | } | 593 | } |
594 | } | 594 | } |