aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2019-01-09 09:46:48 -0500
committerLibravatar netblue30 <netblue30@yahoo.com>2019-01-09 09:46:48 -0500
commit2e8a13800a2ea3d2fa3760ba3bb2f984b6ce738b (patch)
tree24728cf8ac3c919dba72af93f9f688f336d33f6e
parentmainline merge: fix join/seccomp #2296 (diff)
downloadfirejail-2e8a13800a2ea3d2fa3760ba3bb2f984b6ce738b.tar.gz
firejail-2e8a13800a2ea3d2fa3760ba3bb2f984b6ce738b.tar.zst
firejail-2e8a13800a2ea3d2fa3760ba3bb2f984b6ce738b.zip
mainline merge: test caps join, testing seccomp/join
-rwxr-xr-xtest/filters/caps-join.exp96
-rwxr-xr-xtest/filters/filters.sh13
-rwxr-xr-xtest/filters/seccomp-join.exp159
3 files changed, 266 insertions, 2 deletions
diff --git a/test/filters/caps-join.exp b/test/filters/caps-join.exp
new file mode 100755
index 000000000..2e29ef763
--- /dev/null
+++ b/test/filters/caps-join.exp
@@ -0,0 +1,96 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2018 Firejail Authors
4# License GPL v2
5
6set timeout 10
7match_max 100000
8spawn $env(SHELL)
9set id1 $spawn_id
10spawn $env(SHELL)
11set id2 $spawn_id
12
13send -- "stty -echo\r"
14after 100
15
16#
17# regular run
18#
19set spawn_id $id1
20send -- "firejail --name=jointesting\r"
21expect {
22 timeout {puts "TESTING ERROR 0\n";exit}
23 "Child process initialized"
24}
25sleep 1
26
27set spawn_id $id2
28
29send -- "firejail --join=jointesting cat /proc/self/status\r"
30expect {
31 timeout {puts "TESTING ERROR 1\n";exit}
32 "CapBnd: 0000000000000000"
33}
34sleep 1
35
36set spawn_id $id1
37send -- "exit\r"
38after 100
39
40#
41# no caps
42#
43set spawn_id $id1
44send -- "firejail --name=jointesting --noprofile\r"
45expect {
46 timeout {puts "TESTING ERROR 10\n";exit}
47 "Child process initialized"
48}
49sleep 1
50
51set spawn_id $id2
52
53send -- "firejail --join=jointesting cat /proc/self/status\r"
54expect {
55 timeout {puts "TESTING ERROR 11\n";exit}
56 "CapBnd:"
57}
58expect {
59 timeout {puts "TESTING ERROR 12\n";exit}
60 "fffffffff"
61}
62expect {
63 timeout {puts "TESTING ERROR 13\n";exit}
64 "CapAmb:"
65}
66sleep 1
67
68set spawn_id $id1
69send -- "exit\r"
70after 100
71
72#
73# no caps
74#
75set spawn_id $id1
76send -- "firejail --name=jointesting --noprofile --caps.keep=chown,fowner\r"
77expect {
78 timeout {puts "TESTING ERROR20\n";exit}
79 "Child process initialized"
80}
81sleep 1
82
83set spawn_id $id2
84
85send -- "firejail --join=jointesting cat /proc/self/status\r"
86expect {
87 timeout {puts "TESTING ERROR 21\n";exit}
88 "CapBnd: 0000000000000009"
89}
90sleep 1
91
92set spawn_id $id1
93send -- "exit\r"
94after 100
95
96puts "all done\n"
diff --git a/test/filters/filters.sh b/test/filters/filters.sh
index 3d1211b8e..33f205e05 100755
--- a/test/filters/filters.sh
+++ b/test/filters/filters.sh
@@ -12,7 +12,6 @@ if [ -f /etc/debian_version ]; then
12fi 12fi
13export PATH="$PATH:/usr/lib/firejail:/usr/lib64/firejail" 13export PATH="$PATH:/usr/lib/firejail:/usr/lib64/firejail"
14 14
15
16if [ -f /sys/kernel/security/apparmor/profiles ]; then 15if [ -f /sys/kernel/security/apparmor/profiles ]; then
17 echo "TESTING: apparmor (test/filters/apparmor.exp)" 16 echo "TESTING: apparmor (test/filters/apparmor.exp)"
18 ./apparmor.exp 17 ./apparmor.exp
@@ -42,7 +41,7 @@ echo "TESTING: seccomp postexec (test/filters/seccomp-postexec.exp)"
42echo "TESTING: noroot (test/filters/noroot.exp)" 41echo "TESTING: noroot (test/filters/noroot.exp)"
43./noroot.exp 42./noroot.exp
44 43
45echo "TESTING: capabilities (test/filters/caps.exp)" 44
46if grep -q "^CapBnd:\\s0000003fffffffff" /proc/self/status; then 45if grep -q "^CapBnd:\\s0000003fffffffff" /proc/self/status; then
47 echo "TESTING: capabilities (test/filters/caps.exp)" 46 echo "TESTING: capabilities (test/filters/caps.exp)"
48 ./caps.exp 47 ./caps.exp
@@ -53,6 +52,9 @@ fi
53echo "TESTING: capabilities print (test/filters/caps-print.exp)" 52echo "TESTING: capabilities print (test/filters/caps-print.exp)"
54./caps-print.exp 53./caps-print.exp
55 54
55echo "TESTING: capabilities join (test/filters/caps-join.exp)"
56./caps-join.exp
57
56rm -f seccomp-test-file 58rm -f seccomp-test-file
57if [ "$(uname -m)" = "x86_64" ]; then 59if [ "$(uname -m)" = "x86_64" ]; then
58 echo "TESTING: fseccomp (test/filters/fseccomp.exp)" 60 echo "TESTING: fseccomp (test/filters/fseccomp.exp)"
@@ -114,3 +116,10 @@ if [ "$(uname -m)" = "x86_64" ]; then
114else 116else
115 echo "TESTING SKIP: seccomp dual, not running on x86_64" 117 echo "TESTING SKIP: seccomp dual, not running on x86_64"
116fi 118fi
119
120if [ "$(uname -m)" = "x86_64" ]; then
121 echo "TESTING: seccomp join (test/filters/seccomp-join.exp)"
122 ./seccomp-join.exp
123else
124 echo "TESTING SKIP: seccomp join test implemented only for x86_64"
125fi
diff --git a/test/filters/seccomp-join.exp b/test/filters/seccomp-join.exp
new file mode 100755
index 000000000..7a869b85f
--- /dev/null
+++ b/test/filters/seccomp-join.exp
@@ -0,0 +1,159 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2018 Firejail Authors
4# License GPL v2
5
6set timeout 10
7match_max 100000
8spawn $env(SHELL)
9set id1 $spawn_id
10spawn $env(SHELL)
11set id2 $spawn_id
12
13send -- "stty -echo\r"
14after 100
15
16#
17# regular run
18#
19set spawn_id $id1
20send -- "firejail --name=jointesting --debug\r"
21expect {
22 timeout {puts "TESTING ERROR 0\n";exit}
23 "Installing /run/firejail/mnt/seccomp seccomp filter"
24}
25expect {
26 timeout {puts "TESTING ERROR 1\n";exit}
27 "Installing /run/firejail/mnt/seccomp.32 seccomp filter"
28}
29expect {
30 timeout {puts "TESTING ERROR 2\n";exit}
31 "Installing /run/firejail/mnt/seccomp.protocol seccomp filter"
32}
33sleep 1
34
35set spawn_id $id2
36
37send -- "firejail --debug --join=jointesting\r"
38expect {
39 timeout {puts "TESTING ERROR 3\n";exit}
40 "Installing /run/firejail/mnt/seccomp seccomp filter"
41}
42expect {
43 timeout {puts "TESTING ERROR 4\n";exit}
44 "Installing /run/firejail/mnt/seccomp.32 seccomp filter"
45}
46expect {
47 timeout {puts "TESTING ERROR 5\n";exit}
48 "Installing /run/firejail/mnt/seccomp.protocol seccomp filter"
49}
50sleep 1
51
52send -- "exit\r"
53after 100
54set spawn_id $id1
55send -- "exit\r"
56after 100
57
58
59
60#
61# block secondary
62#
63set spawn_id $id1
64send -- "firejail --name=jointesting --seccomp.block-secondary --debug\r"
65expect {
66 timeout {puts "TESTING ERROR 10\n";exit}
67 "Installing /run/firejail/mnt/seccomp seccomp filter"
68}
69expect {
70 timeout {puts "TESTING ERROR 11\n";exit}
71 "Installing /run/firejail/mnt/seccomp.32 seccomp filter" {puts "TESTING ERROR 12\n";exit}
72 "Installing /run/firejail/mnt/seccomp.block_secondary seccomp filter"
73}
74expect {
75 timeout {puts "TESTING ERROR 13\n";exit}
76 "Installing /run/firejail/mnt/seccomp.protocol seccomp filter"
77}
78sleep 1
79
80set spawn_id $id2
81send -- "firejail --debug --join=jointesting\r"
82expect {
83 timeout {puts "TESTING ERROR 14\n";exit}
84 "Installing /run/firejail/mnt/seccomp seccomp filter"
85}
86expect {
87 timeout {puts "TESTING ERROR 15\n";exit}
88 "Installing /run/firejail/mnt/seccomp.block_secondary seccomp filter"
89}
90expect {
91 timeout {puts "TESTING ERROR 16\n";exit}
92 "Installing /run/firejail/mnt/seccomp.protocol seccomp filter"
93}
94sleep 1
95
96send -- "exit\r"
97after 100
98set spawn_id $id1
99send -- "exit\r"
100after 100
101
102#
103# protocol
104#
105set spawn_id $id1
106send -- "firejail --name=jointesting --noprofile --protocol=inet --debug\r"
107expect {
108 timeout {puts "TESTING ERROR 22\n";exit}
109 "Installing /run/firejail/mnt/seccomp.protocol seccomp filter"
110}
111sleep 1
112
113set spawn_id $id2
114
115send -- "firejail --debug --join=jointesting\r"
116expect {
117 timeout {puts "TESTING ERROR 23\n";exit}
118 "Installing /run/firejail/mnt/seccomp seccomp filter" {puts "TESTING ERROR 24\n";exit}
119 "Installing /run/firejail/mnt/seccomp.32 seccomp filter" {puts "TESTING ERROR 25\n";exit}
120 "Installing /run/firejail/mnt/seccomp.protocol seccomp filter"
121}
122sleep 1
123
124send -- "exit\r"
125after 100
126set spawn_id $id1
127send -- "exit\r"
128after 100
129
130#
131# memory deny write execute
132#
133set spawn_id $id1
134send -- "firejail --name=jointesting --noprofile --memory-deny-write-execute --debug\r"
135expect {
136 timeout {puts "TESTING ERROR 32\n";exit}
137 "Installing /run/firejail/mnt/seccomp.mdwx seccomp filter"
138}
139sleep 1
140
141set spawn_id $id2
142
143send -- "firejail --debug --join=jointesting\r"
144expect {
145 timeout {puts "TESTING ERROR 33\n";exit}
146 "Installing /run/firejail/mnt/seccomp seccomp filter" {puts "TESTING ERROR 34\n";exit}
147 "Installing /run/firejail/mnt/seccomp.32 seccomp filter" {puts "TESTING ERROR 35\n";exit}
148 "Installing /run/firejail/mnt/seccomp.protocol seccomp filter" {puts "TESTING ERROR 36\n";exit}
149 "Installing /run/firejail/mnt/seccomp.mdwx seccomp filter"
150}
151sleep 1
152
153send -- "exit\r"
154after 100
155set spawn_id $id1
156send -- "exit\r"
157after 100
158
159puts "all done\n"