diff options
Diffstat (limited to 'test/private-lib')
-rwxr-xr-x | test/private-lib/private-lib.exp | 48 | ||||
-rwxr-xr-x | test/private-lib/private-lib.sh | 12 |
2 files changed, 60 insertions, 0 deletions
diff --git a/test/private-lib/private-lib.exp b/test/private-lib/private-lib.exp new file mode 100755 index 000000000..5290def35 --- /dev/null +++ b/test/private-lib/private-lib.exp | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2022 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | |||
7 | set timeout 10 | ||
8 | spawn $env(SHELL) | ||
9 | match_max 100000 | ||
10 | |||
11 | send -- "firejail --private-lib --private-bin=sh,bash,dash,ps,grep,ls,find,echo,stty \r" | ||
12 | expect { | ||
13 | timeout {puts "TESTING ERROR 1\n";exit} | ||
14 | -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" | ||
15 | } | ||
16 | after 100 | ||
17 | send -- "stty -echo\r" | ||
18 | after 100 | ||
19 | |||
20 | send -- "cd /bin; find .\; echo done\r" | ||
21 | expect { | ||
22 | timeout {puts "TESTING ERROR 2\n";exit} | ||
23 | # "grep" {puts "TESTING ERROR 3\n";exit} | ||
24 | "rm" {puts "TESTING ERROR 3\n";exit} | ||
25 | "cp" {puts "TESTING ERROR 4\n";exit} | ||
26 | "done" | ||
27 | } | ||
28 | after 100 | ||
29 | |||
30 | send -- "cd /lib; find .\r" | ||
31 | expect { | ||
32 | timeout {puts "TESTING ERROR 5\n";exit} | ||
33 | "./modules" {puts "TESTING ERROR 6\n";exit} | ||
34 | "./firmware" {puts "TESTING ERROR 7\n";exit} | ||
35 | "libc.so" | ||
36 | } | ||
37 | after 100 | ||
38 | |||
39 | send -- "cd /usr/lib; find .\r" | ||
40 | expect { | ||
41 | timeout {puts "TESTING ERROR 8\n";exit} | ||
42 | "grub" {puts "TESTING ERROR 9\n";exit} | ||
43 | "mozilla" {puts "TESTING ERROR 10\n";exit} | ||
44 | "libdl.so" | ||
45 | } | ||
46 | after 100 | ||
47 | |||
48 | puts "\nall done\n" | ||
diff --git a/test/private-lib/private-lib.sh b/test/private-lib/private-lib.sh index 6b7d433c8..43c42a098 100755 --- a/test/private-lib/private-lib.sh +++ b/test/private-lib/private-lib.sh | |||
@@ -18,3 +18,15 @@ for app in "${apps[@]}"; do | |||
18 | echo "TESTING SKIP: $app not found" | 18 | echo "TESTING SKIP: $app not found" |
19 | fi | 19 | fi |
20 | done | 20 | done |
21 | |||
22 | if [[ $(uname -m) == "x86_64" ]]; then | ||
23 | fjconfig=/etc/firejail/firejail.config | ||
24 | printf 'private-lib yes\n' | sudo tee -a "$fjconfig" >/dev/null | ||
25 | echo "TESTING: private-lib (test/fs/private-lib.exp)" | ||
26 | ./private-lib.exp | ||
27 | printf '%s\n' "$(sed '/^private-lib yes$/d' "$fjconfig")" | | ||
28 | sudo tee "$fjconfig" >/dev/null | ||
29 | else | ||
30 | echo "TESTING SKIP: private-lib test implemented only for x86_64." | ||
31 | fi | ||
32 | |||