aboutsummaryrefslogtreecommitdiffstats
path: root/test/private-etc/hostname.exp
diff options
context:
space:
mode:
Diffstat (limited to 'test/private-etc/hostname.exp')
-rwxr-xr-xtest/private-etc/hostname.exp130
1 files changed, 130 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
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --hostname=foo cat /etc/hostname\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15expect {
16 timeout {puts "TESTING ERROR 0.1\n";exit}
17 "foo"
18}
19sleep 1
20
21send -- "firejail --hostname=foo --private-etc cat /etc/hostname\r"
22expect {
23 timeout {puts "TESTING ERROR 1\n";exit}
24 "Child process initialized"
25}
26expect {
27 timeout {puts "TESTING ERROR 1.1\n";exit}
28 "foo"
29}
30sleep 1
31
32send -- "firejail --hosts-file=hosts-file cat /etc/hosts\r"
33expect {
34 timeout {puts "TESTING ERROR 2\n";exit}
35 "Child process initialized"
36}
37expect {
38 timeout {puts "TESTING ERROR 2.1\n";exit}
39 "blablabla"
40}
41sleep 1
42
43send -- "firejail --hosts-file=hosts-file --private-etc cat /etc/hosts\r"
44expect {
45 timeout {puts "TESTING ERROR 3\n";exit}
46 "Child process initialized"
47}
48expect {
49 timeout {puts "TESTING ERROR 3.1\n";exit}
50 "blablabla"
51}
52sleep 1
53
54send -- "firejail --hosts-file=hosts-file --hostname=foo cat /etc/hosts\r"
55expect {
56 timeout {puts "TESTING ERROR 4\n";exit}
57 "Child process initialized"
58}
59expect {
60 timeout {puts "TESTING ERROR 4.1\n";exit}
61 "foo"
62}
63expect {
64 timeout {puts "TESTING ERROR 4.2\n";exit}
65 "blablabla"
66}
67sleep 1
68
69send -- "firejail --hosts-file=hosts-file --hostname=foo --private-etc cat /etc/hosts\r"
70expect {
71 timeout {puts "TESTING ERROR 5\n";exit}
72 "Child process initialized"
73}
74expect {
75 timeout {puts "TESTING ERROR 5.1\n";exit}
76 "foo"
77}
78expect {
79 timeout {puts "TESTING ERROR 5.2\n";exit}
80 "blablabla"
81}
82sleep 1
83
84# ping test
85send -- "firejail --hostname=foo --private-etc ping -c 3 foo\r"
86expect {
87 timeout {puts "TESTING ERROR 6\n";exit}
88 "3 packets transmitted, 3 received"
89}
90sleep 1
91
92send -- "firejail --hosts-file=hosts-file --private-etc ping -c 3 blablabla\r"
93expect {
94 timeout {puts "TESTING ERROR 7\n";exit}
95 "3 packets transmitted, 3 received"
96}
97sleep 1
98
99# random hostname
100send -- "firejail cat /etc/hostname\r"
101expect {
102 timeout {puts "TESTING ERROR 8\n";exit}
103 "Child process initialized"
104}
105expect {
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}
114sleep 1
115
116# run /bin/hostname
117send -- "firejail --noblacklist=/usr/bin/hostname --noblacklist=/bin/hostname --hostname=foo /usr/bin/hostname\r"
118expect {
119 timeout {puts "TESTING ERROR 9\n";exit}
120 "Child process initialized"
121}
122expect {
123 timeout {puts "TESTING ERROR 9.1\n";exit}
124 "foo"
125}
126
127
128after 500
129puts "all done\n"
130