aboutsummaryrefslogtreecommitdiffstats
path: root/test/fs
diff options
context:
space:
mode:
Diffstat (limited to 'test/fs')
-rwxr-xr-xtest/fs/fs.sh13
-rwxr-xr-xtest/fs/fscheck-bindnoroot.exp17
-rwxr-xr-xtest/fs/fscheck-private.exp50
-rwxr-xr-xtest/fs/fscheck-readonly.exp15
-rwxr-xr-xtest/fs/fscheck-tmpfs.exp14
-rwxr-xr-xtest/fs/invalid_filename.exp15
-rwxr-xr-xtest/fs/private-bin.exp22
-rwxr-xr-xtest/fs/private-etc.exp34
-rwxr-xr-xtest/fs/private-home.exp62
-rwxr-xr-xtest/fs/read-write.exp28
-rw-r--r--test/fs/testfile10
11 files changed, 242 insertions, 28 deletions
diff --git a/test/fs/fs.sh b/test/fs/fs.sh
index efbf505ee..1c5473f79 100755
--- a/test/fs/fs.sh
+++ b/test/fs/fs.sh
@@ -82,10 +82,21 @@ echo "TESTING: recursive mkdir (test/fs/mkdir.exp)"
82echo "TESTING: double whitelist (test/fs/whitelist-double.exp)" 82echo "TESTING: double whitelist (test/fs/whitelist-double.exp)"
83./whitelist-double.exp 83./whitelist-double.exp
84 84
85
86echo "TESTING: whitelist (test/fs/whitelist.exp)" 85echo "TESTING: whitelist (test/fs/whitelist.exp)"
87./whitelist.exp 86./whitelist.exp
88 87
88echo "TESTING: fscheck --bind non root (test/fs/fscheck-bindnoroot.exp)"
89./fscheck-bindnoroot.exp
90
91echo "TESTING: fscheck --tmpfs non root (test/fs/fscheck-tmpfs.exp)"
92./fscheck-tmpfs.exp
93
94echo "TESTING: fscheck --private= (test/fs/fscheck-private.exp)"
95./fscheck-private.exp
96
97echo "TESTING: fscheck --read-only= (test/fs/fscheck-readonly.exp)"
98./fscheck-readonly.exp
99
89#cleanup 100#cleanup
90rm -fr ~/fjtest-dir 101rm -fr ~/fjtest-dir
91rm -fr ~/fjtest-dir-lnk 102rm -fr ~/fjtest-dir-lnk
diff --git a/test/fs/fscheck-bindnoroot.exp b/test/fs/fscheck-bindnoroot.exp
new file mode 100755
index 000000000..8cbe2b8af
--- /dev/null
+++ b/test/fs/fscheck-bindnoroot.exp
@@ -0,0 +1,17 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# dir
8send -- "firejail --net=br0 --bind=testdir1,/etc\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "Error"
12}
13after 100
14
15puts "\nall done\n"
16
17
diff --git a/test/fs/fscheck-private.exp b/test/fs/fscheck-private.exp
new file mode 100755
index 000000000..28c921538
--- /dev/null
+++ b/test/fs/fscheck-private.exp
@@ -0,0 +1,50 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7
8
9# file link
10#send -- "firejail --private=fscheck-file-link\r"
11#expect {
12# timeout {puts "TESTING ERROR 2\n";exit}
13# "Error"
14#}
15#after 100
16
17# file
18send -- "firejail --private=testfile1\r"
19expect {
20 timeout {puts "TESTING ERROR 2.1\n";exit}
21 "Error"
22}
23after 100
24
25# ..
26send -- "firejail --private=../fs/testfile1\r"
27expect {
28 timeout {puts "TESTING ERROR 2.2\n";exit}
29 "Error"
30}
31after 100
32
33# no file
34send -- "firejail --private=../test/nodir\r"
35expect {
36 timeout {puts "TESTING ERROR 3\n";exit}
37 "Error"
38}
39after 100
40
41# same owner
42send -- "firejail --private=/etc\r"
43expect {
44 timeout {puts "TESTING ERROR 4\n";exit}
45 "Error"
46}
47after 100
48
49puts "\nall done\n"
50
diff --git a/test/fs/fscheck-readonly.exp b/test/fs/fscheck-readonly.exp
new file mode 100755
index 000000000..4d7528e50
--- /dev/null
+++ b/test/fs/fscheck-readonly.exp
@@ -0,0 +1,15 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# dir
8send -- "firejail --read-only=../test/testdir1\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "Error"
12}
13after 100
14
15puts "\nall done\n"
diff --git a/test/fs/fscheck-tmpfs.exp b/test/fs/fscheck-tmpfs.exp
new file mode 100755
index 000000000..deac5a631
--- /dev/null
+++ b/test/fs/fscheck-tmpfs.exp
@@ -0,0 +1,14 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# ..
8send -- "firejail --tmpfs=fscheck-dir\r"
9expect {
10 timeout {puts "TESTING ERROR 0.1\n";exit}
11 "Error"
12}
13after 100
14
diff --git a/test/fs/invalid_filename.exp b/test/fs/invalid_filename.exp
index 1acc85491..a6efc24b6 100755
--- a/test/fs/invalid_filename.exp
+++ b/test/fs/invalid_filename.exp
@@ -109,6 +109,21 @@ expect {
109} 109}
110after 100 110after 100
111 111
112send -- "firejail --debug-check-filename --noprofile --private-home=\"bla&&bla\"\r"
113expect {
114 timeout {puts "TESTING ERROR 8.1\n";exit}
115 "Checking filename bla&&bla"
116}
117expect {
118 timeout {puts "TESTING ERROR 8.2\n";exit}
119 "Error:"
120}
121expect {
122 timeout {puts "TESTING ERROR 8.3\n";exit}
123 "is an invalid filename"
124}
125after 100
126
112send -- "firejail --debug-check-filename --noprofile --private-etc=\"bla&&bla\"\r" 127send -- "firejail --debug-check-filename --noprofile --private-etc=\"bla&&bla\"\r"
113expect { 128expect {
114 timeout {puts "TESTING ERROR 9.1\n";exit} 129 timeout {puts "TESTING ERROR 9.1\n";exit}
diff --git a/test/fs/private-bin.exp b/test/fs/private-bin.exp
index fe9468be9..f7181d218 100755
--- a/test/fs/private-bin.exp
+++ b/test/fs/private-bin.exp
@@ -65,6 +65,28 @@ expect {
65 "sh" 65 "sh"
66} 66}
67send -- "exit\r" 67send -- "exit\r"
68after 100
69
70
71send -- "firejail --private-bin=/etc/shadow\r"
72expect {
73 timeout {puts "TESTING ERROR 8\n";exit}
74 "invalid filename"
75}
76after 100
77
78send -- "firejail --private-bin=\"bla;bla\"\r"
79expect {
80 timeout {puts "TESTING ERROR 9\n";exit}
81 "is an invalid filename"
82}
83after 100
84
85send -- "firejail --private-etc=../bin/ls\r"
86expect {
87 timeout {puts "TESTING ERROR 10\n";exit}
88 "is an invalid filename"
89}
68 90
69after 100 91after 100
70puts "\nall done\n" 92puts "\nall done\n"
diff --git a/test/fs/private-etc.exp b/test/fs/private-etc.exp
index e692f7382..36b5d247c 100755
--- a/test/fs/private-etc.exp
+++ b/test/fs/private-etc.exp
@@ -33,12 +33,40 @@ expect {
33 "resolv.conf" 33 "resolv.conf"
34} 34}
35 35
36send -- "ls -al /etc; echo done\r" 36
37send -- "file /etc/shadow\r"
37expect { 38expect {
38 timeout {puts "TESTING ERROR 7\n";exit} 39 timeout {puts "TESTING ERROR 7\n";exit}
39 "shadow" {puts "TESTING ERROR 8\n";exit} 40 "No such file or directory"
40 "done" 41}
42after 100
43send -- "exit\r"
44sleep 1
45
46send -- "firejail --private-etc=shadow\r"
47expect {
48 timeout {puts "TESTING ERROR 8\n";exit}
49 "invalid file type"
50}
51after 100
52
53send -- "firejail --private-etc=\"bla;bla\"\r"
54expect {
55 timeout {puts "TESTING ERROR 9\n";exit}
56 "is an invalid filename"
41} 57}
58after 100
59
60send -- "firejail --private-etc=../bin/ls\r"
61expect {
62 timeout {puts "TESTING ERROR 10\n";exit}
63 "is an invalid filename"
64}
65after 100
66
67
68
69
42 70
43after 100 71after 100
44puts "\nall done\n" 72puts "\nall done\n"
diff --git a/test/fs/private-home.exp b/test/fs/private-home.exp
index de5a88dea..3840d1cb8 100755
--- a/test/fs/private-home.exp
+++ b/test/fs/private-home.exp
@@ -9,11 +9,19 @@ match_max 100000
9 9
10# create some test files in user home directory 10# create some test files in user home directory
11send -- "touch ~/_firejail_test_file1\r" 11send -- "touch ~/_firejail_test_file1\r"
12after 100
12send -- "touch ~/_firejail_test_file2\r" 13send -- "touch ~/_firejail_test_file2\r"
14after 100
13send -- "mkdir ~/_firejail_test_dir1\r" 15send -- "mkdir ~/_firejail_test_dir1\r"
16after 100
14send -- "mkdir ~/_firejail_test_dir1/_firejail_test_dir2\r" 17send -- "mkdir ~/_firejail_test_dir1/_firejail_test_dir2\r"
18after 100
15send -- "touch ~/_firejail_test_dir1/_firejail_test_dir2/_firejail_test_file3\r" 19send -- "touch ~/_firejail_test_dir1/_firejail_test_dir2/_firejail_test_file3\r"
16after 100 20after 100
21send -- "ln -s /etc ~/_firejail_test_link1\r"
22after 100
23send -- "ln -s ~/_firejail_test_dir1 ~/_firejail_test_link2\r"
24after 100
17 25
18send -- "firejail --private-home=_firejail_test_file1,_firejail_test_file2,_firejail_test_dir1\r" 26send -- "firejail --private-home=_firejail_test_file1,_firejail_test_file2,_firejail_test_dir1\r"
19expect { 27expect {
@@ -37,8 +45,58 @@ expect {
37} 45}
38after 100 46after 100
39 47
40send -- "rm -f ~/_firejail_test_file*\r" 48send -- "exit\r"
41send -- "rm -fr ~/_firejail_test_dir*\r" 49sleep 1
50
51send -- "firejail --private-home=\"bla;bla\"\r"
52expect {
53 timeout {puts "TESTING ERROR 5\n";exit}
54 "is an invalid filename"
55}
56after 100
57
58send -- "firejail --private-home=/etc/shadow\r"
59expect {
60 timeout {puts "TESTING ERROR 6\n";exit}
61 "invalid file"
62}
63after 100
64
65send -- "firejail --private-home=/etc/passwd\r"
66expect {
67 timeout {puts "TESTING ERROR 7\n";exit}
68 "invalid file"
69}
70after 100
71
72send -- "firejail --private-home=../../etc/passwd\r"
73expect {
74 timeout {puts "TESTING ERROR 8\n";exit}
75 "invalid file"
76}
77after 100
78
79send -- "firejail --private-home=_firejail_test_link1\r"
80expect {
81 timeout {puts "TESTING ERROR 9\n";exit}
82 "to file or directory not owned by the user"
83}
84after 100
85
86send -- "firejail --private-home=_firejail_test_link2\r"
87expect {
88 timeout {puts "TESTING ERROR 10\n";exit}
89 "Child process initialized"
90}
91after 100
92send -- "file file ~/_firejail_test_link2\r"
93expect {
94 timeout {puts "TESTING ERROR 11\n";exit}
95 "broken symbolic link"
96}
97send -- "exit\r"
98
99send -- "rm -f ~/_firejail_test*\r"
42after 100 100after 100
43 101
44puts "\nall done\n" 102puts "\nall done\n"
diff --git a/test/fs/read-write.exp b/test/fs/read-write.exp
index 57986488e..19a915f66 100755
--- a/test/fs/read-write.exp
+++ b/test/fs/read-write.exp
@@ -15,37 +15,21 @@ expect {
15} 15}
16sleep 1 16sleep 1
17 17
18send -- "echo mytest >~/_firejail_test_dir/a;echo done\r" 18send -- "echo mytest > ~/_firejail_test_dir/a\r"
19expect { 19expect {
20 timeout {puts "TESTING ERROR 1\n";exit} 20 timeout {puts "TESTING ERROR 5\n";exit}
21 "done" 21 "Read-only file system"
22}
23after 100
24
25send -- "echo mytest >~/_firejail_test_dir/test1/b;echo done\r"
26expect {
27 timeout {puts "TESTING ERROR 2\n";exit}
28 "done"
29} 22}
30after 100 23after 100
31 24
32send -- "cat ~/_firejail_test_dir/a;echo done\r" 25send -- "echo mytest > ~/_firejail_test_dir/test1/b\r"
33expect { 26sleep 1
34 timeout {puts "TESTING ERROR 3\n";exit}
35 "mytest" {puts "TESTING ERROR 4\n";exit}
36 "done"
37}
38after 100
39 27
40send -- "cat ~/_firejail_test_dir/test1/b;echo done\r" 28send -- "cat ~/_firejail_test_dir/test1/b\r"
41expect { 29expect {
42 timeout {puts "TESTING ERROR 5\n";exit} 30 timeout {puts "TESTING ERROR 5\n";exit}
43 "mytest" 31 "mytest"
44} 32}
45expect {
46 timeout {puts "TESTING ERROR 6\n";exit}
47 "done"
48}
49 33
50after 100 34after 100
51puts "\nall done\n" 35puts "\nall done\n"
diff --git a/test/fs/testfile1 b/test/fs/testfile1
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test/fs/testfile1