diff options
Diffstat (limited to 'test/fs/private-bin.exp')
-rwxr-xr-x | test/fs/private-bin.exp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/test/fs/private-bin.exp b/test/fs/private-bin.exp new file mode 100755 index 000000000..f7181d218 --- /dev/null +++ b/test/fs/private-bin.exp | |||
@@ -0,0 +1,93 @@ | |||
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 | send -- "firejail --private-bin=bash,ls,sh\r" | ||
11 | expect { | ||
12 | timeout {puts "TESTING ERROR 1\n";exit} | ||
13 | "Child process initialized" | ||
14 | } | ||
15 | sleep 1 | ||
16 | |||
17 | send -- "ls /bin\r" | ||
18 | expect { | ||
19 | timeout {puts "TESTING ERROR 2\n";exit} | ||
20 | "bash" | ||
21 | } | ||
22 | expect { | ||
23 | timeout {puts "TESTING ERROR 3\n";exit} | ||
24 | "ls" | ||
25 | } | ||
26 | expect { | ||
27 | timeout {puts "TESTING ERROR 4\n";exit} | ||
28 | "sh" | ||
29 | } | ||
30 | |||
31 | send -- "ls /bin\r" | ||
32 | expect { | ||
33 | timeout {puts "TESTING ERROR 5\n";exit} | ||
34 | "ping" {puts "TESTING ERROR 6\n";exit} | ||
35 | "sh" | ||
36 | } | ||
37 | send -- "exit\r" | ||
38 | sleep 1 | ||
39 | |||
40 | send -- "firejail --profile=private-bin.profile\r" | ||
41 | expect { | ||
42 | timeout {puts "TESTING ERROR 7\n";exit} | ||
43 | "Child process initialized" | ||
44 | } | ||
45 | sleep 1 | ||
46 | |||
47 | send -- "ls /bin\r" | ||
48 | expect { | ||
49 | timeout {puts "TESTING ERROR 8\n";exit} | ||
50 | "bash" | ||
51 | } | ||
52 | expect { | ||
53 | timeout {puts "TESTING ERROR 9\n";exit} | ||
54 | "ls" | ||
55 | } | ||
56 | expect { | ||
57 | timeout {puts "TESTING ERROR 10\n";exit} | ||
58 | "sh" | ||
59 | } | ||
60 | |||
61 | send -- "ls /bin\r" | ||
62 | expect { | ||
63 | timeout {puts "TESTING ERROR 5\n";exit} | ||
64 | "ping" {puts "TESTING ERROR 6\n";exit} | ||
65 | "sh" | ||
66 | } | ||
67 | send -- "exit\r" | ||
68 | after 100 | ||
69 | |||
70 | |||
71 | send -- "firejail --private-bin=/etc/shadow\r" | ||
72 | expect { | ||
73 | timeout {puts "TESTING ERROR 8\n";exit} | ||
74 | "invalid filename" | ||
75 | } | ||
76 | after 100 | ||
77 | |||
78 | send -- "firejail --private-bin=\"bla;bla\"\r" | ||
79 | expect { | ||
80 | timeout {puts "TESTING ERROR 9\n";exit} | ||
81 | "is an invalid filename" | ||
82 | } | ||
83 | after 100 | ||
84 | |||
85 | send -- "firejail --private-etc=../bin/ls\r" | ||
86 | expect { | ||
87 | timeout {puts "TESTING ERROR 10\n";exit} | ||
88 | "is an invalid filename" | ||
89 | } | ||
90 | |||
91 | after 100 | ||
92 | puts "\nall done\n" | ||
93 | |||