aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2023-03-08 17:09:17 -0500
committerLibravatar netblue30 <netblue30@protonmail.com>2023-03-08 17:09:17 -0500
commitaa0194eae75871f3fb5e15d31a9060527711adae (patch)
treebb535822c1469d4a1d6a736b7b58616b37d19d7d /test
parenttesting (diff)
downloadfirejail-aa0194eae75871f3fb5e15d31a9060527711adae.tar.gz
firejail-aa0194eae75871f3fb5e15d31a9060527711adae.tar.zst
firejail-aa0194eae75871f3fb5e15d31a9060527711adae.zip
testing
Diffstat (limited to 'test')
-rwxr-xr-xtest/capabilities/capabilities.sh3
-rwxr-xr-xtest/capabilities/caps-join.exp6
-rwxr-xr-xtest/capabilities/caps-print.exp6
-rwxr-xr-xtest/capabilities/caps.exp44
-rwxr-xr-xtest/capabilities/firemon-caps.exp47
-rwxr-xr-xtest/utils/caps-print.exp32
-rw-r--r--test/utils/caps1.profile1
-rw-r--r--test/utils/caps2.profile1
-rwxr-xr-xtest/utils/firemon-caps.exp129
-rwxr-xr-xtest/utils/utils.sh10
10 files changed, 66 insertions, 213 deletions
diff --git a/test/capabilities/capabilities.sh b/test/capabilities/capabilities.sh
index 50279cd4f..2d345025a 100755
--- a/test/capabilities/capabilities.sh
+++ b/test/capabilities/capabilities.sh
@@ -21,3 +21,6 @@ echo "TESTING: capabilities print (test/filters/caps-print.exp)"
21echo "TESTING: capabilities join (test/filters/caps-join.exp)" 21echo "TESTING: capabilities join (test/filters/caps-join.exp)"
22./caps-join.exp 22./caps-join.exp
23 23
24echo "TESTING: firemon caps (test/utils/firemon-caps.exp)"
25./firemon-caps.exp
26
diff --git a/test/capabilities/caps-join.exp b/test/capabilities/caps-join.exp
index 1830143fb..ecb43d943 100755
--- a/test/capabilities/caps-join.exp
+++ b/test/capabilities/caps-join.exp
@@ -35,7 +35,7 @@ sleep 1
35 35
36set spawn_id $id1 36set spawn_id $id1
37send -- "exit\r" 37send -- "exit\r"
38after 100 38sleep 1
39 39
40# 40#
41# no caps 41# no caps
@@ -67,7 +67,7 @@ sleep 1
67 67
68set spawn_id $id1 68set spawn_id $id1
69send -- "exit\r" 69send -- "exit\r"
70after 100 70after 500
71 71
72# 72#
73# no caps 73# no caps
@@ -91,6 +91,6 @@ sleep 1
91 91
92set spawn_id $id1 92set spawn_id $id1
93send -- "exit\r" 93send -- "exit\r"
94after 100 94after 500
95 95
96puts "all done\n" 96puts "all done\n"
diff --git a/test/capabilities/caps-print.exp b/test/capabilities/caps-print.exp
index b403f9ffe..66a7e093b 100755
--- a/test/capabilities/caps-print.exp
+++ b/test/capabilities/caps-print.exp
@@ -68,7 +68,7 @@ expect {
68 timeout {puts "TESTING ERROR 13\n";exit} 68 timeout {puts "TESTING ERROR 13\n";exit}
69 "syslog - disabled" 69 "syslog - disabled"
70} 70}
71after 100 71after 500
72 72
73send -- "firejail --debug-caps\r" 73send -- "firejail --debug-caps\r"
74expect { 74expect {
@@ -87,7 +87,7 @@ expect {
87 timeout {puts "TESTING ERROR 9\n";exit} 87 timeout {puts "TESTING ERROR 9\n";exit}
88 "24 - sys_resource" 88 "24 - sys_resource"
89} 89}
90after 100 90after 500
91 91
92send -- "firejail --caps.keep=\"bla bla bla\"\r" 92send -- "firejail --caps.keep=\"bla bla bla\"\r"
93expect { 93expect {
@@ -99,5 +99,5 @@ expect {
99 "not found" 99 "not found"
100} 100}
101 101
102after 100 102after 500
103puts "\nall done\n" 103puts "\nall done\n"
diff --git a/test/capabilities/caps.exp b/test/capabilities/caps.exp
index dbd63efda..bd7ab04eb 100755
--- a/test/capabilities/caps.exp
+++ b/test/capabilities/caps.exp
@@ -7,14 +7,11 @@ set timeout 10
7spawn $env(SHELL) 7spawn $env(SHELL)
8match_max 100000 8match_max 100000
9 9
10send -- "firejail --caps.keep=chown,fowner --noprofile\r" 10send -- "firejail --caps.keep=chown,fowner --noprofile cat /proc/self/status\r"
11expect { 11expect {
12 timeout {puts "TESTING ERROR 1\n";exit} 12 timeout {puts "TESTING ERROR 1\n";exit}
13 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" 13 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
14} 14}
15after 100
16
17send -- "cat /proc/self/status\r"
18expect { 15expect {
19 timeout {puts "TESTING ERROR 2\n";exit} 16 timeout {puts "TESTING ERROR 2\n";exit}
20 "CapBnd: 0000000000000009" 17 "CapBnd: 0000000000000009"
@@ -23,17 +20,13 @@ expect {
23 timeout {puts "TESTING ERROR 3\n";exit} 20 timeout {puts "TESTING ERROR 3\n";exit}
24 "Seccomp:" 21 "Seccomp:"
25} 22}
26send -- "exit\r" 23after 500
27sleep 1
28 24
29send -- "firejail --caps.drop=all --noprofile\r" 25send -- "firejail --caps.drop=all --noprofile cat /proc/self/status\r"
30expect { 26expect {
31 timeout {puts "TESTING ERROR 4\n";exit} 27 timeout {puts "TESTING ERROR 4\n";exit}
32 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" 28 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
33} 29}
34after 100
35
36send -- "cat /proc/self/status\r"
37expect { 30expect {
38 timeout {puts "TESTING ERROR 5\n";exit} 31 timeout {puts "TESTING ERROR 5\n";exit}
39 "CapBnd: 0000000000000000" 32 "CapBnd: 0000000000000000"
@@ -42,17 +35,13 @@ expect {
42 timeout {puts "TESTING ERROR 6\n";exit} 35 timeout {puts "TESTING ERROR 6\n";exit}
43 "Seccomp:" 36 "Seccomp:"
44} 37}
45send -- "exit\r" 38after 500
46sleep 1
47 39
48send -- "firejail --caps.drop=chown,dac_override,dac_read_search,fowner --noprofile\r" 40send -- "firejail --caps.drop=chown,dac_override,dac_read_search,fowner --noprofile cat /proc/self/status\r"
49expect { 41expect {
50 timeout {puts "TESTING ERROR 7\n";exit} 42 timeout {puts "TESTING ERROR 7\n";exit}
51 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" 43 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
52} 44}
53after 100
54
55send -- "cat /proc/self/status\r"
56expect { 45expect {
57 timeout {puts "TESTING ERROR 8\n";exit} 46 timeout {puts "TESTING ERROR 8\n";exit}
58 "CapBnd:" 47 "CapBnd:"
@@ -65,11 +54,9 @@ expect {
65 timeout {puts "TESTING ERROR 10\n";exit} 54 timeout {puts "TESTING ERROR 10\n";exit}
66 "Seccomp:" 55 "Seccomp:"
67} 56}
68send -- "exit\r" 57after 500
69sleep 1
70 58
71 59send -- "firejail --profile=caps1.profile --debug ls\r"
72send -- "firejail --profile=caps1.profile --debug\r"
73expect { 60expect {
74 timeout {puts "TESTING ERROR 11\n";exit} 61 timeout {puts "TESTING ERROR 11\n";exit}
75 "Drop CAP_SYS_MODULE" 62 "Drop CAP_SYS_MODULE"
@@ -83,10 +70,7 @@ expect {
83 "Drop CAP_" {puts "TESTING ERROR 14\n";exit} 70 "Drop CAP_" {puts "TESTING ERROR 14\n";exit}
84 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" 71 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
85} 72}
86after 100 73after 500
87send -- "exit\r"
88sleep 1
89
90 74
91## tofix: possible problem with caps.keep in profile files 75## tofix: possible problem with caps.keep in profile files
92##send -- "firejail --caps.keep=chown,fowner --noprofile\r" 76##send -- "firejail --caps.keep=chown,fowner --noprofile\r"
@@ -110,14 +94,11 @@ sleep 1
110#sleep 1 94#sleep 1
111 95
112#send -- "firejail --caps.drop=chown,dac_override,dac_read_search,fowner --noprofile\r" 96#send -- "firejail --caps.drop=chown,dac_override,dac_read_search,fowner --noprofile\r"
113send -- "firejail --profile=caps3.profile\r" 97send -- "firejail --profile=caps3.profile cat /proc/self/status\r"
114expect { 98expect {
115 timeout {puts "TESTING ERROR 18\n";exit} 99 timeout {puts "TESTING ERROR 18\n";exit}
116 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" 100 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
117} 101}
118after 100
119
120send -- "cat /proc/self/status\r"
121expect { 102expect {
122 timeout {puts "TESTING ERROR 19\n";exit} 103 timeout {puts "TESTING ERROR 19\n";exit}
123 "CapBnd:" 104 "CapBnd:"
@@ -130,10 +111,5 @@ expect {
130 timeout {puts "TESTING ERROR 21\n";exit} 111 timeout {puts "TESTING ERROR 21\n";exit}
131 "Seccomp:" 112 "Seccomp:"
132} 113}
133send -- "exit\r" 114after 500
134sleep 1
135
136
137
138after 100
139puts "\nall done\n" 115puts "\nall done\n"
diff --git a/test/capabilities/firemon-caps.exp b/test/capabilities/firemon-caps.exp
new file mode 100755
index 000000000..905c8cba9
--- /dev/null
+++ b/test/capabilities/firemon-caps.exp
@@ -0,0 +1,47 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2023 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=bingo1 --noprofile --caps\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
14}
15sleep 1
16
17spawn $env(SHELL)
18send -- "firejail --name=bingo2 --noprofile\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
22}
23sleep 1
24
25spawn $env(SHELL)
26send -- "firemon --caps\r"
27expect {
28 timeout {puts "TESTING ERROR 2\n";exit}
29 "need to be root" {puts "TESTING SKIP: /proc mounted as hidepid\n"; exit}
30 "bingo1"
31}
32expect {
33 timeout {puts "TESTING ERROR 3\n";exit}
34 "31cffff"
35}
36expect {
37 timeout {puts "TESTING ERROR 4\n";exit}
38 "bingo2"
39}
40expect {
41 timeout {puts "TESTING ERROR 5\n";exit}
42 "fffffff"
43}
44
45after 500
46
47puts "all done\n"
diff --git a/test/utils/caps-print.exp b/test/utils/caps-print.exp
deleted file mode 100755
index 381f27574..000000000
--- a/test/utils/caps-print.exp
+++ /dev/null
@@ -1,32 +0,0 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2023 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
14}
15sleep 2
16
17spawn $env(SHELL)
18send -- "firejail --caps.print=test\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "setgid - disabled"
22}
23expect {
24 timeout {puts "TESTING ERROR 2\n";exit}
25 "setuid - disabled"
26}
27expect {
28 timeout {puts "TESTING ERROR 3\n";exit}
29 "net_raw - disabled"
30}
31after 100
32puts "\nall done\n"
diff --git a/test/utils/caps1.profile b/test/utils/caps1.profile
deleted file mode 100644
index 78c18fc64..000000000
--- a/test/utils/caps1.profile
+++ /dev/null
@@ -1 +0,0 @@
1caps.drop chown,kill
diff --git a/test/utils/caps2.profile b/test/utils/caps2.profile
deleted file mode 100644
index e760d4cb5..000000000
--- a/test/utils/caps2.profile
+++ /dev/null
@@ -1 +0,0 @@
1caps.keep chown,kill
diff --git a/test/utils/firemon-caps.exp b/test/utils/firemon-caps.exp
deleted file mode 100755
index 621447d45..000000000
--- a/test/utils/firemon-caps.exp
+++ /dev/null
@@ -1,129 +0,0 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2023 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=bingo1 --noprofile --caps\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
14}
15sleep 1
16
17spawn $env(SHELL)
18send -- "firejail --name=bingo2 --noprofile\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
22}
23sleep 1
24
25spawn $env(SHELL)
26send -- "firejail --name=bingo3 --noprofile --caps.drop=all\r"
27expect {
28 timeout {puts "TESTING ERROR 2\n";exit}
29 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
30}
31sleep 1
32
33spawn $env(SHELL)
34send -- "firejail --noprofile --name=bingo4 --caps.drop=chown,kill\r"
35expect {
36 timeout {puts "TESTING ERROR 3\n";exit}
37 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
38}
39sleep 1
40
41spawn $env(SHELL)
42send -- "firejail --noprofile --name=bingo5 --caps.keep=chown,kill\r"
43expect {
44 timeout {puts "TESTING ERROR 4\n";exit}
45 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
46}
47sleep 1
48
49spawn $env(SHELL)
50send -- "firejail --name=bingo6 --profile=caps1.profile\r"
51expect {
52 timeout {puts "TESTING ERROR 5\n";exit}
53 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
54}
55sleep 1
56
57spawn $env(SHELL)
58send -- "firejail --name=bingo7 --profile=caps2.profile\r"
59expect {
60 timeout {puts "TESTING ERROR 0\n";exit}
61 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
62}
63sleep 1
64
65spawn $env(SHELL)
66send -- "firemon --caps\r"
67expect {
68 timeout {puts "TESTING ERROR 8.1\n";exit}
69 "need to be root" {puts "TESTING SKIP: /proc mounted as hidepid\n"; exit}
70 "bingo1"
71}
72expect {
73 timeout {puts "TESTING ERROR 8.2\n";exit}
74 "31cffff"
75}
76expect {
77 timeout {puts "TESTING ERROR 8.3\n";exit}
78 "bingo2"
79}
80expect {
81 timeout {puts "TESTING ERROR 8.4\n";exit}
82 "fffffff"
83}
84expect {
85 timeout {puts "TESTING ERROR 8.5\n";exit}
86 "bingo3"
87}
88expect {
89 timeout {puts "TESTING ERROR 8.6\n";exit}
90 "000000000000"
91}
92
93expect {
94 timeout {puts "TESTING ERROR 8.7\n";exit}
95 "bingo4"
96}
97expect {
98 timeout {puts "TESTING ERROR 8.8\n";exit}
99 "ffffffde"
100}
101expect {
102 timeout {puts "TESTING ERROR 8.9\n";exit}
103 "bingo5"
104}
105expect {
106 timeout {puts "TESTING ERROR 8.10\n";exit}
107 "0000000000000021"
108}
109
110expect {
111 timeout {puts "TESTING ERROR 8.11\n";exit}
112 "bingo6"
113}
114expect {
115 timeout {puts "TESTING ERROR 8.12\n";exit}
116 "ffffffde"
117}
118expect {
119 timeout {puts "TESTING ERROR 8.13\n";exit}
120 "bingo7"
121}
122expect {
123 timeout {puts "TESTING ERROR 8.14\n";exit}
124 "0000000000000021"
125}
126
127after 100
128
129puts "all done\n"
diff --git a/test/utils/utils.sh b/test/utils/utils.sh
index 9f04c2625..49ff8e6de 100755
--- a/test/utils/utils.sh
+++ b/test/utils/utils.sh
@@ -61,9 +61,6 @@ echo "TESTING: fs.print (test/utils/fs-print.exp)"
61echo "TESTING: dns.print (test/utils/dns-print.exp)" 61echo "TESTING: dns.print (test/utils/dns-print.exp)"
62./dns-print.exp 62./dns-print.exp
63 63
64echo "TESTING: caps.print (test/utils/caps-print.exp)"
65./caps-print.exp
66
67echo "TESTING: seccomp.print (test/utils/seccomp-print.exp)" 64echo "TESTING: seccomp.print (test/utils/seccomp-print.exp)"
68./seccomp-print.exp 65./seccomp-print.exp
69 66
@@ -112,13 +109,6 @@ else
112 echo "TESTING SKIP: seccomp already active (test/utils/firemon-seccomp.exp)" 109 echo "TESTING SKIP: seccomp already active (test/utils/firemon-seccomp.exp)"
113fi 110fi
114 111
115if grep -q "^CapBnd:\\s0000003fffffffff" /proc/self/status; then
116 echo "TESTING: firemon caps (test/utils/firemon-caps.exp)"
117 ./firemon-caps.exp
118else
119 echo "TESTING SKIP: other capabilities than expected (test/utils/firemon-caps.exp)"
120fi
121
122echo "TESTING: firemon cpu (test/utils/firemon-cpu.exp)" 112echo "TESTING: firemon cpu (test/utils/firemon-cpu.exp)"
123./firemon-cpu.exp 113./firemon-cpu.exp
124 114