aboutsummaryrefslogtreecommitdiffstats
path: root/test/fs
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-08-05 12:37:53 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-08-05 12:37:53 -0400
commit2775b37ed206e5650b1ec4398d33718562f4d657 (patch)
tree0204a9f1a2938787f362ec45681fbeb596c90408 /test/fs
parentMerge pull request #684 from Fred-Barclay/checkmate (diff)
downloadfirejail-2775b37ed206e5650b1ec4398d33718562f4d657.tar.gz
firejail-2775b37ed206e5650b1ec4398d33718562f4d657.tar.zst
firejail-2775b37ed206e5650b1ec4398d33718562f4d657.zip
whitelist test
Diffstat (limited to 'test/fs')
-rwxr-xr-xtest/fs/fs.sh13
-rwxr-xr-xtest/fs/whitelist-double.exp2
-rwxr-xr-xtest/fs/whitelist.exp226
3 files changed, 240 insertions, 1 deletions
diff --git a/test/fs/fs.sh b/test/fs/fs.sh
index ee6351e2e..d45ef48bd 100755
--- a/test/fs/fs.sh
+++ b/test/fs/fs.sh
@@ -56,3 +56,16 @@ echo "TESTING: recursive mkdir (test/fs/mkdir.exp)"
56 56
57echo "TESTING: double whitelist (test/fs/whitelist-double.exp)" 57echo "TESTING: double whitelist (test/fs/whitelist-double.exp)"
58./whitelist-double.exp 58./whitelist-double.exp
59
60
61echo "TESTING: whitelist (test/fs/whitelist.exp)"
62./whitelist.exp
63rm -fr ~/fjtest-dir
64rm -fr ~/fjtest-dir-lnk
65rm -f ~/fjtest-file
66rm -f ~/fjtest-file-lnk
67rm -f /tmp/fjtest-file
68rm -fr /tmp/fjtest-dir
69
70
71
diff --git a/test/fs/whitelist-double.exp b/test/fs/whitelist-double.exp
index 87d6ed686..43e4d6fc0 100755
--- a/test/fs/whitelist-double.exp
+++ b/test/fs/whitelist-double.exp
@@ -3,7 +3,7 @@
3# Copyright (C) 2014-2016 Firejail Authors 3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2 4# License GPL v2
5 5
6set timeout 30 6set timeout 10
7spawn $env(SHELL) 7spawn $env(SHELL)
8match_max 100000 8match_max 100000
9 9
diff --git a/test/fs/whitelist.exp b/test/fs/whitelist.exp
new file mode 100755
index 000000000..9a9a0f353
--- /dev/null
+++ b/test/fs/whitelist.exp
@@ -0,0 +1,226 @@
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
10# cleanup
11send -- "rm -fr ~/fjtest-dir\r"
12after 200
13send -- "rm -fr ~/fjtest-dir-lnk\r"
14after 200
15send -- "rm ~/fjtest-file\r"
16after 200
17send -- "rm ~/fjtest-file-lnk\r"
18after 200
19send -- "rm /tmp/fjtest-file\r"
20after 200
21send -- "rm -fr /tmp/fjtest-dir\r"
22after 200
23
24
25# simple files and directories
26send -- "mkdir -p ~/fjtest-dir/fjtest-dir\r"
27after 200
28send -- "echo 123 > ~/fjtest-file\r"
29after 200
30send -- "echo 123 > ~/fjtest-dir/fjtest-file\r"
31after 200
32send -- "echo 123 > ~/fjtest-dir/fjtest-dir/fjtest-file\r"
33after 200
34send -- "ln -s ~/fjtest-file ~/fjtest-file-lnk\r"
35after 200
36send -- "ln -s ~/fjtest-dir ~/fjtest-dir-lnk\r"
37after 200
38
39send -- "firejail --whitelist=~/fjtest-file --whitelist=~/fjtest-dir\r"
40expect {
41 timeout {puts "TESTING ERROR 0\n";exit}
42 "Child process initialized"
43}
44sleep 1
45
46send -- "ls -l ~/ | grep -v total | wc -l\r"
47expect {
48 timeout {puts "TESTING ERROR 1\n";exit}
49 "2"
50}
51
52send -- "cat fjtest-file\r"
53expect {
54 timeout {puts "TESTING ERROR 2\n";exit}
55 "123"
56}
57
58send -- "cat fjtest-dir/fjtest-file\r"
59expect {
60 timeout {puts "TESTING ERROR 3\n";exit}
61 "123"
62}
63
64send -- "cat fjtest-dir/fjtest-dir/fjtest-file\r"
65expect {
66 timeout {puts "TESTING ERROR 4\n";exit}
67 "123"
68}
69
70send -- "exit\r"
71sleep 1
72
73
74
75# simple files and directories
76send -- "firejail --whitelist=~/fjtest-dir/fjtest-dir/fjtest-file\r"
77expect {
78 timeout {puts "TESTING ERROR 10\n";exit}
79 "Child process initialized"
80}
81sleep 1
82
83send -- "ls -l ~/ | grep -v total | wc -l\r"
84expect {
85 timeout {puts "TESTING ERROR 11\n";exit}
86 "1"
87}
88
89send -- "cat fjtest-dir/fjtest-dir/fjtest-file\r"
90expect {
91 timeout {puts "TESTING ERROR 12\n";exit}
92 "123"
93}
94
95send -- "exit\r"
96sleep 1
97
98
99
100# symlinks
101send -- "firejail --whitelist=~/fjtest-file-lnk --whitelist=~/fjtest-dir-lnk\r"
102expect {
103 timeout {puts "TESTING ERROR 20\n";exit}
104 "Child process initialized"
105}
106sleep 1
107
108send -- "ls -l ~/ | grep -v total | wc -l\r"
109expect {
110 timeout {puts "TESTING ERROR 21\n";exit}
111 "4"
112}
113
114send -- "cat fjtest-file\r"
115expect {
116 timeout {puts "TESTING ERROR 22\n";exit}
117 "123"
118}
119
120send -- "cat fjtest-dir/fjtest-file\r"
121expect {
122 timeout {puts "TESTING ERROR 23\n";exit}
123 "123"
124}
125
126send -- "cat fjtest-dir/fjtest-dir/fjtest-file\r"
127expect {
128 timeout {puts "TESTING ERROR 24\n";exit}
129 "123"
130}
131
132send -- "cat fjtest-file-lnk\r"
133expect {
134 timeout {puts "TESTING ERROR 25\n";exit}
135 "123"
136}
137
138send -- "cat fjtest-dir-lnk/fjtest-file\r"
139expect {
140 timeout {puts "TESTING ERROR 26\n";exit}
141 "123"
142}
143
144send -- "cat fjtest-dir-lnk/fjtest-dir/fjtest-file\r"
145expect {
146 timeout {puts "TESTING ERROR 27\n";exit}
147 "123"
148}
149send -- "exit\r"
150sleep 1
151
152# symlinks outside home to a file we don't own
153send -- "rm ~/fjtest-file-lnk\r"
154after 200
155send -- "ln -s /etc/passwd ~/fjtest-file-lnk\r"
156after 200
157send -- "firejail --whitelist=~/fjtest-file-lnk --whitelist=~/fjtest-dir-lnk\r"
158expect {
159 timeout {puts "TESTING ERROR 30\n";exit}
160 "invalid whitelist path"
161}
162expect {
163 timeout {puts "TESTING ERROR 31\n";exit}
164 "exiting"
165}
166sleep 1
167
168# symlinks outside home to a file we own
169send -- "rm -fr ~/fjtest-dir-lnk\r"
170after 200
171send -- "rm ~/fjtest-file-lnk\r"
172after 200
173send -- "echo 123 > /tmp/fjtest-file\r"
174after 200
175send -- "mkdir /tmp/fjtest-dir\r"
176after 200
177send -- "echo 123 > /tmp/fjtest-dir/fjtest-file\r"
178after 200
179send -- "ln -s /tmp/fjtest-file ~/fjtest-file-lnk\r"
180after 200
181send -- "ln -s /tmp/fjtest-dir ~/fjtest-dir-lnk\r"
182after 200
183send -- "firejail --whitelist=~/fjtest-file-lnk --whitelist=~/fjtest-dir-lnk\r"
184expect {
185 timeout {puts "TESTING ERROR 40\n";exit}
186 "Child process initialized"
187}
188sleep 1
189
190send -- "ls -l ~/ | grep -v total | wc -l\r"
191expect {
192 timeout {puts "TESTING ERROR 41\n";exit}
193 "2"
194}
195
196send -- "cat fjtest-file-lnk\r"
197expect {
198 timeout {puts "TESTING ERROR 42\n";exit}
199 "123"
200}
201
202send -- "cat fjtest-dir-lnk/fjtest-file\r"
203expect {
204 timeout {puts "TESTING ERROR 43\n";exit}
205 "123"
206}
207send -- "exit\r"
208sleep 1
209
210# cleanup
211send -- "rm -fr ~/fjtest-dir\r"
212after 200
213send -- "rm -fr ~/fjtest-dir-lnk\r"
214after 200
215send -- "rm ~/fjtest-file\r"
216after 200
217send -- "rm ~/fjtest-file-lnk\r"
218after 200
219send -- "rm /tmp/fjtest-file\r"
220after 200
221send -- "rm -fr /tmp/fjtest-dir\r"
222after 200
223
224
225puts "\nall done\n"
226