aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-08-10 08:42:58 -0400
committerLibravatar GitHub <noreply@github.com>2016-08-10 08:42:58 -0400
commitee2eca44671c61b96e9e2275bec93cff18ed7b0a (patch)
treefb3a117a648d8f9b3fa9cb05ef91df42e478c1f5 /src
parentMerge pull request #694 from Fred-Barclay/typo (diff)
parentexpand ${PATH} macro in noblacklist entries (diff)
downloadfirejail-ee2eca44671c61b96e9e2275bec93cff18ed7b0a.tar.gz
firejail-ee2eca44671c61b96e9e2275bec93cff18ed7b0a.tar.zst
firejail-ee2eca44671c61b96e9e2275bec93cff18ed7b0a.zip
Merge pull request #695 from manevich/busybox-01
Busybox workaround + expand ${PATH} macro in noblacklist entries
Diffstat (limited to 'src')
-rw-r--r--src/firejail/fs.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/firejail/fs.c b/src/firejail/fs.c
index ff5887c10..5bcfa6066 100644
--- a/src/firejail/fs.c
+++ b/src/firejail/fs.c
@@ -478,12 +478,40 @@ void fs_blacklist(void) {
478 478
479 // Process noblacklist command 479 // Process noblacklist command
480 if (strncmp(entry->data, "noblacklist ", 12) == 0) { 480 if (strncmp(entry->data, "noblacklist ", 12) == 0) {
481 if (noblacklist_c >= noblacklist_m) { 481 char **paths = build_paths();
482 noblacklist_m *= 2; 482
483 noblacklist = realloc(noblacklist, sizeof(*noblacklist) * noblacklist_m); 483 char *enames[sizeof(paths)+1] = {0};
484 if (noblacklist == NULL) 484 int i = 0;
485 errExit("failed increasing memory for noblacklist entries");} 485
486 noblacklist[noblacklist_c++] = expand_home(entry->data + 12, homedir); 486 if (strncmp(entry->data + 12, "${PATH}", 7) == 0) {
487 // expand ${PATH} macro
488 while (paths[i] != NULL) {
489 if (asprintf(&enames[i], "%s%s", paths[i], entry->data + 19) == -1)
490 errExit("asprintf");
491 i++;
492 }
493 } else {
494 // expand ${HOME} macro if found or pass as is
495 enames[0] = expand_home(entry->data + 12, homedir);
496 enames[1] = NULL;
497 }
498
499 i = 0;
500 while (enames[i] != NULL) {
501 if (noblacklist_c >= noblacklist_m) {
502 noblacklist_m *= 2;
503 noblacklist = realloc(noblacklist, sizeof(*noblacklist) * noblacklist_m);
504 if (noblacklist == NULL)
505 errExit("failed increasing memory for noblacklist entries");
506 }
507 noblacklist[noblacklist_c++] = enames[i];
508 i++;
509 }
510
511 while (enames[i] != NULL) {
512 free(enames[i]);
513 }
514
487 entry = entry->next; 515 entry = entry->next;
488 continue; 516 continue;
489 } 517 }