diff options
Diffstat (limited to 'test/fs/private-home.exp')
-rwxr-xr-x | test/fs/private-home.exp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/test/fs/private-home.exp b/test/fs/private-home.exp new file mode 100755 index 000000000..3840d1cb8 --- /dev/null +++ b/test/fs/private-home.exp | |||
@@ -0,0 +1,103 @@ | |||
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 | |||
6 | set timeout 10 | ||
7 | spawn $env(SHELL) | ||
8 | match_max 100000 | ||
9 | |||
10 | # create some test files in user home directory | ||
11 | send -- "touch ~/_firejail_test_file1\r" | ||
12 | after 100 | ||
13 | send -- "touch ~/_firejail_test_file2\r" | ||
14 | after 100 | ||
15 | send -- "mkdir ~/_firejail_test_dir1\r" | ||
16 | after 100 | ||
17 | send -- "mkdir ~/_firejail_test_dir1/_firejail_test_dir2\r" | ||
18 | after 100 | ||
19 | send -- "touch ~/_firejail_test_dir1/_firejail_test_dir2/_firejail_test_file3\r" | ||
20 | after 100 | ||
21 | send -- "ln -s /etc ~/_firejail_test_link1\r" | ||
22 | after 100 | ||
23 | send -- "ln -s ~/_firejail_test_dir1 ~/_firejail_test_link2\r" | ||
24 | after 100 | ||
25 | |||
26 | send -- "firejail --private-home=_firejail_test_file1,_firejail_test_file2,_firejail_test_dir1\r" | ||
27 | expect { | ||
28 | timeout {puts "TESTING ERROR 1\n";exit} | ||
29 | "Child process initialized" | ||
30 | } | ||
31 | after 100 | ||
32 | |||
33 | send -- "find ~\r" | ||
34 | expect { | ||
35 | timeout {puts "TESTING ERROR 2\n";exit} | ||
36 | "_firejail_test_file3" | ||
37 | } | ||
38 | expect { | ||
39 | timeout {puts "TESTING ERROR 3\n";exit} | ||
40 | "_firejail_test_file2" | ||
41 | } | ||
42 | expect { | ||
43 | timeout {puts "TESTING ERROR 4\n";exit} | ||
44 | "_firejail_test_file1" | ||
45 | } | ||
46 | after 100 | ||
47 | |||
48 | send -- "exit\r" | ||
49 | sleep 1 | ||
50 | |||
51 | send -- "firejail --private-home=\"bla;bla\"\r" | ||
52 | expect { | ||
53 | timeout {puts "TESTING ERROR 5\n";exit} | ||
54 | "is an invalid filename" | ||
55 | } | ||
56 | after 100 | ||
57 | |||
58 | send -- "firejail --private-home=/etc/shadow\r" | ||
59 | expect { | ||
60 | timeout {puts "TESTING ERROR 6\n";exit} | ||
61 | "invalid file" | ||
62 | } | ||
63 | after 100 | ||
64 | |||
65 | send -- "firejail --private-home=/etc/passwd\r" | ||
66 | expect { | ||
67 | timeout {puts "TESTING ERROR 7\n";exit} | ||
68 | "invalid file" | ||
69 | } | ||
70 | after 100 | ||
71 | |||
72 | send -- "firejail --private-home=../../etc/passwd\r" | ||
73 | expect { | ||
74 | timeout {puts "TESTING ERROR 8\n";exit} | ||
75 | "invalid file" | ||
76 | } | ||
77 | after 100 | ||
78 | |||
79 | send -- "firejail --private-home=_firejail_test_link1\r" | ||
80 | expect { | ||
81 | timeout {puts "TESTING ERROR 9\n";exit} | ||
82 | "to file or directory not owned by the user" | ||
83 | } | ||
84 | after 100 | ||
85 | |||
86 | send -- "firejail --private-home=_firejail_test_link2\r" | ||
87 | expect { | ||
88 | timeout {puts "TESTING ERROR 10\n";exit} | ||
89 | "Child process initialized" | ||
90 | } | ||
91 | after 100 | ||
92 | send -- "file file ~/_firejail_test_link2\r" | ||
93 | expect { | ||
94 | timeout {puts "TESTING ERROR 11\n";exit} | ||
95 | "broken symbolic link" | ||
96 | } | ||
97 | send -- "exit\r" | ||
98 | |||
99 | send -- "rm -f ~/_firejail_test*\r" | ||
100 | after 100 | ||
101 | |||
102 | puts "\nall done\n" | ||
103 | |||