aboutsummaryrefslogtreecommitdiffstats
path: root/test/capabilities
diff options
context:
space:
mode:
Diffstat (limited to 'test/capabilities')
-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
5 files changed, 66 insertions, 40 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"