aboutsummaryrefslogtreecommitdiffstats
path: root/test/network
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2018-07-16 09:49:55 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2018-07-16 09:49:55 -0400
commit2bea8f674112e02604bd5aeff12e9d642cdad7b2 (patch)
tree4c40577178898b83e769c0356ee78617e0d2329a /test/network
parentMerge branch 'master' of https://github.com/netblue30/firejail (diff)
downloadfirejail-2bea8f674112e02604bd5aeff12e9d642cdad7b2.tar.gz
firejail-2bea8f674112e02604bd5aeff12e9d642cdad7b2.tar.zst
firejail-2bea8f674112e02604bd5aeff12e9d642cdad7b2.zip
network testing
Diffstat (limited to 'test/network')
-rwxr-xr-xtest/network/configure2
-rwxr-xr-xtest/network/net_noip.exp1
-rwxr-xr-xtest/network/net_noip2.exp1
-rwxr-xr-xtest/network/net_unconfigured.exp244
-rwxr-xr-xtest/network/network.sh3
5 files changed, 251 insertions, 0 deletions
diff --git a/test/network/configure b/test/network/configure
index 9d47fe69e..9859519bd 100755
--- a/test/network/configure
+++ b/test/network/configure
@@ -10,6 +10,8 @@ iptables -t nat -A POSTROUTING -o eth0 -s 10.10.20.0/29 -j MASQUERADE
10# port forwarding 10# port forwarding
11# iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 10.10.20.2:80 11# iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 10.10.20.2:80
12 12
13brctl addbr br-unconfigured
14ifconfig br-unconfigured up
13brctl addbr br1 15brctl addbr br1
14ifconfig br1 10.10.30.1/24 up 16ifconfig br1 10.10.30.1/24 up
15brctl addbr br2 17brctl addbr br2
diff --git a/test/network/net_noip.exp b/test/network/net_noip.exp
index 958586ccb..125862c2b 100755
--- a/test/network/net_noip.exp
+++ b/test/network/net_noip.exp
@@ -39,6 +39,7 @@ expect {
39} 39}
40expect { 40expect {
41 timeout {puts "TESTING ERROR 6\n";exit} 41 timeout {puts "TESTING ERROR 6\n";exit}
42 "10.10.20" {puts "TESTING ERROR 7\n";exit}
42 "done" 43 "done"
43} 44}
44send -- "exit\r" 45send -- "exit\r"
diff --git a/test/network/net_noip2.exp b/test/network/net_noip2.exp
index 8a6748114..c9df2c36f 100755
--- a/test/network/net_noip2.exp
+++ b/test/network/net_noip2.exp
@@ -38,6 +38,7 @@ expect {
38} 38}
39expect { 39expect {
40 timeout {puts "TESTING ERROR 6\n";exit} 40 timeout {puts "TESTING ERROR 6\n";exit}
41 "10.10.30" {puts "TESTING ERROR 7\n";exit}
41 "done" 42 "done"
42} 43}
43send -- "exit\r" 44send -- "exit\r"
diff --git a/test/network/net_unconfigured.exp b/test/network/net_unconfigured.exp
new file mode 100755
index 000000000..6f1be0e50
--- /dev/null
+++ b/test/network/net_unconfigured.exp
@@ -0,0 +1,244 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2018 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10# check ip address
11send -- "firejail --noprofile --net=br-unconfigured --ip=none\r"
12expect {
13 timeout {puts "TESTING ERROR 0\n";exit}
14 "eth0" {puts "TESTING ERROR 1\n";exit}
15 "Child process initialized"
16}
17sleep 1
18send -- "bash\r"
19sleep 1
20
21send -- "stty -echo\r"
22after 100
23
24# no default gateway configured
25send -- "netstat -rn;echo done\r"
26expect {
27 timeout {puts "TESTING ERROR 2\n";exit}
28 "0.0.0.0" {puts "TESTING ERROR 3\n";exit}
29 "eth0" {puts "TESTING ERROR 4\n";exit}
30 "done"
31}
32sleep 1
33
34# eth0 configured
35send -- "/sbin/ifconfig;echo done\r"
36expect {
37 timeout {puts "TESTING ERROR 5\n";exit}
38 "eth0"
39}
40expect {
41 timeout {puts "TESTING ERROR 6\n";exit}
42 "done"
43}
44send -- "exit\r"
45after 100
46send -- "exit\r"
47after 100
48
49
50
51# check ip address
52send -- "firejail --noprofile --net=br-unconfigured\r"
53expect {
54 timeout {puts "TESTING ERROR 7\n";exit}
55 "eth0" {puts "TESTING ERROR 8\n";exit}
56 "Child process initialized"
57}
58sleep 1
59send -- "bash\r"
60sleep 1
61
62send -- "stty -echo\r"
63after 100
64
65# no default gateway configured
66send -- "netstat -rn;echo done\r"
67expect {
68 timeout {puts "TESTING ERROR 9\n";exit}
69 "0.0.0.0" {puts "TESTING ERROR 10\n";exit}
70 "eth0" {puts "TESTING ERROR 11\n";exit}
71 "done"
72}
73sleep 1
74
75# eth0 configured
76send -- "/sbin/ifconfig;echo done\r"
77expect {
78 timeout {puts "TESTING ERROR 12\n";exit}
79 "eth0"
80}
81expect {
82 timeout {puts "TESTING ERROR 13\n";exit}
83 "done"
84}
85send -- "exit\r"
86after 100
87send -- "exit\r"
88after 100
89
90
91# check ip address
92send -- "firejail --noprofile --net=br-unconfigured --defaultgw=10.10.80.1\r"
93expect {
94 timeout {puts "TESTING ERROR 14\n";exit}
95 "eth0" {puts "TESTING ERROR 15\n";exit}
96 "Child process initialized"
97}
98sleep 1
99send -- "bash\r"
100sleep 1
101
102send -- "stty -echo\r"
103after 100
104
105# no default gateway configured
106send -- "netstat -rn;echo done\r"
107expect {
108 timeout {puts "TESTING ERROR 16\n";exit}
109 "0.0.0.0" {puts "TESTING ERROR 17\n";exit}
110 "eth0" {puts "TESTING ERROR 18\n";exit}
111 "done"
112}
113sleep 1
114
115# eth0 configured
116send -- "/sbin/ifconfig;echo done\r"
117expect {
118 timeout {puts "TESTING ERROR 19\n";exit}
119 "eth0"
120}
121expect {
122 timeout {puts "TESTING ERROR 20\n";exit}
123 "done"
124}
125send -- "exit\r"
126after 100
127send -- "exit\r"
128after 100
129
130
131# check ip address
132send -- "firejail --noprofile --net=br-unconfigured --ip=10.10.80.1 --defaultgw=10.10.80.1\r"
133expect {
134 timeout {puts "TESTING ERROR 21\n";exit}
135 "eth0" {puts "TESTING ERROR 22\n";exit}
136 "Child process initialized"
137}
138sleep 1
139send -- "bash\r"
140sleep 1
141
142send -- "stty -echo\r"
143after 100
144
145# no default gateway configured
146send -- "netstat -rn;echo done\r"
147expect {
148 timeout {puts "TESTING ERROR 23\n";exit}
149 "0.0.0.0" {puts "TESTING ERROR 24\n";exit}
150 "eth0" {puts "TESTING ERROR 25\n";exit}
151 "done"
152}
153sleep 1
154
155# eth0 configured
156send -- "/sbin/ifconfig;echo done\r"
157expect {
158 timeout {puts "TESTING ERROR 26\n";exit}
159 "eth0"
160}
161expect {
162 timeout {puts "TESTING ERROR 27\n";exit}
163 "done"
164}
165send -- "exit\r"
166after 100
167send -- "exit\r"
168after 100
169
170
171# check ip address
172send -- "firejail --noprofile --net=br-unconfigured --ip=10.10.80.1 --netmask=255.255.255.0 --defaultgw=10.10.80.1\r"
173expect {
174 timeout {puts "TESTING ERROR 28\n";exit}
175 "eth0"
176}
177expect {
178 timeout {puts "TESTING ERROR 29\n";exit}
179 "10.10.80.1"
180}
181expect {
182 timeout {puts "TESTING ERROR 30\n";exit}
183 "Child process initialized"
184}
185sleep 1
186send -- "bash\r"
187sleep 1
188
189send -- "stty -echo\r"
190after 100
191
192# no default gateway configured
193send -- "netstat -rn;echo done\r"
194expect {
195 timeout {puts "TESTING ERROR 31\n";exit}
196 "0.0.0.0"
197}
198expect {
199 timeout {puts "TESTING ERROR 32\n";exit}
200 "10.10.80.1"
201}
202expect {
203 timeout {puts "TESTING ERROR 33\n";exit}
204 "eth0"
205}
206expect {
207 timeout {puts "TESTING ERROR 34\n";exit}
208 "10.10.80.0"
209}
210expect {
211 timeout {puts "TESTING ERROR 35\n";exit}
212 "0.0.0.0"
213}
214expect {
215 timeout {puts "TESTING ERROR 36\n";exit}
216 "eth0"
217}
218expect {
219 timeout {puts "TESTING ERROR 37\n";exit}
220 "done"
221}
222sleep 1
223
224# eth0 configured
225send -- "/sbin/ifconfig;echo done\r"
226expect {
227 timeout {puts "TESTING ERROR 38\n";exit}
228 "eth0"
229}
230expect {
231 timeout {puts "TESTING ERROR 39\n";exit}
232 "10.10.80.1"
233}
234expect {
235 timeout {puts "TESTING ERROR 40\n";exit}
236 "done"
237}
238send -- "exit\r"
239after 100
240send -- "exit\r"
241after 100
242
243
244puts "all done\n"
diff --git a/test/network/network.sh b/test/network/network.sh
index 4f001b49c..fa6f214cd 100755
--- a/test/network/network.sh
+++ b/test/network/network.sh
@@ -8,6 +8,9 @@ export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8 8
9sudo ./configure 9sudo ./configure
10 10
11echo "TESTING: unconfigured network (net_unconfigured.exp)"
12./net_unconfigured.exp
13
11echo "TESTING: netfilter template (netfilter-template.exp)" 14echo "TESTING: netfilter template (netfilter-template.exp)"
12rm -f ./tcpserver 15rm -f ./tcpserver
13gcc -o tcpserver tcpserver.c 16gcc -o tcpserver tcpserver.c