From 362d290bacf90a9bb29d6c25ca395117e4da838e Mon Sep 17 00:00:00 2001 From: netblue30 Date: Tue, 5 Sep 2017 10:56:40 -0400 Subject: testing --- gcov.sh | 5 +++-- src/fldd/main.c | 5 +++++ test/fs/fs.sh | 3 +++ test/fs/private-lib.exp | 44 ++++++++++++++++++++++++++++++++++++++++++++ test/utils/seccomp-print.exp | 4 ++-- 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100755 test/fs/private-lib.exp diff --git a/gcov.sh b/gcov.sh index 092b755af..df1fcb51b 100755 --- a/gcov.sh +++ b/gcov.sh @@ -8,12 +8,13 @@ gcov_init() { /usr/lib/firejail/fseccomp --help > /dev/null /usr/lib/firejail/ftee --help > /dev/null /usr/lib/firejail/fcopy --help > /dev/null + /usr/lib/firejail/fldd --help > /dev/null firecfg --help > /dev/null sudo chown $USER:$USER `find .` } generate() { - lcov -q --capture -d src/firejail -d src/firemon -d src/fcopy -d src/fseccomp -d src/fnet -d src/ftee -d src/lib -d src/firecfg --output-file gcov-file-new + lcov -q --capture -d src/firejail -d src/firemon -d src/fcopy -d src/fseccomp -d src/fnet -d src/ftee -d src/lib -d src/firecfg -d src/fldd --output-file gcov-file-new lcov --add-tracefile gcov-file-old --add-tracefile gcov-file-new --output-file gcov-file rm -fr gcov-dir genhtml -q gcov-file --output-directory gcov-dir @@ -24,7 +25,7 @@ generate() { gcov_init -lcov -q --capture -d src/firejail -d src/firemon -d src/fcopy -d src/fseccomp -d src/fnet -d src/ftee -d src/lib -d src/firecfg --output-file gcov-file-old +lcov -q --capture -d src/firejail -d src/firemon -d src/fcopy -d src/fseccomp -d src/fnet -d src/ftee -d src/lib -d src/firecfg -d src/fldd --output-file gcov-file-old #make test-environment #generate diff --git a/src/fldd/main.c b/src/fldd/main.c index 947c6b4ae..5fda45266 100644 --- a/src/fldd/main.c +++ b/src/fldd/main.c @@ -265,6 +265,11 @@ printf("\n"); } + if (strcmp(argv[1], "--help") == 0) { + usage(); + return 0; + } + // check program access if (access(argv[1], R_OK)) { fprintf(stderr, "Error fldd: cannot access %s\n", argv[1]); diff --git a/test/fs/fs.sh b/test/fs/fs.sh index 9e7ead3c9..e67ccc476 100755 --- a/test/fs/fs.sh +++ b/test/fs/fs.sh @@ -28,6 +28,9 @@ echo "TESTING: kmsg access (test/fs/kmsg.exp)" echo "TESTING: read/write /var/tmp (test/fs/fs_var_tmp.exp)" ./fs_var_tmp.exp +echo "TESTING: private-lib (test/fs/private-lib.exp)" +./private-lib.exp + echo "TESTING: read/write /var/lock (test/fs/fs_var_lock.exp)" ./fs_var_lock.exp diff --git a/test/fs/private-lib.exp b/test/fs/private-lib.exp new file mode 100755 index 000000000..dd418da0f --- /dev/null +++ b/test/fs/private-lib.exp @@ -0,0 +1,44 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2017 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --private-lib --private-bin=sh,bash,dash,ps,grep,ls,find,echo \r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +after 100 + +send -- "find /bin; echo done\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "rm" {puts "TESTING ERROR 3\n";exit} + "cp" {puts "TESTING ERROR 4\n";exit} + "done" +} +after 100 + +send -- "find /lib; echo done\r" +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "modules" {puts "TESTING ERROR 6\n";exit} + "firmware" {puts "TESTING ERROR 7\n";exit} + "libc.so" +} +after 100 + +send -- "find /usr/lib; echo done\r" +expect { + timeout {puts "TESTING ERROR 8\n";exit} + "grub" {puts "TESTING ERROR 9\n";exit} + "mozilla" {puts "TESTING ERROR 10\n";exit} + "libdl.so" +} +after 100 + +puts "\nall done\n" diff --git a/test/utils/seccomp-print.exp b/test/utils/seccomp-print.exp index 5a76d7fcc..b3ab5e13c 100755 --- a/test/utils/seccomp-print.exp +++ b/test/utils/seccomp-print.exp @@ -22,11 +22,11 @@ expect { } expect { timeout {puts "TESTING ERROR 2\n";exit} - "init_module" + "delete_module" } expect { timeout {puts "TESTING ERROR 3\n";exit} - "delete_module" + "init_module" } expect { timeout {puts "TESTING ERROR 4\n";exit} -- cgit v1.2.3-70-g09d2