diff options
author | netblue30 <netblue30@protonmail.com> | 2023-02-27 17:50:02 -0500 |
---|---|---|
committer | netblue30 <netblue30@protonmail.com> | 2023-02-27 17:50:02 -0500 |
commit | e4f9f36a47d5a0031bd181e77d9121fac1dd06ec (patch) | |
tree | e0c324bd24cf6d67f50f9dd6839e321c1d2bdb2c /test/private-etc | |
parent | minor clarify userns comments (#5686) (diff) | |
download | firejail-e4f9f36a47d5a0031bd181e77d9121fac1dd06ec.tar.gz firejail-e4f9f36a47d5a0031bd181e77d9121fac1dd06ec.tar.zst firejail-e4f9f36a47d5a0031bd181e77d9121fac1dd06ec.zip |
random hostname by default; fix --hostname and --hosts-file
Diffstat (limited to 'test/private-etc')
-rwxr-xr-x | test/private-etc/hostname.exp | 130 | ||||
-rw-r--r-- | test/private-etc/hosts-file | 2 | ||||
-rwxr-xr-x | test/private-etc/private-etc.sh | 3 |
3 files changed, 135 insertions, 0 deletions
diff --git a/test/private-etc/hostname.exp b/test/private-etc/hostname.exp new file mode 100755 index 000000000..791445d49 --- /dev/null +++ b/test/private-etc/hostname.exp | |||
@@ -0,0 +1,130 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2023 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | set timeout 10 | ||
7 | spawn $env(SHELL) | ||
8 | match_max 100000 | ||
9 | |||
10 | send -- "firejail --hostname=foo cat /etc/hostname\r" | ||
11 | expect { | ||
12 | timeout {puts "TESTING ERROR 0\n";exit} | ||
13 | "Child process initialized" | ||
14 | } | ||
15 | expect { | ||
16 | timeout {puts "TESTING ERROR 0.1\n";exit} | ||
17 | "foo" | ||
18 | } | ||
19 | sleep 1 | ||
20 | |||
21 | send -- "firejail --hostname=foo --private-etc cat /etc/hostname\r" | ||
22 | expect { | ||
23 | timeout {puts "TESTING ERROR 1\n";exit} | ||
24 | "Child process initialized" | ||
25 | } | ||
26 | expect { | ||
27 | timeout {puts "TESTING ERROR 1.1\n";exit} | ||
28 | "foo" | ||
29 | } | ||
30 | sleep 1 | ||
31 | |||
32 | send -- "firejail --hosts-file=hosts-file cat /etc/hosts\r" | ||
33 | expect { | ||
34 | timeout {puts "TESTING ERROR 2\n";exit} | ||
35 | "Child process initialized" | ||
36 | } | ||
37 | expect { | ||
38 | timeout {puts "TESTING ERROR 2.1\n";exit} | ||
39 | "blablabla" | ||
40 | } | ||
41 | sleep 1 | ||
42 | |||
43 | send -- "firejail --hosts-file=hosts-file --private-etc cat /etc/hosts\r" | ||
44 | expect { | ||
45 | timeout {puts "TESTING ERROR 3\n";exit} | ||
46 | "Child process initialized" | ||
47 | } | ||
48 | expect { | ||
49 | timeout {puts "TESTING ERROR 3.1\n";exit} | ||
50 | "blablabla" | ||
51 | } | ||
52 | sleep 1 | ||
53 | |||
54 | send -- "firejail --hosts-file=hosts-file --hostname=foo cat /etc/hosts\r" | ||
55 | expect { | ||
56 | timeout {puts "TESTING ERROR 4\n";exit} | ||
57 | "Child process initialized" | ||
58 | } | ||
59 | expect { | ||
60 | timeout {puts "TESTING ERROR 4.1\n";exit} | ||
61 | "foo" | ||
62 | } | ||
63 | expect { | ||
64 | timeout {puts "TESTING ERROR 4.2\n";exit} | ||
65 | "blablabla" | ||
66 | } | ||
67 | sleep 1 | ||
68 | |||
69 | send -- "firejail --hosts-file=hosts-file --hostname=foo --private-etc cat /etc/hosts\r" | ||
70 | expect { | ||
71 | timeout {puts "TESTING ERROR 5\n";exit} | ||
72 | "Child process initialized" | ||
73 | } | ||
74 | expect { | ||
75 | timeout {puts "TESTING ERROR 5.1\n";exit} | ||
76 | "foo" | ||
77 | } | ||
78 | expect { | ||
79 | timeout {puts "TESTING ERROR 5.2\n";exit} | ||
80 | "blablabla" | ||
81 | } | ||
82 | sleep 1 | ||
83 | |||
84 | # ping test | ||
85 | send -- "firejail --hostname=foo --private-etc ping -c 3 foo\r" | ||
86 | expect { | ||
87 | timeout {puts "TESTING ERROR 6\n";exit} | ||
88 | "3 packets transmitted, 3 received" | ||
89 | } | ||
90 | sleep 1 | ||
91 | |||
92 | send -- "firejail --hosts-file=hosts-file --private-etc ping -c 3 blablabla\r" | ||
93 | expect { | ||
94 | timeout {puts "TESTING ERROR 7\n";exit} | ||
95 | "3 packets transmitted, 3 received" | ||
96 | } | ||
97 | sleep 1 | ||
98 | |||
99 | # random hostname | ||
100 | send -- "firejail cat /etc/hostname\r" | ||
101 | expect { | ||
102 | timeout {puts "TESTING ERROR 8\n";exit} | ||
103 | "Child process initialized" | ||
104 | } | ||
105 | expect { | ||
106 | timeout {puts "TESTING ERROR 8.1\n";exit} | ||
107 | "hiko" {puts "1"} | ||
108 | "suke" {puts "2"} | ||
109 | "shi" {puts "3"} | ||
110 | "ro" {puts "4"} | ||
111 | "hito" {puts "5"} | ||
112 | "ka" {puts "6"} | ||
113 | } | ||
114 | sleep 1 | ||
115 | |||
116 | # run /bin/hostname | ||
117 | send -- "firejail --noblacklist=/usr/bin/hostname --noblacklist=/bin/hostname --hostname=foo /usr/bin/hostname\r" | ||
118 | expect { | ||
119 | timeout {puts "TESTING ERROR 9\n";exit} | ||
120 | "Child process initialized" | ||
121 | } | ||
122 | expect { | ||
123 | timeout {puts "TESTING ERROR 9.1\n";exit} | ||
124 | "foo" | ||
125 | } | ||
126 | |||
127 | |||
128 | after 500 | ||
129 | puts "all done\n" | ||
130 | |||
diff --git a/test/private-etc/hosts-file b/test/private-etc/hosts-file new file mode 100644 index 000000000..1fb39596a --- /dev/null +++ b/test/private-etc/hosts-file | |||
@@ -0,0 +1,2 @@ | |||
1 | 127.0.0.1 debian | ||
2 | 127.5.5.5 blablabla | ||
diff --git a/test/private-etc/private-etc.sh b/test/private-etc/private-etc.sh index c46b684af..0dd61cb82 100755 --- a/test/private-etc/private-etc.sh +++ b/test/private-etc/private-etc.sh | |||
@@ -18,3 +18,6 @@ echo "TESTING: groups (test/private-etc/groups.exp)" | |||
18 | 18 | ||
19 | echo "TESTING: etc-cleanup (test/private-etc/etc-cleanup.exp)" | 19 | echo "TESTING: etc-cleanup (test/private-etc/etc-cleanup.exp)" |
20 | ./etc-cleanup.exp | 20 | ./etc-cleanup.exp |
21 | |||
22 | echo "TESTING: hostname (test/private-etc/hostname.exp)" | ||
23 | ./hostname.exp | ||