diff options
author | 2023-02-06 22:28:25 -0500 | |
---|---|---|
committer | 2023-02-06 22:28:25 -0500 | |
commit | cb1104edf9c6ed0dc753724259b5c12fa5619afb (patch) | |
tree | d654d6547a7836faf5467cb37dac9f3ab50f7107 /test/private-etc/private-etc.exp | |
parent | testing (diff) | |
download | firejail-cb1104edf9c6ed0dc753724259b5c12fa5619afb.tar.gz firejail-cb1104edf9c6ed0dc753724259b5c12fa5619afb.tar.zst firejail-cb1104edf9c6ed0dc753724259b5c12fa5619afb.zip |
private-etc testing
Diffstat (limited to 'test/private-etc/private-etc.exp')
-rwxr-xr-x | test/private-etc/private-etc.exp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/test/private-etc/private-etc.exp b/test/private-etc/private-etc.exp new file mode 100755 index 000000000..3aac7cdf2 --- /dev/null +++ b/test/private-etc/private-etc.exp | |||
@@ -0,0 +1,68 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2022 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | set timeout 10 | ||
7 | spawn $env(SHELL) | ||
8 | match_max 100000 | ||
9 | |||
10 | send -- "firejail --private-etc=passwd,group,resolv.conf,X11\r" | ||
11 | expect { | ||
12 | timeout {puts "TESTING ERROR 1\n";exit} | ||
13 | -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" | ||
14 | } | ||
15 | sleep 1 | ||
16 | |||
17 | send -- "LC_ALL=C ls -al /etc\r" | ||
18 | expect { | ||
19 | timeout {puts "TESTING ERROR 3\n";exit} | ||
20 | "X11" | ||
21 | } | ||
22 | expect { | ||
23 | timeout {puts "TESTING ERROR 4\n";exit} | ||
24 | "group" | ||
25 | } | ||
26 | expect { | ||
27 | timeout {puts "TESTING ERROR 5\n";exit} | ||
28 | "passwd" | ||
29 | } | ||
30 | expect { | ||
31 | timeout {puts "TESTING ERROR 6\n";exit} | ||
32 | "resolv.conf" | ||
33 | } | ||
34 | |||
35 | |||
36 | send -- "file /etc/shadow\r" | ||
37 | expect { | ||
38 | timeout {puts "TESTING ERROR 7\n";exit} | ||
39 | "No such file or directory" | ||
40 | } | ||
41 | after 100 | ||
42 | send -- "exit\r" | ||
43 | sleep 1 | ||
44 | |||
45 | send -- "firejail --private-etc=shadow\r" | ||
46 | expect { | ||
47 | timeout {puts "TESTING ERROR 8\n";exit} | ||
48 | "invalid file type" | ||
49 | } | ||
50 | after 100 | ||
51 | |||
52 | send -- "firejail --private-etc=\"bla;bla\"\r" | ||
53 | expect { | ||
54 | timeout {puts "TESTING ERROR 9\n";exit} | ||
55 | "is an invalid filename" | ||
56 | } | ||
57 | after 100 | ||
58 | |||
59 | send -- "firejail --private-etc=../bin/ls\r" | ||
60 | expect { | ||
61 | timeout {puts "TESTING ERROR 10\n";exit} | ||
62 | "is an invalid filename" | ||
63 | } | ||
64 | after 100 | ||
65 | |||
66 | send -- "exit\r" | ||
67 | after 100 | ||
68 | puts "\nall done\n" | ||