diff options
Diffstat (limited to 'src/firejail/main.c')
-rw-r--r-- | src/firejail/main.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/firejail/main.c b/src/firejail/main.c index c74fb02d2..e70e20eec 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c | |||
@@ -1509,7 +1509,15 @@ int main(int argc, char **argv) { | |||
1509 | } | 1509 | } |
1510 | 1510 | ||
1511 | // extract private home dirname | 1511 | // extract private home dirname |
1512 | cfg.home_private_keep = argv[i] + 15; | 1512 | if (*(argv[i] + 15) == '\0') { |
1513 | fprintf(stderr, "Error: invalid private-home option\n"); | ||
1514 | exit(1); | ||
1515 | } | ||
1516 | if (cfg.home_private_keep) { | ||
1517 | if ( asprintf(&cfg.home_private_keep, "%s,%s", cfg.home_private_keep, argv[i] + 15) < 0 ) | ||
1518 | errExit("asprintf"); | ||
1519 | } else | ||
1520 | cfg.home_private_keep = argv[i] + 15; | ||
1513 | arg_private = 1; | 1521 | arg_private = 1; |
1514 | } | 1522 | } |
1515 | else | 1523 | else |
@@ -1526,38 +1534,54 @@ int main(int argc, char **argv) { | |||
1526 | } | 1534 | } |
1527 | 1535 | ||
1528 | // extract private etc list | 1536 | // extract private etc list |
1529 | cfg.etc_private_keep = argv[i] + 14; | 1537 | if (*(argv[i] + 14) == '\0') { |
1530 | if (*cfg.etc_private_keep == '\0') { | ||
1531 | fprintf(stderr, "Error: invalid private-etc option\n"); | 1538 | fprintf(stderr, "Error: invalid private-etc option\n"); |
1532 | exit(1); | 1539 | exit(1); |
1533 | } | 1540 | } |
1541 | if (cfg.etc_private_keep) { | ||
1542 | if ( asprintf(&cfg.etc_private_keep, "%s,%s", cfg.etc_private_keep, argv[i] + 14) < 0 ) | ||
1543 | errExit("asprintf"); | ||
1544 | } else | ||
1545 | cfg.etc_private_keep = argv[i] + 14; | ||
1534 | arg_private_etc = 1; | 1546 | arg_private_etc = 1; |
1535 | } | 1547 | } |
1536 | else if (strncmp(argv[i], "--private-opt=", 14) == 0) { | 1548 | else if (strncmp(argv[i], "--private-opt=", 14) == 0) { |
1537 | // extract private opt list | 1549 | // extract private opt list |
1538 | cfg.opt_private_keep = argv[i] + 14; | 1550 | if (*(argv[i] + 14) == '\0') { |
1539 | if (*cfg.opt_private_keep == '\0') { | ||
1540 | fprintf(stderr, "Error: invalid private-opt option\n"); | 1551 | fprintf(stderr, "Error: invalid private-opt option\n"); |
1541 | exit(1); | 1552 | exit(1); |
1542 | } | 1553 | } |
1554 | if (cfg.opt_private_keep) { | ||
1555 | if ( asprintf(&cfg.opt_private_keep, "%s,%s", cfg.opt_private_keep, argv[i] + 14) < 0 ) | ||
1556 | errExit("asprintf"); | ||
1557 | } else | ||
1558 | cfg.opt_private_keep = argv[i] + 14; | ||
1543 | arg_private_opt = 1; | 1559 | arg_private_opt = 1; |
1544 | } | 1560 | } |
1545 | else if (strncmp(argv[i], "--private-srv=", 14) == 0) { | 1561 | else if (strncmp(argv[i], "--private-srv=", 14) == 0) { |
1546 | // extract private srv list | 1562 | // extract private srv list |
1547 | cfg.srv_private_keep = argv[i] + 14; | 1563 | if (*(argv[i] + 14) == '\0') { |
1548 | if (*cfg.srv_private_keep == '\0') { | ||
1549 | fprintf(stderr, "Error: invalid private-etc option\n"); | 1564 | fprintf(stderr, "Error: invalid private-etc option\n"); |
1550 | exit(1); | 1565 | exit(1); |
1551 | } | 1566 | } |
1567 | if (cfg.srv_private_keep) { | ||
1568 | if ( asprintf(&cfg.srv_private_keep, "%s,%s", cfg.srv_private_keep, argv[i] + 14) < 0 ) | ||
1569 | errExit("asprintf"); | ||
1570 | } else | ||
1571 | cfg.srv_private_keep = argv[i] + 14; | ||
1552 | arg_private_srv = 1; | 1572 | arg_private_srv = 1; |
1553 | } | 1573 | } |
1554 | else if (strncmp(argv[i], "--private-bin=", 14) == 0) { | 1574 | else if (strncmp(argv[i], "--private-bin=", 14) == 0) { |
1555 | // extract private bin list | 1575 | // extract private bin list |
1556 | cfg.bin_private_keep = argv[i] + 14; | 1576 | if (*(argv[i] + 14) == '\0') { |
1557 | if (*cfg.bin_private_keep == '\0') { | ||
1558 | fprintf(stderr, "Error: invalid private-bin option\n"); | 1577 | fprintf(stderr, "Error: invalid private-bin option\n"); |
1559 | exit(1); | 1578 | exit(1); |
1560 | } | 1579 | } |
1580 | if (cfg.bin_private_keep) { | ||
1581 | if ( asprintf(&cfg.bin_private_keep, "%s,%s", cfg.bin_private_keep, argv[i] + 14) < 0 ) | ||
1582 | errExit("asprintf"); | ||
1583 | } else | ||
1584 | cfg.bin_private_keep = argv[i] + 14; | ||
1561 | arg_private_bin = 1; | 1585 | arg_private_bin = 1; |
1562 | } | 1586 | } |
1563 | else if (strcmp(argv[i], "--private-tmp") == 0) { | 1587 | else if (strcmp(argv[i], "--private-tmp") == 0) { |