From 113597818860241185d0c3efecf99b0ee7d900fa Mon Sep 17 00:00:00 2001 From: netblue30 Date: Sun, 25 Oct 2015 08:22:21 -0400 Subject: ignore option testing --- src/firejail/main.c | 6 +++++- test/ignore.exp | 38 ++++++++++++++++++++++++++++++++++++++ test/ignore.profile | 3 +++ test/test.sh | 3 +++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 test/ignore.exp create mode 100644 test/ignore.profile diff --git a/src/firejail/main.c b/src/firejail/main.c index 0def00fa8..8d11caef3 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c @@ -712,7 +712,11 @@ int main(int argc, char **argv) { arg_noprofile = 1; } else if (strncmp(argv[i], "--ignore=", 9) == 0) { - char *ptr = argv[i] + 9; + if (custom_profile) { + fprintf(stderr, "Error: please use --profile after --include\n"); + exit(1); + } + if (*(argv[i] + 9) == '\0') { fprintf(stderr, "Error: invalid ignore option\n"); exit(1); diff --git a/test/ignore.exp b/test/ignore.exp new file mode 100755 index 000000000..bdbd9d28c --- /dev/null +++ b/test/ignore.exp @@ -0,0 +1,38 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --profile=ignore.profile --ignore=seccomp \r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Error: please use --profile after --include" +} + +send -- "firejail --debug --ignore=seccomp\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + BLACKLIST {puts "TESTING ERROR 2\n";exit} + "Child process initialized" +} +sleep 1 +send -- "exit\r" +sleep 1 + +send -- "firejail --ignore=seccomp --ignore=shell --profile=ignore.profile \r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "ps aux | wc -l\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "4" +} +sleep 1 + + +puts "\nall done\n" diff --git a/test/ignore.profile b/test/ignore.profile new file mode 100644 index 000000000..aec231ad2 --- /dev/null +++ b/test/ignore.profile @@ -0,0 +1,3 @@ +private +seccomp +shell none diff --git a/test/test.sh b/test/test.sh index c986b5f29..406ef92a3 100755 --- a/test/test.sh +++ b/test/test.sh @@ -18,6 +18,9 @@ echo "TESTING: invalid filename" echo "TESTING: environment variables" ./env.exp +echo "TESTING: ignore command" +./ignore.exp + echo "TESTING: private-etc" ./private-etc.exp -- cgit v1.2.3-70-g09d2