aboutsummaryrefslogtreecommitdiffstats
path: root/test/filters
diff options
context:
space:
mode:
Diffstat (limited to 'test/filters')
-rwxr-xr-xtest/filters/filters.sh15
-rwxr-xr-xtest/filters/fseccomp.exp138
-rwxr-xr-xtest/filters/noroot.exp44
3 files changed, 171 insertions, 26 deletions
diff --git a/test/filters/filters.sh b/test/filters/filters.sh
index 5093c8614..5c7c98b3e 100755
--- a/test/filters/filters.sh
+++ b/test/filters/filters.sh
@@ -12,11 +12,21 @@ echo "TESTING: noroot (test/filters/noroot.exp)"
12echo "TESTING: capabilities (test/filters/caps.exp)" 12echo "TESTING: capabilities (test/filters/caps.exp)"
13./caps.exp 13./caps.exp
14 14
15rm -f seccomp-test-file
16if [ "$(uname -m)" = "x86_64" ]; then
17 echo "TESTING: fseccomp (test/filters/fseccomp.exp)"
18 ./fseccomp.exp
19else
20 echo "TESTING SKIP: fseccomp test implemented only for x86_64"
21fi
22rm -f seccomp-test-file
23
24
15if [ "$(uname -m)" = "x86_64" ]; then 25if [ "$(uname -m)" = "x86_64" ]; then
16 echo "TESTING: protocol (test/filters/protocol.exp)" 26 echo "TESTING: protocol (test/filters/protocol.exp)"
17 ./protocol.exp 27 ./protocol.exp
18else 28else
19 echo "TESTING SKIP: protocol, not running on x86_64" 29 echo "TESTING SKIP: protocol, running only on x86_64"
20fi 30fi
21 31
22echo "TESTING: seccomp bad empty (test/filters/seccomp-bad-empty.exp)" 32echo "TESTING: seccomp bad empty (test/filters/seccomp-bad-empty.exp)"
@@ -50,9 +60,6 @@ echo "TESTING: seccomp chmod profile - seccomp lists (test/filters/seccomp-chmod
50echo "TESTING: seccomp empty (test/filters/seccomp-empty.exp)" 60echo "TESTING: seccomp empty (test/filters/seccomp-empty.exp)"
51./seccomp-empty.exp 61./seccomp-empty.exp
52 62
53echo "TESTING: seccomp bad empty (test/filters/seccomp-bad-empty.exp)"
54./seccomp-bad-empty.exp
55
56if [ "$(uname -m)" = "x86_64" ]; then 63if [ "$(uname -m)" = "x86_64" ]; then
57 echo "TESTING: seccomp dual filter (test/filters/seccomp-dualfilter.exp)" 64 echo "TESTING: seccomp dual filter (test/filters/seccomp-dualfilter.exp)"
58 ./seccomp-dualfilter.exp 65 ./seccomp-dualfilter.exp
diff --git a/test/filters/fseccomp.exp b/test/filters/fseccomp.exp
new file mode 100755
index 000000000..8a9a8f9dc
--- /dev/null
+++ b/test/filters/fseccomp.exp
@@ -0,0 +1,138 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10after 100
11send -- "/usr/lib/firejail/fseccomp debug-syscalls\r"
12expect {
13 timeout {puts "TESTING ERROR 1\n";exit}
14 "1 - write"
15}
16
17after 100
18send -- "/usr/lib/firejail/fseccomp debug-errnos\r"
19expect {
20 timeout {puts "TESTING ERROR 2\n";exit}
21 "1 - EPERM"
22}
23
24after 100
25send -- "/usr/lib/firejail/fseccomp debug-protocols\r"
26expect {
27 timeout {puts "TESTING ERROR 3\n";exit}
28 "unix, inet, inet6, netlink, packet,"
29}
30
31after 100
32send -- "/usr/lib/firejail/fseccomp protocol build unix,inet seccomp-test-file\r"
33after 100
34send -- "/usr/lib/firejail/fseccomp print seccomp-test-file\r"
35expect {
36 timeout {puts "TESTING ERROR 4.1\n";exit}
37 "WHITELIST 41 socket"
38}
39
40after 100
41send -- "/usr/lib/firejail/fseccomp secondary 64 seccomp-test-file\r"
42after 100
43send -- "/usr/lib/firejail/fseccomp print seccomp-test-file\r"
44expect {
45 timeout {puts "TESTING ERROR 5.1\n";exit}
46 "BLACKLIST 165 mount"
47}
48expect {
49 timeout {puts "TESTING ERROR 5.2\n";exit}
50 "BLACKLIST 166 umount2"
51}
52expect {
53 timeout {puts "TESTING ERROR 5.3\n";exit}
54 "RETURN_ALLOW"
55}
56
57after 100
58send -- "/usr/lib/firejail/fseccomp default seccomp-test-file\r"
59after 100
60send -- "/usr/lib/firejail/fseccomp print seccomp-test-file\r"
61expect {
62 timeout {puts "TESTING ERROR 6.1\n";exit}
63 "BLACKLIST 165 mount"
64}
65expect {
66 timeout {puts "TESTING ERROR 6.2\n";exit}
67 "BLACKLIST 166 umount2"
68}
69expect {
70 timeout {puts "TESTING ERROR 6.3\n";exit}
71 "RETURN_ALLOW"
72}
73
74after 100
75send -- "/usr/lib/firejail/fseccomp drop seccomp-test-file chmod,chown\r"
76after 100
77send -- "/usr/lib/firejail/fseccomp print seccomp-test-file\r"
78expect {
79 timeout {puts "TESTING ERROR 7.1\n";exit}
80 "BLACKLIST 165 mount" {puts "TESTING ERROR 7.2\n";exit}
81 "BLACKLIST 166 umount2" {puts "TESTING ERROR 7.3\n";exit}
82 "BLACKLIST 90 chmod"
83}
84expect {
85 timeout {puts "TESTING ERROR 7.4\n";exit}
86 "BLACKLIST 92 chown"
87}
88expect {
89 timeout {puts "TESTING ERROR 7.5\n";exit}
90 "RETURN_ALLOW"
91}
92
93after 100
94send -- "/usr/lib/firejail/fseccomp default drop seccomp-test-file chmod,chown\r"
95after 100
96send -- "/usr/lib/firejail/fseccomp print seccomp-test-file\r"
97expect {
98 timeout {puts "TESTING ERROR 8.1\n";exit}
99 "BLACKLIST 165 mount"
100}
101expect {
102 timeout {puts "TESTING ERROR 8.2\n";exit}
103 "BLACKLIST 166 umount2"
104}
105expect {
106 timeout {puts "TESTING ERROR 8.3\n";exit}
107 "BLACKLIST 90 chmod"
108}
109expect {
110 timeout {puts "TESTING ERROR 8.4\n";exit}
111 "BLACKLIST 92 chown"
112}
113expect {
114 timeout {puts "TESTING ERROR 8.5\n";exit}
115 "RETURN_ALLOW"
116}
117after 100
118send -- "/usr/lib/firejail/fseccomp keep seccomp-test-file chmod,chown\r"
119after 100
120send -- "/usr/lib/firejail/fseccomp print seccomp-test-file\r"
121expect {
122 timeout {puts "TESTING ERROR 9.1\n";exit}
123 "WHITELIST 90 chmod"
124}
125expect {
126 timeout {puts "TESTING ERROR 9.2\n";exit}
127 "WHITELIST 92 chown"
128}
129expect {
130 timeout {puts "TESTING ERROR 9.3\n";exit}
131 "KILL_PROCESS"
132}
133
134
135
136after 100
137puts "\nall done\n"
138
diff --git a/test/filters/noroot.exp b/test/filters/noroot.exp
index 2a7cb7975..b011f2bf9 100755
--- a/test/filters/noroot.exp
+++ b/test/filters/noroot.exp
@@ -46,20 +46,20 @@ expect {
46} 46}
47send -- "sudo -s\r" 47send -- "sudo -s\r"
48expect { 48expect {
49 timeout {puts "TESTING ERROR 8\n";exit} 49 timeout {puts "TESTING ERROR 7\n";exit}
50 "effective uid is not 0, is sudo installed setuid root?" { puts "OK\n";} 50 "effective uid is not 0, is sudo installed setuid root?" { puts "OK\n";}
51 "sudo must be owned by uid 0 and have the setuid bit set" { puts "OK\n";} 51 "sudo must be owned by uid 0 and have the setuid bit set" { puts "OK\n";}
52 "Bad system call" { puts "OK\n";} 52 "Bad system call" { puts "OK\n";}
53} 53}
54send -- "cat /proc/self/uid_map | wc -l\r" 54send -- "cat /proc/self/uid_map | wc -l\r"
55expect { 55expect {
56 timeout {puts "TESTING ERROR 7\n";exit} 56 timeout {puts "TESTING ERROR 8\n";exit}
57 "1" 57 "1"
58} 58}
59send -- "cat /proc/self/gid_map | wc -l\r" 59send -- "cat /proc/self/gid_map | wc -l\r"
60expect { 60expect {
61 timeout {puts "TESTING ERROR 8\n";exit} 61 timeout {puts "TESTING ERROR 9\n";exit}
62 "3" 62 "5"
63} 63}
64 64
65puts "\n" 65puts "\n"
@@ -70,59 +70,59 @@ sleep 2
70 70
71send -- "firejail --name=test --noroot --noprofile\r" 71send -- "firejail --name=test --noroot --noprofile\r"
72expect { 72expect {
73 timeout {puts "TESTING ERROR 9\n";exit} 73 timeout {puts "TESTING ERROR 10\n";exit}
74 "Child process initialized" 74 "Child process initialized"
75} 75}
76sleep 1 76sleep 1
77 77
78send -- "cat /proc/self/status\r" 78send -- "cat /proc/self/status\r"
79expect { 79expect {
80 timeout {puts "TESTING ERROR 10\n";exit} 80 timeout {puts "TESTING ERROR 11\n";exit}
81 "CapBnd:" 81 "CapBnd:"
82} 82}
83expect { 83expect {
84 timeout {puts "TESTING ERROR 11\n";exit} 84 timeout {puts "TESTING ERROR 12\n";exit}
85 "ffffffff" 85 "ffffffff"
86} 86}
87expect { 87expect {
88 timeout {puts "TESTING ERROR 12\n";exit} 88 timeout {puts "TESTING ERROR 13\n";exit}
89 "Seccomp:" 89 "Seccomp:"
90} 90}
91expect { 91expect {
92 timeout {puts "TESTING ERROR 13\n";exit} 92 timeout {puts "TESTING ERROR 14\n";exit}
93 "0" 93 "0"
94} 94}
95expect { 95expect {
96 timeout {puts "TESTING ERROR 14\n";exit} 96 timeout {puts "TESTING ERROR 15\n";exit}
97 "Cpus_allowed:" 97 "Cpus_allowed:"
98} 98}
99puts "\n" 99puts "\n"
100 100
101send -- "whoami\r" 101send -- "whoami\r"
102expect { 102expect {
103 timeout {puts "TESTING ERROR 15\n";exit} 103 timeout {puts "TESTING ERROR 16\n";exit}
104 $env(USER) 104 $env(USER)
105} 105}
106send -- "sudo -s\r" 106send -- "sudo -s\r"
107expect { 107expect {
108 timeout {puts "TESTING ERROR 16\n";exit} 108 timeout {puts "TESTING ERROR 17\n";exit}
109 "effective uid is not 0, is sudo installed setuid root?" { puts "OK\n";} 109 "effective uid is not 0, is sudo installed setuid root?" { puts "OK\n";}
110 "sudo must be owned by uid 0 and have the setuid bit set" { puts "OK\n";} 110 "sudo must be owned by uid 0 and have the setuid bit set" { puts "OK\n";}
111} 111}
112send -- "ping 0\r" 112send -- "ping 0\r"
113expect { 113expect {
114 timeout {puts "TESTING ERROR 17\n";exit} 114 timeout {puts "TESTING ERROR 18\n";exit}
115 "Operation not permitted" 115 "Operation not permitted"
116} 116}
117send -- "cat /proc/self/uid_map | wc -l\r" 117send -- "cat /proc/self/uid_map | wc -l\r"
118expect { 118expect {
119 timeout {puts "TESTING ERROR 18\n";exit} 119 timeout {puts "TESTING ERROR 19\n";exit}
120 "1" 120 "1"
121} 121}
122send -- "cat /proc/self/gid_map | wc -l\r" 122send -- "cat /proc/self/gid_map | wc -l\r"
123expect { 123expect {
124 timeout {puts "TESTING ERROR 19\n";exit} 124 timeout {puts "TESTING ERROR 20\n";exit}
125 "3" 125 "5"
126} 126}
127 127
128 128
@@ -130,31 +130,31 @@ expect {
130spawn $env(SHELL) 130spawn $env(SHELL)
131send -- "firejail --debug --join=test\r" 131send -- "firejail --debug --join=test\r"
132expect { 132expect {
133 timeout {puts "TESTING ERROR 20\n";exit} 133 timeout {puts "TESTING ERROR 21\n";exit}
134 "User namespace detected" 134 "User namespace detected"
135} 135}
136expect { 136expect {
137 timeout {puts "TESTING ERROR 21\n";exit} 137 timeout {puts "TESTING ERROR 22\n";exit}
138 "Joining user namespace" 138 "Joining user namespace"
139} 139}
140sleep 1 140sleep 1
141 141
142send -- "sudo -s\r" 142send -- "sudo -s\r"
143expect { 143expect {
144 timeout {puts "TESTING ERROR 22\n";exit} 144 timeout {puts "TESTING ERROR 23\n";exit}
145 "effective uid is not 0, is sudo installed setuid root?" { puts "OK\n";} 145 "effective uid is not 0, is sudo installed setuid root?" { puts "OK\n";}
146 "sudo must be owned by uid 0 and have the setuid bit set" { puts "OK\n";} 146 "sudo must be owned by uid 0 and have the setuid bit set" { puts "OK\n";}
147 "Permission denied" { puts "OK\n";} 147 "Permission denied" { puts "OK\n";}
148} 148}
149send -- "cat /proc/self/uid_map | wc -l\r" 149send -- "cat /proc/self/uid_map | wc -l\r"
150expect { 150expect {
151 timeout {puts "TESTING ERROR 23\n";exit} 151 timeout {puts "TESTING ERROR 24\n";exit}
152 "1" 152 "1"
153} 153}
154send -- "cat /proc/self/gid_map | wc -l\r" 154send -- "cat /proc/self/gid_map | wc -l\r"
155expect { 155expect {
156 timeout {puts "TESTING ERROR 24\n";exit} 156 timeout {puts "TESTING ERROR 25\n";exit}
157 "3" 157 "5"
158} 158}
159after 100 159after 100
160puts "\nall done\n" 160puts "\nall done\n"