aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-09-15 09:59:11 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-09-15 09:59:11 -0400
commitfc116c063938d5e141d5fbc38e8013d9832ef315 (patch)
tree382b401cc0a9efeda1509a88bd430cd68b741346
parentfixed /etc/login.def reading on Mageia systems (diff)
downloadfirejail-fc116c063938d5e141d5fbc38e8013d9832ef315.tar.gz
firejail-fc116c063938d5e141d5fbc38e8013d9832ef315.tar.zst
firejail-fc116c063938d5e141d5fbc38e8013d9832ef315.zip
testing
-rw-r--r--Makefile.in3
-rwxr-xr-xtest/filters/filters.sh2
-rwxr-xr-xtest/filters/seccomp-su.exp2
-rwxr-xr-xtest/root/apache2.exp (renamed from test/servers3.exp)6
-rwxr-xr-xtest/root/configure27
-rwxr-xr-xtest/root/firemon-interface.exp (renamed from test/firemon-interface.exp)0
-rwxr-xr-xtest/root/isc-dhcp.exp (renamed from test/servers4.exp)0
-rwxr-xr-xtest/root/net_interface.exp (renamed from test/network/net_interface.exp)0
-rwxr-xr-xtest/root/nginx.exp (renamed from test/servers6.exp)6
-rwxr-xr-xtest/root/option_bind_directory.exp (renamed from test/option_bind_directory.exp)0
-rwxr-xr-xtest/root/option_bind_file.exp (renamed from test/option_bind_file.exp)0
-rwxr-xr-xtest/root/option_tmpfs.exp (renamed from test/option_tmpfs.exp)2
-rwxr-xr-xtest/root/profile_tmpfs.exp (renamed from test/profile_tmpfs.exp)2
-rwxr-xr-xtest/root/root.sh105
-rwxr-xr-xtest/root/seccomp-chmod.exp51
-rwxr-xr-xtest/root/seccomp-chown.exp49
-rwxr-xr-xtest/root/seccomp-umount.exp (renamed from test/filters/seccomp-umount.exp)6
-rwxr-xr-xtest/root/snmpd.exp (renamed from test/servers2.exp)0
-rwxr-xr-xtest/root/start.sh4
-rw-r--r--test/root/tmpfs.profile (renamed from test/tmpfs.profile)0
-rwxr-xr-xtest/root/unbound.exp (renamed from test/servers5.exp)0
-rwxr-xr-xtest/test-root.sh81
22 files changed, 243 insertions, 103 deletions
diff --git a/Makefile.in b/Makefile.in
index 803769f3f..95b07c170 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -161,6 +161,9 @@ install-snap: snap
161 161
162test-compile: dist 162test-compile: dist
163 cd test/compile; ./compile.sh $(NAME)-$(VERSION) 163 cd test/compile; ./compile.sh $(NAME)-$(VERSION)
164
165test-root:
166 cd test/root; su -c ./start.sh
164 167
165.PHONY: rpms 168.PHONY: rpms
166rpms: 169rpms:
diff --git a/test/filters/filters.sh b/test/filters/filters.sh
index 67b9f2c0d..5093c8614 100755
--- a/test/filters/filters.sh
+++ b/test/filters/filters.sh
@@ -45,7 +45,7 @@ echo "TESTING: seccomp chmod - seccomp lists (test/filters/seccomp-chmod.exp)"
45echo "TESTING: seccomp chmod profile - seccomp lists (test/filters/seccomp-chmod-profile.exp)" 45echo "TESTING: seccomp chmod profile - seccomp lists (test/filters/seccomp-chmod-profile.exp)"
46./seccomp-chmod-profile.exp 46./seccomp-chmod-profile.exp
47 47
48# todo: fix pwd and add seccomp-chown.exp and seccomp-umount.exp 48# todo: fix pwd and add seccomp-chown.exp
49 49
50echo "TESTING: seccomp empty (test/filters/seccomp-empty.exp)" 50echo "TESTING: seccomp empty (test/filters/seccomp-empty.exp)"
51./seccomp-empty.exp 51./seccomp-empty.exp
diff --git a/test/filters/seccomp-su.exp b/test/filters/seccomp-su.exp
index 7833c69b0..3feabc20f 100755
--- a/test/filters/seccomp-su.exp
+++ b/test/filters/seccomp-su.exp
@@ -30,7 +30,7 @@ expect {
30 30
31send -- "ping google.com\r" 31send -- "ping google.com\r"
32expect { 32expect {
33 timeout {puts "TESTING ERROR 2\n";exit} 33 timeout {puts "TESTING ERROR 3\n";exit}
34 "Operation not permitted" {puts "OK\n"} 34 "Operation not permitted" {puts "OK\n"}
35 "unknown host" {puts "OK\n"} 35 "unknown host" {puts "OK\n"}
36} 36}
diff --git a/test/servers3.exp b/test/root/apache2.exp
index eccdaa1d9..7f67f4706 100755
--- a/test/servers3.exp
+++ b/test/root/apache2.exp
@@ -4,12 +4,6 @@ set timeout 5
4spawn $env(SHELL) 4spawn $env(SHELL)
5match_max 100000 5match_max 100000
6 6
7send -- "sudo ls; sudo whoami; sudo pwd\r"
8expect {
9 timeout {puts "TESTING ERROR: you need to root run this test as root\n";exit}
10 "root"
11}
12
13send -- "pkill apache\r" 7send -- "pkill apache\r"
14sleep 2 8sleep 2
15 9
diff --git a/test/root/configure b/test/root/configure
new file mode 100755
index 000000000..35d938340
--- /dev/null
+++ b/test/root/configure
@@ -0,0 +1,27 @@
1#!/bin/bash
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6brctl addbr br0
7ifconfig br0 10.10.20.1/29 up
8# NAT masquerade
9iptables -t nat -A POSTROUTING -o eth0 -s 10.10.20.0/29 -j MASQUERADE
10# port forwarding
11# iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 10.10.20.2:80
12
13brctl addbr br1
14ifconfig br1 10.10.30.1/24 up
15brctl addbr br2
16ifconfig br2 10.10.40.1/24 up
17brctl addbr br3
18ifconfig br3 10.10.50.1/24 up
19brctl addbr br4
20ifconfig br4 10.10.60.1/24 up
21ip link add link eth0 name eth0.5 type vlan id 5
22/sbin/ifconfig eth0.5 10.10.205.10/24 up
23ip link add link eth0 name eth0.6 type vlan id 6
24/sbin/ifconfig eth0.6 10.10.206.10/24 up
25ip link add link eth0 name eth0.7 type vlan id 7
26/sbin/ifconfig eth0.7 10.10.207.10/24 up
27
diff --git a/test/firemon-interface.exp b/test/root/firemon-interface.exp
index 6a82ae41e..6a82ae41e 100755
--- a/test/firemon-interface.exp
+++ b/test/root/firemon-interface.exp
diff --git a/test/servers4.exp b/test/root/isc-dhcp.exp
index 86500707a..86500707a 100755
--- a/test/servers4.exp
+++ b/test/root/isc-dhcp.exp
diff --git a/test/network/net_interface.exp b/test/root/net_interface.exp
index 2f87024d8..2f87024d8 100755
--- a/test/network/net_interface.exp
+++ b/test/root/net_interface.exp
diff --git a/test/servers6.exp b/test/root/nginx.exp
index 9ef4ea514..0b62fada9 100755
--- a/test/servers6.exp
+++ b/test/root/nginx.exp
@@ -4,12 +4,6 @@ set timeout 5
4spawn $env(SHELL) 4spawn $env(SHELL)
5match_max 100000 5match_max 100000
6 6
7send -- "sudo ls; sudo whoami; sudo pwd\r"
8expect {
9 timeout {puts "TESTING ERROR: you need to root run this test as root\n";exit}
10 "root"
11}
12
13send -- "pkill nginx\r" 7send -- "pkill nginx\r"
14sleep 2 8sleep 2
15 9
diff --git a/test/option_bind_directory.exp b/test/root/option_bind_directory.exp
index 3233c68de..3233c68de 100755
--- a/test/option_bind_directory.exp
+++ b/test/root/option_bind_directory.exp
diff --git a/test/option_bind_file.exp b/test/root/option_bind_file.exp
index 8926e0391..8926e0391 100755
--- a/test/option_bind_file.exp
+++ b/test/root/option_bind_file.exp
diff --git a/test/option_tmpfs.exp b/test/root/option_tmpfs.exp
index 6522ef2d3..20e42a858 100755
--- a/test/option_tmpfs.exp
+++ b/test/root/option_tmpfs.exp
@@ -40,5 +40,5 @@ expect {
40after 100 40after 100
41 41
42 42
43puts "\nalldone\n" 43puts "\nall done\n"
44 44
diff --git a/test/profile_tmpfs.exp b/test/root/profile_tmpfs.exp
index a2faa32f7..da7c084a2 100755
--- a/test/profile_tmpfs.exp
+++ b/test/root/profile_tmpfs.exp
@@ -34,4 +34,4 @@ send -- "rm -fr /tmp/firejailtestdir\r"
34 34
35sleep 1 35sleep 1
36 36
37puts "\n" 37puts "\nall done\n"
diff --git a/test/root/root.sh b/test/root/root.sh
new file mode 100755
index 000000000..960071d45
--- /dev/null
+++ b/test/root/root.sh
@@ -0,0 +1,105 @@
1#!/bin/bash
2
3./configure 2 > /dev/null
4
5#********************************
6# servers
7#********************************
8if [ -f /etc/init.d/snmpd ]
9then
10 echo "TESTING: snmpd (test/root/snmpd.exp)"
11 ./snmpd.exp
12else
13 echo "TESTING SKIP: snmpd not found"
14fi
15
16
17if [ -f /etc/init.d/apache2 ]
18then
19 echo "TESTING: apache2 (test/root/apache2.exp)"
20 ./apache2.exp
21else
22 echo "TESTING SKIP: apache2 not found"
23fi
24
25if [ -f /etc/init.d/isc-dhcp-server ]
26then
27 echo "TESTING: isc dhcp server (test/root/isc-dhscp.exp)"
28 ./isc-dhcp.exp
29else
30 echo "TESTING SKIP: isc dhcp server not found"
31fi
32
33if [ -f /etc/init.d/unbound ]
34then
35 echo "TESTING: unbound (test/root/unbound.exp)"
36 ./unbound.exp
37else
38 echo "TESTING SKIP: unbound not found"
39fi
40
41if [ -f /etc/init.d/nginx ]
42then
43 echo "TESTING: nginx (test/root/nginx.exp)"
44 ./nginx.exp
45else
46 echo "TESTING SKIP: nginx not found"
47fi
48
49#********************************
50# seccomp
51#********************************
52echo "TESTING: seccomp umount (test/root/seccomp-umount.exp)"
53./seccomp-umount.exp
54
55echo "TESTING: seccomp chmod (test/root/seccomp-chmod.exp)"
56./seccomp-chmod.exp
57
58echo "TESTING: seccomp chown (test/root/seccomp-chown.exp)"
59./seccomp-chown.exp
60
61#********************************
62# command line options
63#********************************
64echo "TESTING: tmpfs (test/root/option_tmpfs.exp)"
65./option_tmpfs.exp
66
67echo "TESTING: profile tmpfs (test/root/profile_tmpfs)"
68./profile_tmpfs.exp
69
70echo "TESTING: bind directory (test/root/option_bind_directory.exp)"
71./option_bind_directory.exp
72
73echo "TESTING: bind file (test/root/option_bind_file.exp)"
74echo hello > tmpfile
75./option_bind_file.exp
76rm -f tmpfile
77
78#********************************
79# networking
80#********************************
81echo "TESTING: network interfaces (test/root/net_interface.exp)"
82./net_interface.exp
83
84echo "TESTING: firemon --interface (test/root/firemon-interface.exp)"
85./firemon-interface.exp
86
87#if [ -f /sys/fs/cgroup/g1/tasks ]
88#then
89# echo "TESTING: firemon --cgroup (firemon-cgroup.exp)"
90# ./firemon-cgroup.exp
91#fi
92#
93#echo "TESTING: chroot resolv.conf (chroot-resolvconf.exp)"
94#rm -f tmpfile
95#touch tmpfile
96#rm -f /tmp/chroot/etc/resolv.conf
97#ln -s tmp /tmp/chroot/etc/resolv.conf
98#./chroot-resolvconf.exp
99#rm -f tmpfile
100#rm /tmp/chroot/etc/resolv.conf
101
102#echo "TESTING: chroot (fs_chroot_asroot.exp)"
103#./fs_chroot_asroot.exp
104
105
diff --git a/test/root/seccomp-chmod.exp b/test/root/seccomp-chmod.exp
new file mode 100755
index 000000000..b17990e3a
--- /dev/null
+++ b/test/root/seccomp-chmod.exp
@@ -0,0 +1,51 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --seccomp=chmod,fchmod,fchmodat --private\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 2
16
17send -- "cd ~; echo done\r"
18expect {
19 timeout {puts "TESTING ERROR 1\n";exit}
20 "done"
21}
22
23send -- "touch testfile; echo done\r"
24expect {
25 timeout {puts "TESTING ERROR 2\n";exit}
26 "done"
27}
28
29send -- "ls -l testfile; echo done\r"
30expect {
31 timeout {puts "TESTING ERROR 3\n";exit}
32 "testfile"
33}
34expect {
35 timeout {puts "TESTING ERROR 4\n";exit}
36 "done"
37}
38
39send -- "chmod +x testfile; echo done\r"
40expect {
41 timeout {puts "TESTING ERROR 5\n";exit}
42 "Bad system call"
43}
44expect {
45 timeout {puts "TESTING ERROR 6\n";exit}
46 "done"
47}
48
49send -- "exit\r"
50after 100
51puts "\nall done\n"
diff --git a/test/root/seccomp-chown.exp b/test/root/seccomp-chown.exp
new file mode 100755
index 000000000..a54d279f1
--- /dev/null
+++ b/test/root/seccomp-chown.exp
@@ -0,0 +1,49 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --seccomp=chown,fchown,fchownat,lchown --private\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 2
16
17send -- "touch testfile;pwd\r"
18expect {
19 timeout {puts "TESTING ERROR 1\n";exit}
20 "/root" {puts "running as root"}
21 "/home"
22}
23
24send -- "ls -l testfile;pwd\r"
25expect {
26 timeout {puts "TESTING ERROR 2\n";exit}
27 "testfile"
28}
29expect {
30 timeout {puts "TESTING ERROR 3\n";exit}
31 "/root" {puts "running as root"}
32 "/home"
33}
34
35send -- "chown netblue:netblue testfile;pwd\r"
36expect {
37 timeout {puts "TESTING ERROR 2\n";exit}
38 "Bad system call"
39}
40expect {
41 timeout {puts "TESTING ERROR 3\n";exit}
42 "/root" {puts "running as root"}
43 "/home"
44}
45
46
47send -- "exit\r"
48after 100
49puts "\nall done\n"
diff --git a/test/filters/seccomp-umount.exp b/test/root/seccomp-umount.exp
index df38dba5e..04a9b7a3d 100755
--- a/test/filters/seccomp-umount.exp
+++ b/test/root/seccomp-umount.exp
@@ -7,12 +7,6 @@ set timeout 10
7spawn $env(SHELL) 7spawn $env(SHELL)
8match_max 100000 8match_max 100000
9 9
10send -- "sudo ls; sudo whoami; sudo pwd\r"
11expect {
12 timeout {puts "TESTING ERROR: you need to root run this test as root\n";exit}
13 "root"
14}
15
16send -- "firejail --net=br0 --ip=10.10.20.5 --seccomp --noprofile\r" 10send -- "firejail --net=br0 --ip=10.10.20.5 --seccomp --noprofile\r"
17expect { 11expect {
18 timeout {puts "TESTING ERROR 0\n";exit} 12 timeout {puts "TESTING ERROR 0\n";exit}
diff --git a/test/servers2.exp b/test/root/snmpd.exp
index 90e34470f..90e34470f 100755
--- a/test/servers2.exp
+++ b/test/root/snmpd.exp
diff --git a/test/root/start.sh b/test/root/start.sh
new file mode 100755
index 000000000..8e7a869cd
--- /dev/null
+++ b/test/root/start.sh
@@ -0,0 +1,4 @@
1#/bin/bash
2
3./configure
4./root.sh | grep TESTING \ No newline at end of file
diff --git a/test/tmpfs.profile b/test/root/tmpfs.profile
index 0680f4d69..0680f4d69 100644
--- a/test/tmpfs.profile
+++ b/test/root/tmpfs.profile
diff --git a/test/servers5.exp b/test/root/unbound.exp
index 193e662ff..193e662ff 100755
--- a/test/servers5.exp
+++ b/test/root/unbound.exp
diff --git a/test/test-root.sh b/test/test-root.sh
deleted file mode 100755
index 0fdaf4ff7..000000000
--- a/test/test-root.sh
+++ /dev/null
@@ -1,81 +0,0 @@
1#!/bin/bash
2
3./chk_config.exp
4
5echo "TESTING: tmpfs (option_tmpfs.exp)"
6./option_tmpfs.exp
7
8echo "TESTING: profile tmpfs (profile_tmpfs)"
9./profile_tmpfs.exp
10
11echo "TESTING: network interfaces (net_interface.exp)"
12./network/net_interface.exp
13
14echo "TESTING: chroot (fs_chroot_asroot.exp)"
15./fs_chroot_asroot.exp
16
17if [ -f /etc/init.d/snmpd ]
18then
19 echo "TESTING: servers snmpd, private-dev (servers2.exp)"
20 ./servers2.exp
21fi
22
23if [ -f /etc/init.d/apache2 ]
24then
25 echo "TESTING: servers apache2, private-dev, private-tmp (servers3.exp)"
26 ./servers3.exp
27fi
28
29if [ -f /etc/init.d/isc-dhcp-server ]
30then
31 echo "TESTING: servers isc dhcp server, private-dev (servers4.exp)"
32 ./servers4.exp
33fi
34
35if [ -f /etc/init.d/unbound ]
36then
37 echo "TESTING: servers unbound, private-dev, private-tmp (servers5.exp)"
38 ./servers5.exp
39fi
40
41if [ -f /etc/init.d/nginx ]
42then
43 echo "TESTING: servers nginx, private-dev, private-tmp (servers6.exp)"
44 ./servers6.exp
45fi
46
47echo "TESTING: seccomp umount (seccomp-umount.exp)"
48./filters/seccomp-umount.exp
49
50echo "TESTING: seccomp chmod (seccomp-chmod.exp)"
51./filters/seccomp-chmod.exp
52
53echo "TESTING: seccomp chown (seccomp-chown.exp)"
54./filters/seccomp-chown.exp
55
56echo "TESTING: bind directory (option_bind_directory.exp)"
57./option_bind_directory.exp
58
59echo "TESTING: bind file (option_bind_file.exp)"
60echo hello > tmpfile
61./option_bind_file.exp
62rm -f tmpfile
63
64echo "TESTING: firemon --interface (firemon-interface.exp)"
65./firemon-interface.exp
66
67if [ -f /sys/fs/cgroup/g1/tasks ]
68then
69 echo "TESTING: firemon --cgroup (firemon-cgroup.exp)"
70 ./firemon-cgroup.exp
71fi
72
73echo "TESTING: chroot resolv.conf (chroot-resolvconf.exp)"
74rm -f tmpfile
75touch tmpfile
76rm -f /tmp/chroot/etc/resolv.conf
77ln -s tmp /tmp/chroot/etc/resolv.conf
78./chroot-resolvconf.exp
79rm -f tmpfile
80rm /tmp/chroot/etc/resolv.conf
81