summaryrefslogtreecommitdiffstats
path: root/test/network
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-05-03 08:41:24 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-05-03 08:41:24 -0400
commit57bea6c8c4d1bd666ce57057b1cbb681b3cc4afc (patch)
tree60f90718665a1a812b552f589bc4d85616232df1 /test/network
parentMerge branch 'master' of https://github.com/netblue30/firejail (diff)
downloadfirejail-57bea6c8c4d1bd666ce57057b1cbb681b3cc4afc.tar.gz
firejail-57bea6c8c4d1bd666ce57057b1cbb681b3cc4afc.tar.zst
firejail-57bea6c8c4d1bd666ce57057b1cbb681b3cc4afc.zip
networking features testing
Diffstat (limited to 'test/network')
-rwxr-xr-xtest/network/4bridges_arp.exp170
-rwxr-xr-xtest/network/4bridges_ip.exp174
-rwxr-xr-xtest/network/bandwidth.exp62
-rwxr-xr-xtest/network/hostname.exp25
-rwxr-xr-xtest/network/ip6.exp43
-rw-r--r--test/network/ipv6.net8
-rw-r--r--test/network/net-profile.profile10
-rwxr-xr-xtest/network/net_arp.exp71
-rwxr-xr-xtest/network/net_badip.exp16
-rwxr-xr-xtest/network/net_defaultgw.exp46
-rwxr-xr-xtest/network/net_defaultgw2.exp40
-rwxr-xr-xtest/network/net_defaultgw3.exp17
-rwxr-xr-xtest/network/net_interface.exp88
-rwxr-xr-xtest/network/net_ip.exp72
-rwxr-xr-xtest/network/net_local.exp45
-rwxr-xr-xtest/network/net_mac.exp36
-rwxr-xr-xtest/network/net_macvlan.exp88
-rwxr-xr-xtest/network/net_mtu.exp30
-rwxr-xr-xtest/network/net_netfilter.exp88
-rwxr-xr-xtest/network/net_noip.exp41
-rwxr-xr-xtest/network/net_noip2.exp41
-rwxr-xr-xtest/network/net_none.exp68
-rw-r--r--test/network/net_none.profile1
-rwxr-xr-xtest/network/net_profile.exp73
-rw-r--r--test/network/netfilter.filter6
-rw-r--r--test/network/netfilter.profile1
26 files changed, 1360 insertions, 0 deletions
diff --git a/test/network/4bridges_arp.exp b/test/network/4bridges_arp.exp
new file mode 100755
index 000000000..6a3e6db2a
--- /dev/null
+++ b/test/network/4bridges_arp.exp
@@ -0,0 +1,170 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check eth0
8send -- "firejail --net=br0 --net=br1 --net=br2 --net=br3\r"
9expect {
10 timeout {puts "TESTING ERROR 0.0\n";exit}
11 "eth0"
12}
13expect {
14 timeout {puts "TESTING ERROR 0.1\n";exit}
15 "10.10.20"
16}
17expect {
18 timeout {puts "TESTING ERROR 0.2\n";exit}
19 "255.255.255.248"
20}
21expect {
22 timeout {puts "TESTING ERROR 0.3\n";exit}
23 "UP"
24}
25expect {
26 timeout {puts "TESTING ERROR 0.4\n";exit}
27 "Child process initialized"
28}
29sleep 2
30send -- "exit\r"
31sleep 2
32
33# check eth1
34send -- "firejail --net=br0 --net=br1 --net=br2 --net=br3\r"
35expect {
36 timeout {puts "TESTING ERROR 1.0\n";exit}
37 "eth1"
38}
39expect {
40 timeout {puts "TESTING ERROR 1.1\n";exit}
41 "10.10.30"
42}
43expect {
44 timeout {puts "TESTING ERROR 1.2\n";exit}
45 "255.255.255.0"
46}
47expect {
48 timeout {puts "TESTING ERROR 1.3\n";exit}
49 "UP"
50}
51expect {
52 timeout {puts "TESTING ERROR 1.4\n";exit}
53 "Child process initialized"
54}
55sleep 2
56send -- "exit\r"
57sleep 2
58
59
60# check eth2
61send -- "firejail --net=br0 --net=br1 --net=br2 --net=br3\r"
62expect {
63 timeout {puts "TESTING ERROR 2.0\n";exit}
64 "eth2"
65}
66expect {
67 timeout {puts "TESTING ERROR 2.1\n";exit}
68 "10.10.40"
69}
70expect {
71 timeout {puts "TESTING ERROR 2.2\n";exit}
72 "255.255.255.0"
73}
74expect {
75 timeout {puts "TESTING ERROR 2.3\n";exit}
76 "UP"
77}
78expect {
79 timeout {puts "TESTING ERROR 2.4\n";exit}
80 "Child process initialized"
81}
82sleep 2
83send -- "exit\r"
84sleep 2
85
86
87
88# check eth3
89send -- "firejail --net=br0 --net=br1 --net=br2 --net=br3\r"
90expect {
91 timeout {puts "TESTING ERROR 3.0\n";exit}
92 "eth3"
93}
94expect {
95 timeout {puts "TESTING ERROR 3.1\n";exit}
96 "10.10.50"
97}
98expect {
99 timeout {puts "TESTING ERROR 3.2\n";exit}
100 "255.255.255.0"
101}
102expect {
103 timeout {puts "TESTING ERROR 3.3\n";exit}
104 "UP"
105}
106expect {
107 timeout {puts "TESTING ERROR 4\n";exit}
108 "Child process initialized"
109}
110sleep 2
111send -- "exit\r"
112sleep 2
113
114
115
116
117# check loopback
118send -- "firejail --net=br0 --net=br1 --net=br2 --net=br3 --protocol=unix,inet,netlink\r"
119expect {
120 timeout {puts "TESTING ERROR 5\n";exit}
121 "lo"
122}
123expect {
124 timeout {puts "TESTING ERROR 6\n";exit}
125 "127.0.0.1"
126}
127expect {
128 timeout {puts "TESTING ERROR 7\n";exit}
129 "255.0.0.0"
130}
131expect {
132 timeout {puts "TESTING ERROR 8\n";exit}
133 "UP"
134}
135expect {
136 timeout {puts "TESTING ERROR 9\n";exit}
137 "Child process initialized"
138}
139sleep 1
140
141# check default gateway
142send -- "ip route show\r"
143expect {
144 timeout {puts "TESTING ERROR 10.1\n";exit}
145 "default via 10.10.20.1 dev eth0"
146}
147send -- "ip route show\r"
148expect {
149 timeout {puts "TESTING ERROR 10.2\n";exit}
150 "10.10.20.0/29 dev eth0 proto kernel scope link"
151}
152send -- "ip route show\r"
153expect {
154 timeout {puts "TESTING ERROR 10.2\n";exit}
155 "10.10.30.0/24 dev eth1 proto kernel scope link"
156}
157send -- "ip route show\r"
158expect {
159 timeout {puts "TESTING ERROR 10.2\n";exit}
160 "10.10.40.0/24 dev eth2 proto kernel scope link"
161}
162send -- "ip route show\r"
163expect {
164 timeout {puts "TESTING ERROR 10.2\n";exit}
165 "10.10.50.0/24 dev eth3 proto kernel scope link"
166}
167sleep 1
168
169puts "\nall done\n"
170
diff --git a/test/network/4bridges_ip.exp b/test/network/4bridges_ip.exp
new file mode 100755
index 000000000..8068aeebb
--- /dev/null
+++ b/test/network/4bridges_ip.exp
@@ -0,0 +1,174 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check eth0
8send -- "firejail --net=br0 --net=br1 --ip=10.10.30.50 --net=br2 --ip=10.10.40.100 --net=br3\r"
9expect {
10 timeout {puts "TESTING ERROR 0.0\n";exit}
11 "eth0"
12}
13expect {
14 timeout {puts "TESTING ERROR 0.1\n";exit}
15 "10.10.20"
16}
17expect {
18 timeout {puts "TESTING ERROR 0.2\n";exit}
19 "255.255.255.248"
20}
21expect {
22 timeout {puts "TESTING ERROR 0.3\n";exit}
23 "UP"
24}
25expect {
26 timeout {puts "TESTING ERROR 0.4\n";exit}
27 "Child process initialized"
28}
29sleep 2
30send -- "exit\r"
31sleep 2
32
33# check eth1
34send -- "firejail --net=br0 --net=br1 --ip=10.10.30.50 --net=br2 --ip=10.10.40.100 --net=br3\r"
35expect {
36 timeout {puts "TESTING ERROR 1.0\n";exit}
37 "eth1"
38}
39expect {
40 timeout {puts "TESTING ERROR 1.1\n";exit}
41 "10.10.30.50"
42}
43expect {
44 timeout {puts "TESTING ERROR 1.2\n";exit}
45 "255.255.255.0"
46}
47expect {
48 timeout {puts "TESTING ERROR 1.3\n";exit}
49 "UP"
50}
51expect {
52 timeout {puts "TESTING ERROR 1.4\n";exit}
53 "Child process initialized"
54}
55sleep 2
56send -- "exit\r"
57sleep 2
58
59
60# check eth2
61send -- "firejail --net=br0 --net=br1 --ip=10.10.30.50 --net=br2 --ip=10.10.40.100 --net=br3\r"
62expect {
63 timeout {puts "TESTING ERROR 2.0\n";exit}
64 "eth2"
65}
66expect {
67 timeout {puts "TESTING ERROR 2.1\n";exit}
68 "10.10.40.100"
69}
70expect {
71 timeout {puts "TESTING ERROR 2.2\n";exit}
72 "255.255.255.0"
73}
74expect {
75 timeout {puts "TESTING ERROR 2.3\n";exit}
76 "UP"
77}
78expect {
79 timeout {puts "TESTING ERROR 2.4\n";exit}
80 "Child process initialized"
81}
82sleep 2
83send -- "exit\r"
84sleep 2
85
86
87
88# check eth3
89send -- "firejail --net=br0 --net=br1 --ip=10.10.30.50 --net=br2 --ip=10.10.40.100 --net=br3\r"
90expect {
91 timeout {puts "TESTING ERROR 3.0\n";exit}
92 "eth3"
93}
94expect {
95 timeout {puts "TESTING ERROR 3.1\n";exit}
96 "10.10.50"
97}
98expect {
99 timeout {puts "TESTING ERROR 3.2\n";exit}
100 "255.255.255.0"
101}
102expect {
103 timeout {puts "TESTING ERROR 3.3\n";exit}
104 "UP"
105}
106expect {
107 timeout {puts "TESTING ERROR 4\n";exit}
108 "Child process initialized"
109}
110sleep 2
111send -- "exit\r"
112sleep 2
113
114
115
116
117# check loopback
118send -- "firejail --net=br0 --net=br1 --ip=10.10.30.50 --net=br2 --ip=10.10.40.100 --net=br3 --protocol=unix,inet,netlink\r"
119expect {
120 timeout {puts "TESTING ERROR 5\n";exit}
121 "lo"
122}
123expect {
124 timeout {puts "TESTING ERROR 6\n";exit}
125 "127.0.0.1"
126}
127expect {
128 timeout {puts "TESTING ERROR 7\n";exit}
129 "255.0.0.0"
130}
131expect {
132 timeout {puts "TESTING ERROR 8\n";exit}
133 "UP"
134}
135expect {
136 timeout {puts "TESTING ERROR 9\n";exit}
137 "Child process initialized"
138}
139
140# check default gateway
141send -- "ip route show\r"
142expect {
143 timeout {puts "TESTING ERROR 10.1\n";exit}
144 "default via 10.10.20.1 dev eth0"
145}
146
147send -- "ip route show\r"
148expect {
149 timeout {puts "TESTING ERROR 10.2\n";exit}
150 "10.10.20.0/29 dev eth0 proto kernel scope link"
151}
152
153send -- "ip route show\r"
154expect {
155 timeout {puts "TESTING ERROR 10.3\n";exit}
156 "10.10.30.0/24 dev eth1 proto kernel scope link src 10.10.30.50"
157}
158
159send -- "ip route show\r"
160expect {
161 timeout {puts "TESTING ERROR 10.4\n";exit}
162 "10.10.40.0/24 dev eth2 proto kernel scope link src 10.10.40.100"
163}
164
165send -- "ip route show\r"
166expect {
167 timeout {puts "TESTING ERROR 10.5\n";exit}
168 "10.10.50.0/24 dev eth3 proto kernel scope link"
169}
170
171sleep 1
172
173puts "\nall done\n"
174
diff --git a/test/network/bandwidth.exp b/test/network/bandwidth.exp
new file mode 100755
index 000000000..33b351296
--- /dev/null
+++ b/test/network/bandwidth.exp
@@ -0,0 +1,62 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "firejail --name=test --net=br0\r"
8expect {
9 timeout {puts "TESTING ERROR 0\n";exit}
10 "Child process initialized"
11}
12sleep 2
13
14spawn $env(SHELL)
15send -- "firejail --bandwidth=test status\r"
16expect {
17 timeout {puts "TESTING ERROR 1\n";exit}
18 "qdisc noqueue 0: dev eth0"
19}
20sleep 1
21
22send -- "firejail --bandwidth=test set br0 50 10\r"
23expect {
24 timeout {puts "TESTING ERROR 2\n";exit}
25 "Configuring interface eth0"
26}
27expect {
28 timeout {puts "TESTING ERROR 3\n";exit}
29 "configuring tc ingress"
30}
31expect {
32 timeout {puts "TESTING ERROR 4\n";exit}
33 "configuring tc egress"
34}
35
36send -- "firejail --bandwidth=test status\r"
37expect {
38 timeout {puts "TESTING ERROR 5\n";exit}
39 "dev eth0"
40}
41expect {
42 timeout {puts "TESTING ERROR 6\n";exit}
43 "rate 80Kbit burst 10Kb"
44}
45sleep 1
46
47send -- "firejail --bandwidth=test clear br0\r"
48expect {
49 timeout {puts "TESTING ERROR 7\n";exit}
50 "Removing bandwith limits"
51}
52sleep 1
53
54send -- "firejail --bandwidth=test status; pwd\r"
55expect {
56 timeout {puts "TESTING ERROR 8\n";exit}
57 "rate 80Kbit burst 10Kb" {puts "TESTING ERROR 9\n";exit}
58 "home" {puts "ok\n"}
59}
60sleep 1
61
62puts "\nall done\n"
diff --git a/test/network/hostname.exp b/test/network/hostname.exp
new file mode 100755
index 000000000..4e5c7e073
--- /dev/null
+++ b/test/network/hostname.exp
@@ -0,0 +1,25 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "firejail --hostname=baluba --noprofile\r"
8expect {
9 timeout {puts "TESTING ERROR 1\n";exit}
10 "Child process initialized"
11}
12sleep 1
13
14send -- "ping -c 3 baluba;pwd\r"
15expect {
16 timeout {puts "TESTING ERROR 2\n";exit}
17 "3 packets transmitted, 3 received"
18}
19expect {
20 timeout {puts "TESTING ERROR 3\n";exit}
21 "home"
22}
23sleep 1
24
25puts "all done\n"
diff --git a/test/network/ip6.exp b/test/network/ip6.exp
new file mode 100755
index 000000000..fba47d095
--- /dev/null
+++ b/test/network/ip6.exp
@@ -0,0 +1,43 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "firejail --debug --noprofile --net=br0 --ip6=2001:0db8:0:f101::1/64 --netfilter6=ipv6.net\r"
8expect {
9 timeout {puts "TESTING ERROR 0\n";exit}
10 "Installing network filter"
11}
12expect {
13 timeout {puts "TESTING ERROR 1\n";exit}
14 "DROP"
15}
16expect {
17 timeout {puts "TESTING ERROR 2\n";exit}
18 "2001:db8:1f0a:3ec::2"
19}
20expect {
21 timeout {puts "TESTING ERROR 3\n";exit}
22 "Child process initialized"
23}
24sleep 2
25
26send -- "/sbin/ifconfig\r"
27expect {
28 timeout {puts "TESTING ERROR 4\n";exit}
29 "inet6"
30}
31expect {
32 timeout {puts "TESTING ERROR 5\n";exit}
33 "2001:db8:0:f101::1"
34}
35expect {
36 timeout {puts "TESTING ERROR 6\n";exit}
37 "Scope:Global" { puts "Debian\n"}
38 "scopeid 0x0<global>" { puts "Arch\n"}
39}
40
41
42puts "\nall done\n"
43
diff --git a/test/network/ipv6.net b/test/network/ipv6.net
new file mode 100644
index 000000000..cc8f22943
--- /dev/null
+++ b/test/network/ipv6.net
@@ -0,0 +1,8 @@
1# Generated by ip6tables-save v1.4.14 on Wed Jan 13 10:53:40 2016
2*filter
3:INPUT ACCEPT [0:0]
4:FORWARD ACCEPT [0:0]
5:OUTPUT ACCEPT [0:0]
6-A INPUT -s 2001:db8:1f0a:3ec::2/128 -j DROP
7COMMIT
8# Completed on Wed Jan 13 10:53:40 2016
diff --git a/test/network/net-profile.profile b/test/network/net-profile.profile
new file mode 100644
index 000000000..05052b6dc
--- /dev/null
+++ b/test/network/net-profile.profile
@@ -0,0 +1,10 @@
1net br0
2mac 00:11:22:33:44:55
3mtu 1000
4net br1
5ip 10.10.30.50
6net br2
7ip 10.10.40.100
8net br3
9defaultgw 10.10.20.2
10
diff --git a/test/network/net_arp.exp b/test/network/net_arp.exp
new file mode 100755
index 000000000..9e07744f3
--- /dev/null
+++ b/test/network/net_arp.exp
@@ -0,0 +1,71 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "firejail --net=br0 sleep 20 &\r"
8expect {
9 timeout {puts "TESTING ERROR 0\n";exit}
10 "Child process initialized"
11}
12send -- "firejail --net=br0 sleep 20 &\r"
13expect {
14 timeout {puts "TESTING ERROR 1\n";exit}
15 "Child process initialized"
16}
17send -- "firejail --net=br0 sleep 20 &\r"
18expect {
19 timeout {puts "TESTING ERROR 2\n";exit}
20 "Child process initialized"
21}
22send -- "firejail --net=br0 sleep 20 &\r"
23expect {
24 timeout {puts "TESTING ERROR 3\n";exit}
25 "Child process initialized"
26}
27send -- "firejail --net=br0 sleep 20 &\r"
28expect {
29 timeout {puts "TESTING ERROR 4\n";exit}
30 "Child process initialized"
31}
32
33# will fail
34send -- "firejail --net=br0 sleep 20 &\r"
35expect {
36 timeout {puts "TESTING ERROR 5n";exit}
37 "cannot assign an IP address"
38}
39
40send -- "firejail --net=br0 sleep 20 &\r"
41expect {
42 timeout {puts "TESTING ERROR 6\n";exit}
43 "cannot assign an IP address"
44}
45
46# check firejail --list
47send -- "firejail --list\r"
48expect {
49 timeout {puts "TESTING ERROR 7.1\n";exit}
50 "sleep 20"
51}
52expect {
53 timeout {puts "TESTING ERROR 7.2\n";exit}
54 "sleep 20"
55}
56expect {
57 timeout {puts "TESTING ERROR 7.3\n";exit}
58 "sleep 20"
59}
60expect {
61 timeout {puts "TESTING ERROR 7.4\n";exit}
62 "sleep 20"
63}
64expect {
65 timeout {puts "TESTING ERROR 7.5\n";exit}
66 "sleep 20"
67}
68
69# wait for snadboxes to be shutdown
70sleep 30
71puts "\n"
diff --git a/test/network/net_badip.exp b/test/network/net_badip.exp
new file mode 100755
index 000000000..71b69e104
--- /dev/null
+++ b/test/network/net_badip.exp
@@ -0,0 +1,16 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check eth0
8send -- "firejail --net=br0 --net=br1 --ip=10.100.10.47\r"
9expect {
10 timeout {puts "TESTING ERROR 0.0\n";exit}
11 "the IP address is not"
12}
13sleep 1
14
15puts "\n"
16
diff --git a/test/network/net_defaultgw.exp b/test/network/net_defaultgw.exp
new file mode 100755
index 000000000..840f2ccac
--- /dev/null
+++ b/test/network/net_defaultgw.exp
@@ -0,0 +1,46 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --net=br0 --ip=10.10.20.5 --defaultgw=10.10.20.2 --protocol=unix,inet,netlink\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "eth0"
12}
13expect {
14 timeout {puts "TESTING ERROR 1\n";exit}
15 "10.10.20.5"
16}
17expect {
18 timeout {puts "TESTING ERROR 2\n";exit}
19 "255.255.255.248"
20}
21expect {
22 timeout {puts "TESTING ERROR 3\n";exit}
23 "UP"
24}
25expect {
26 timeout {puts "TESTING ERROR 4\n";exit}
27 "Child process initialized"
28}
29sleep 1
30
31# check default gateway
32send -- "ip route show\r"
33expect {
34 timeout {puts "TESTING ERROR 10.1\n";exit}
35 "default via 10.10.20.2 dev eth0"
36}
37
38send -- "ip route show\r"
39expect {
40 timeout {puts "TESTING ERROR 10.2\n";exit}
41 "10.10.20.0/29 dev eth0 proto kernel scope link"
42}
43sleep 1
44
45puts "\nall done\n"
46
diff --git a/test/network/net_defaultgw2.exp b/test/network/net_defaultgw2.exp
new file mode 100755
index 000000000..db14e17cb
--- /dev/null
+++ b/test/network/net_defaultgw2.exp
@@ -0,0 +1,40 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --net=br0 --net=br1 --defaultgw=10.10.30.89 --protocol=unix,inet,netlink\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "eth1"
12}
13expect {
14 timeout {puts "TESTING ERROR 4\n";exit}
15 "Child process initialized"
16}
17sleep 1
18
19# check default gateway
20send -- "ip route show\r"
21expect {
22 timeout {puts "TESTING ERROR 10.1\n";exit}
23 "default via 10.10.30.89 dev eth1"
24}
25
26send -- "ip route show\r"
27expect {
28 timeout {puts "TESTING ERROR 10.2\n";exit}
29 "10.10.20.0/29 dev eth0 proto kernel scope link"
30}
31
32send -- "ip route show\r"
33expect {
34 timeout {puts "TESTING ERROR 10.3\n";exit}
35 "10.10.30.0/24 dev eth1 proto kernel scope link"
36}
37sleep 1
38
39puts "\nall done\n"
40
diff --git a/test/network/net_defaultgw3.exp b/test/network/net_defaultgw3.exp
new file mode 100755
index 000000000..64da9dfca
--- /dev/null
+++ b/test/network/net_defaultgw3.exp
@@ -0,0 +1,17 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --net=br0 --net=br1 --defaultgw=10.10.95.89\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "default gateway 10.10.95.89 is not in the range of any network"
12}
13
14sleep 1
15
16puts "\n"
17
diff --git a/test/network/net_interface.exp b/test/network/net_interface.exp
new file mode 100755
index 000000000..4b55187ff
--- /dev/null
+++ b/test/network/net_interface.exp
@@ -0,0 +1,88 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "ip link add link eth0 name eth0.100 type vlan id 100\r"
8sleep 1
9send -- "ip link add link eth0 name eth0.101 type vlan id 101\r"
10sleep 1
11send -- "ip link add link eth0 name eth0.102 type vlan id 102\r"
12sleep 1
13send -- "ip link add link eth0 name eth0.103 type vlan id 103\r"
14sleep 1
15send -- "ip link add link eth0 name eth0.104 type vlan id 104\r"
16sleep 1
17puts "\n"
18
19send -- "/sbin/ifconfig eth0.100 10.200.0.1/24\r"
20sleep 1
21send -- "/sbin/ifconfig eth0.101 10.200.1.1/24\r"
22sleep 1
23send -- "/sbin/ifconfig eth0.102 10.200.2.1/24\r"
24sleep 1
25send -- "/sbin/ifconfig eth0.103 10.200.3.1/24\r"
26sleep 1
27send -- "/sbin/ifconfig eth0.104 10.200.4.1/24\r"
28sleep 1
29puts "\n"
30
31
32
33send -- "firejail --noprofile --interface=eth0.100 --interface=eth0.101 --interface=eth0.102 --interface=eth0.103 --interface=eth0.104\r"
34expect {
35 timeout {puts "TESTING ERROR 0\n";exit}
36 "maximum 4 interfaces are allowed"
37}
38sleep 1
39
40send -- "firejail --noprofile --interface=eth0.100 --interface=eth0.101 --interface=eth0.102 --interface=eth0.103\r"
41expect {
42 timeout {puts "TESTING ERROR 1\n";exit}
43 "eth0.100"
44}
45expect {
46 timeout {puts "TESTING ERROR 1.1\n";exit}
47 "UP"
48}
49expect {
50 timeout {puts "TESTING ERROR 2\n";exit}
51 "eth0.101"
52}
53expect {
54 timeout {puts "TESTING ERROR 2.2\n";exit}
55 "UP"
56}
57expect {
58 timeout {puts "TESTING ERROR 3\n";exit}
59 "eth0.102"
60}
61expect {
62 timeout {puts "TESTING ERROR 3.1\n";exit}
63 "UP"
64}
65expect {
66 timeout {puts "TESTING ERROR 4\n";exit}
67 "eth0.103"
68}
69expect {
70 timeout {puts "TESTING ERROR 4.1\n";exit}
71 "UP"
72}
73sleep 1
74send -- "exit\r"
75sleep 1
76
77send -- "firejail --noprofile --interface=eth0.104\r"
78expect {
79 timeout {puts "TESTING ERROR 5\n";exit}
80 "eth0.104"
81}
82expect {
83 timeout {puts "TESTING ERROR 5.1\n";exit}
84 "UP"
85}
86
87puts "all done\n"
88
diff --git a/test/network/net_ip.exp b/test/network/net_ip.exp
new file mode 100755
index 000000000..f5d487ecc
--- /dev/null
+++ b/test/network/net_ip.exp
@@ -0,0 +1,72 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --net=br0 --ip=10.10.20.5\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "eth0"
12}
13expect {
14 timeout {puts "TESTING ERROR 1\n";exit}
15 "10.10.20.5"
16}
17expect {
18 timeout {puts "TESTING ERROR 2\n";exit}
19 "255.255.255.248"
20}
21expect {
22 timeout {puts "TESTING ERROR 3\n";exit}
23 "UP"
24}
25expect {
26 timeout {puts "TESTING ERROR 4\n";exit}
27 "Child process initialized"
28}
29sleep 2
30send -- "exit\r"
31sleep 2
32
33# check loopback
34send -- "firejail --net=br0 --ip=10.10.20.5 --protocol=unix,inet,netlink\r"
35expect {
36 timeout {puts "TESTING ERROR 5\n";exit}
37 "lo"
38}
39expect {
40 timeout {puts "TESTING ERROR 6\n";exit}
41 "127.0.0.1"
42}
43expect {
44 timeout {puts "TESTING ERROR 7\n";exit}
45 "255.0.0.0"
46}
47expect {
48 timeout {puts "TESTING ERROR 8\n";exit}
49 "UP"
50}
51expect {
52 timeout {puts "TESTING ERROR 9\n";exit}
53 "Child process initialized"
54}
55sleep 1
56
57# check default gateway
58send -- "ip route show\r"
59expect {
60 timeout {puts "TESTING ERROR 10.1\n";exit}
61 "default via 10.10.20.1 dev eth0"
62}
63
64send -- "ip route show\r"
65expect {
66 timeout {puts "TESTING ERROR 10\n";exit}
67 "10.10.20.0/29 dev eth0 proto kernel scope link"
68}
69sleep 1
70
71puts "\n"
72
diff --git a/test/network/net_local.exp b/test/network/net_local.exp
new file mode 100755
index 000000000..642213658
--- /dev/null
+++ b/test/network/net_local.exp
@@ -0,0 +1,45 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --noprofile --debug\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "Using the local network stack"
12}
13expect {
14 timeout {puts "TESTING ERROR 4\n";exit}
15 "Child process initialized"
16}
17sleep 2
18send -- "exit\r"
19sleep 2
20
21# check loopback
22send -- "firejail --noprofile\r"
23expect {
24 timeout {puts "TESTING ERROR 9\n";exit}
25 "Child process initialized"
26}
27sleep 1
28
29
30send -- "/sbin/ifconfig\r"
31expect {
32 timeout {puts "TESTING ERROR 5\n";exit}
33 "lo"
34}
35expect {
36 timeout {puts "TESTING ERROR 6\n";exit}
37 "127.0.0.1"
38}
39expect {
40 timeout {puts "TESTING ERROR 7\n";exit}
41 "255.0.0.0"
42}
43
44puts "all done\n"
45
diff --git a/test/network/net_mac.exp b/test/network/net_mac.exp
new file mode 100755
index 000000000..076634730
--- /dev/null
+++ b/test/network/net_mac.exp
@@ -0,0 +1,36 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --net=br0 --ip=10.10.20.5 --mac=00:11:22:33:44:55\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "eth0"
12}
13expect {
14 timeout {puts "TESTING ERROR 0.1\n";exit}
15 "00:11:22:33:44:55"
16}
17expect {
18 timeout {puts "TESTING ERROR 1\n";exit}
19 "10.10.20.5"
20}
21expect {
22 timeout {puts "TESTING ERROR 2\n";exit}
23 "255.255.255.248"
24}
25expect {
26 timeout {puts "TESTING ERROR 3\n";exit}
27 "UP"
28}
29expect {
30 timeout {puts "TESTING ERROR 4\n";exit}
31 "Child process initialized"
32}
33sleep 1
34
35puts "\nall done\n"
36
diff --git a/test/network/net_macvlan.exp b/test/network/net_macvlan.exp
new file mode 100755
index 000000000..20d022de9
--- /dev/null
+++ b/test/network/net_macvlan.exp
@@ -0,0 +1,88 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check the existing address
8spawn $env(SHELL)
9send -- "firejail --net=eth0 --ip=192.168.1.60\r"
10expect {
11 timeout {puts "TESTING ERROR 1.1\n";puts "Please open a sandbox on 192.168.1.60\n";exit}
12 "the address 192.168.1.60 is already in use"
13}
14
15
16
17# grab 30 ip addresses
18set MAXi 229
19set i 200
20while { $i <= $MAXi } {
21 spawn $env(SHELL)
22 send -- "firejail --net=eth0 --ip=192.168.1.$i\r"
23 expect {
24 timeout {puts "TESTING ERROR 0\n";exit}
25 "Child process initialized"
26 }
27 incr i
28 after 100
29}
30
31
32# check an existing address
33spawn $env(SHELL)
34send -- "firejail --net=eth0 --ip=192.168.1.200\r"
35expect {
36 timeout {puts "TESTING ERROR 1\n";exit}
37 "the address 192.168.1.200 is already in use"
38}
39
40
41set MAXi 254
42set i 2
43while { $i <= $MAXi } {
44 spawn $env(SHELL)
45 send -- "firejail --net=eth0\r"
46 expect {
47 timeout {puts "TESTING ERROR 2.1\n";exit}
48 "192.168.1.60" {puts "TESTING ERROR 2.2\n";exit}
49 "192.168.1.200" {puts "TESTING ERROR 3\n";exit}
50 "192.168.1.201" {puts "TESTING ERROR 3\n";exit}
51 "192.168.1.202" {puts "TESTING ERROR 3\n";exit}
52 "192.168.1.203" {puts "TESTING ERROR 3\n";exit}
53 "192.168.1.204" {puts "TESTING ERROR 3\n";exit}
54 "192.168.1.205" {puts "TESTING ERROR 3\n";exit}
55 "192.168.1.206" {puts "TESTING ERROR 3\n";exit}
56 "192.168.1.207" {puts "TESTING ERROR 3\n";exit}
57 "192.168.1.208" {puts "TESTING ERROR 3\n";exit}
58 "192.168.1.209" {puts "TESTING ERROR 3\n";exit}
59 "192.168.1.210" {puts "TESTING ERROR 3\n";exit}
60 "192.168.1.211" {puts "TESTING ERROR 3\n";exit}
61 "192.168.1.212" {puts "TESTING ERROR 3\n";exit}
62 "192.168.1.213" {puts "TESTING ERROR 3\n";exit}
63 "192.168.1.214" {puts "TESTING ERROR 3\n";exit}
64 "192.168.1.215" {puts "TESTING ERROR 3\n";exit}
65 "192.168.1.216" {puts "TESTING ERROR 3\n";exit}
66 "192.168.1.217" {puts "TESTING ERROR 3\n";exit}
67 "192.168.1.218" {puts "TESTING ERROR 3\n";exit}
68 "192.168.1.219" {puts "TESTING ERROR 3\n";exit}
69 "192.168.1.220" {puts "TESTING ERROR 3\n";exit}
70 "192.168.1.221" {puts "TESTING ERROR 3\n";exit}
71 "192.168.1.222" {puts "TESTING ERROR 3\n";exit}
72 "192.168.1.223" {puts "TESTING ERROR 3\n";exit}
73 "192.168.1.224" {puts "TESTING ERROR 3\n";exit}
74 "192.168.1.225" {puts "TESTING ERROR 3\n";exit}
75 "192.168.1.226" {puts "TESTING ERROR 3\n";exit}
76 "192.168.1.227" {puts "TESTING ERROR 3\n";exit}
77 "192.168.1.228" {puts "TESTING ERROR 3\n";exit}
78 "192.168.1.229" {puts "TESTING ERROR 3\n";exit}
79 "Child process initialized"
80 }
81 puts "************ $i ******************\n"
82 incr i
83 after 100
84# sleep 1
85}
86
87puts "\n"
88
diff --git a/test/network/net_mtu.exp b/test/network/net_mtu.exp
new file mode 100755
index 000000000..7943b2866
--- /dev/null
+++ b/test/network/net_mtu.exp
@@ -0,0 +1,30 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --net=br0 --mtu=1000 --noprofile\r"
9expect {
10 timeout {puts "TESTING ERROR 1\n";exit}
11 "Child process initialized"
12}
13sleep 1
14
15send -- "ip link show\r"
16expect {
17 timeout {puts "TESTING ERROR 2\n";exit}
18 "eth0"
19}
20expect {
21 timeout {puts "TESTING ERROR 3\n";exit}
22 "mtu 1000"
23}
24expect {
25 timeout {puts "TESTING ERROR 4\n";exit}
26 "state UP"
27}
28
29puts "\nall done\n"
30
diff --git a/test/network/net_netfilter.exp b/test/network/net_netfilter.exp
new file mode 100755
index 000000000..989fcc407
--- /dev/null
+++ b/test/network/net_netfilter.exp
@@ -0,0 +1,88 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check default netfilter on br0
8send -- "firejail --debug --noprofile --net=br0 --ip=10.10.20.5 --netfilter\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "Installing network filter"
12}
13expect {
14 timeout {puts "TESTING ERROR 1\n";exit}
15 "Chain INPUT (policy DROP"
16}
17expect {
18 timeout {puts "TESTING ERROR 2\n";exit}
19 "ACCEPT all -- any any anywhere"
20}
21expect {
22 timeout {puts "TESTING ERROR 3\n";exit}
23 "ACCEPT icmp -- any any anywhere"
24}
25expect {
26 timeout {puts "TESTING ERROR 4\n";exit}
27 "Child process initialized"
28}
29sleep 2
30send -- "exit\r"
31sleep 1
32
33# check default netfilter no new network
34send -- "firejail --debug --noprofile --netfilter\r"
35expect {
36 timeout {puts "TESTING ERROR 5\n";exit}
37 "Installing network filter" {puts "TESTING ERROR 5.1\n";exit}
38 "Chain INPUT (policy DROP" {puts "TESTING ERROR 5.1\n";exit}
39 "ACCEPT all -- any any anywhere" {puts "TESTING ERROR 5.1\n";exit}
40 "ACCEPT icmp -- any any anywhere" {puts "TESTING ERROR 5.1\n";exit}
41 "Child process initialized"
42}
43sleep 2
44send -- "exit\r"
45sleep 1
46
47# check file filter netfilter on br0
48send -- "firejail --debug --noprofile --net=br0 --ip=10.10.20.5 --netfilter=netfilter.filter\r"
49expect {
50 timeout {puts "TESTING ERROR 6\n";exit}
51 "Installing network filter"
52}
53expect {
54 timeout {puts "TESTING ERROR 6.1\n";exit}
55 "Child process initialized"
56}
57sleep 2
58send -- "ping -c 1 -w 3 10.10.20.1\r"
59expect {
60 timeout {puts "TESTING ERROR 6.2\n";exit}
61 "0 received, 100% packet loss"
62}
63
64send -- "exit\r"
65sleep 1
66
67# check profile netfilter on br0
68send -- "firejail --debug --net=br0 --ip=10.10.20.5 --profile=netfilter.profile\r"
69expect {
70 timeout {puts "TESTING ERROR 7\n";exit}
71 "Installing network filter"
72}
73expect {
74 timeout {puts "TESTING ERROR 7.1\n";exit}
75 "Child process initialized"
76}
77sleep 2
78send -- "ping -c 1 -w 3 10.10.20.1\r"
79expect {
80 timeout {puts "TESTING ERROR 7.2\n";exit}
81 "0 received, 100% packet loss"
82}
83
84send -- "exit\r"
85after 100
86
87puts "all done\n"
88
diff --git a/test/network/net_noip.exp b/test/network/net_noip.exp
new file mode 100755
index 000000000..8d28adb39
--- /dev/null
+++ b/test/network/net_noip.exp
@@ -0,0 +1,41 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --noprofile --net=br0 --ip=none\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "eth0" {puts "TESTING ERROR 1\n";exit}
12 "Child process initialized"
13}
14sleep 1
15send -- "bash\r"
16sleep 1
17
18# no default gateway configured
19send -- "netstat -rn;pwd\r"
20expect {
21 timeout {puts "TESTING ERROR 2\n";exit}
22 "0.0.0.0" {puts "TESTING ERROR 3\n";exit}
23 "eth0" {puts "TESTING ERROR 4\n";exit}
24 "home"
25}
26sleep 1
27
28# eth0 configured
29send -- "/sbin/ifconfig;pwd\r"
30expect {
31 timeout {puts "TESTING ERROR 5\n";exit}
32 "eth0"
33}
34expect {
35 timeout {puts "TESTING ERROR 6\n";exit}
36 "home"
37}
38after 100
39
40puts "all done\n"
41
diff --git a/test/network/net_noip2.exp b/test/network/net_noip2.exp
new file mode 100755
index 000000000..58f90422b
--- /dev/null
+++ b/test/network/net_noip2.exp
@@ -0,0 +1,41 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check ip address
8send -- "firejail --noprofile --net=br1 --ip=none --defaultgw=10.10.30.78\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "eth0" {puts "TESTING ERROR 1\n";exit}
12 "Child process initialized"
13}
14sleep 1
15send -- "bash\r"
16sleep 1
17
18# no default gateway configured
19send -- "netstat -rn;pwd\r"
20expect {
21 timeout {puts "TESTING ERROR 2\n";exit}
22 "0.0.0.0" {puts "TESTING ERROR 3\n";exit}
23 "eth0" {puts "TESTING ERROR 4\n";exit}
24 "home"
25}
26sleep 1
27
28# eth0 configured
29send -- "/sbin/ifconfig;pwd\r"
30expect {
31 timeout {puts "TESTING ERROR 5\n";exit}
32 "eth0"
33}
34expect {
35 timeout {puts "TESTING ERROR 6\n";exit}
36 "home"
37}
38after 100
39
40puts "all done\n"
41
diff --git a/test/network/net_none.exp b/test/network/net_none.exp
new file mode 100755
index 000000000..54b6cb946
--- /dev/null
+++ b/test/network/net_none.exp
@@ -0,0 +1,68 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# options
8send -- "firejail --net=none\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "eth0" {puts "TESTING ERROR 0.1\n";exit}
12 "Child process initialized"
13}
14sleep 1
15
16# test default gw
17send -- "bash\r"
18sleep 1
19send -- "netstat -rn; pwd\r"
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "0.0.0.0" {puts "TESTING ERROR 1.1\n";exit}
23 "home"
24}
25sleep 1
26
27# check again devices
28send -- "cat /proc/1/net/dev;pwd\r"
29expect {
30 timeout {puts "TESTING ERROR 2\n";exit}
31 "eth0" {puts "TESTING ERROR 2.1\n";exit}
32 "home"
33}
34send -- "exit\r"
35sleep 1
36send -- "exit\r"
37sleep 1
38
39# profile
40send -- "firejail --profile=net_none.profile\r"
41expect {
42 timeout {puts "TESTING ERROR 3\n";exit}
43 "eth0" {puts "TESTING ERROR 3.1\n";exit}
44 "Child process initialized"
45}
46sleep 1
47
48# test default gw
49send -- "bash\r"
50sleep 1
51send -- "netstat -rn; pwd\r"
52expect {
53 timeout {puts "TESTING ERROR 4\n";exit}
54 "0.0.0.0" {puts "TESTING ERROR 4.1\n";exit}
55 "home"
56}
57sleep 1
58
59# check again devices
60send -- "cat /proc/1/net/dev;pwd\r"
61expect {
62 timeout {puts "TESTING ERROR 5\n";exit}
63 "eth0" {puts "TESTING ERROR 5.1\n";exit}
64 "home"
65}
66sleep 1
67
68puts "\n"
diff --git a/test/network/net_none.profile b/test/network/net_none.profile
new file mode 100644
index 000000000..079c08ea8
--- /dev/null
+++ b/test/network/net_none.profile
@@ -0,0 +1 @@
net none
diff --git a/test/network/net_profile.exp b/test/network/net_profile.exp
new file mode 100755
index 000000000..37043c906
--- /dev/null
+++ b/test/network/net_profile.exp
@@ -0,0 +1,73 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# check eth0
8send -- "firejail --profile=net-profile.profile\r"
9expect {
10 timeout {puts "TESTING ERROR 0.0\n";exit}
11 "eth0"
12}
13expect {
14 timeout {puts "TESTING ERROR 0.1\n";exit}
15 "00:11:22:33:44:55"
16}
17expect {
18 timeout {puts "TESTING ERROR 0.1\n";exit}
19 "10.10.20"
20}
21expect {
22 timeout {puts "TESTING ERROR 0.2\n";exit}
23 "255.255.255.248"
24}
25expect {
26 timeout {puts "TESTING ERROR 0.3\n";exit}
27 "UP"
28}
29expect {
30 timeout {puts "TESTING ERROR 0.4\n";exit}
31 "Child process initialized"
32}
33sleep 2
34
35send -- "ip route show\r"
36expect {
37 timeout {puts "TESTING ERROR 1\n";exit}
38 "10.10.30.0/24 dev eth1 proto kernel scope link src 10.10.30.50"
39}
40
41send -- "ip route show\r"
42expect {
43 timeout {puts "TESTING ERROR 2\n";exit}
44 "10.10.40.0/24 dev eth2 proto kernel scope link src 10.10.40.100"
45}
46
47
48# check default gw
49send -- "ip route show\r"
50expect {
51 timeout {puts "TESTING ERROR 3\n";exit}
52 "default via 10.10.20.2 dev eth0"
53}
54
55# check mtu
56send -- "ip link show\r"
57expect {
58 timeout {puts "TESTING ERROR 4\n";exit}
59 "eth0"
60}
61expect {
62 timeout {puts "TESTING ERROR 5\n";exit}
63 "mtu 1000"
64}
65expect {
66 timeout {puts "TESTING ERROR 6\n";exit}
67 "state UP"
68}
69
70sleep 1
71
72puts "\nall done\n"
73
diff --git a/test/network/netfilter.filter b/test/network/netfilter.filter
new file mode 100644
index 000000000..3e232065c
--- /dev/null
+++ b/test/network/netfilter.filter
@@ -0,0 +1,6 @@
1*filter
2:INPUT DROP [0:0]
3:FORWARD DROP [0:0]
4:OUTPUT ACCEPT [0:0]
5-A INPUT -i lo -j ACCEPT
6COMMIT
diff --git a/test/network/netfilter.profile b/test/network/netfilter.profile
new file mode 100644
index 000000000..824c6cd0f
--- /dev/null
+++ b/test/network/netfilter.profile
@@ -0,0 +1 @@
netfilter netfilter.filter