aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2015-10-31 13:07:38 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2015-10-31 13:07:38 -0400
commit1cb8ef59101eeaa1b325fb7f881ded148b0de1d3 (patch)
treeea114440c2236e1418a17f0e78c3050262965d98 /test
parentreadme.md (diff)
downloadfirejail-1cb8ef59101eeaa1b325fb7f881ded148b0de1d3.tar.gz
firejail-1cb8ef59101eeaa1b325fb7f881ded148b0de1d3.tar.zst
firejail-1cb8ef59101eeaa1b325fb7f881ded148b0de1d3.zip
--chroot testing
Diffstat (limited to 'test')
-rwxr-xr-xtest/configure4
-rwxr-xr-xtest/fs_chroot.exp17
-rwxr-xr-xtest/fs_chroot_asroot.exp91
-rwxr-xr-xtest/test-root.sh6
-rwxr-xr-xtest/trace.exp2
5 files changed, 113 insertions, 7 deletions
diff --git a/test/configure b/test/configure
index 17bb22e1b..01f0c6ff0 100755
--- a/test/configure
+++ b/test/configure
@@ -22,7 +22,7 @@ ROOTDIR="/tmp/chroot" # default chroot directory
22DEFAULT_FILES="/bin/bash /bin/sh " # basic chroot files 22DEFAULT_FILES="/bin/bash /bin/sh " # basic chroot files
23DEFAULT_FILES+="/etc/passwd /etc/nsswitch.conf /etc/group " 23DEFAULT_FILES+="/etc/passwd /etc/nsswitch.conf /etc/group "
24DEFAULT_FILES+=`find /lib -name libnss*` # files required by glibc 24DEFAULT_FILES+=`find /lib -name libnss*` # files required by glibc
25DEFAULT_FILES+=" /bin/ls /bin/cat /bin/ps /usr/bin/id /usr/bin/whoami /usr/bin/wc /usr/bin/wget" 25DEFAULT_FILES+=" /bin/ls /bin/cat /bin/ps /usr/bin/id /usr/bin/whoami /usr/bin/wc /usr/bin/wget /bin/umount"
26 26
27rm -fr $ROOTDIR 27rm -fr $ROOTDIR
28mkdir -p $ROOTDIR/{root,bin,lib,lib64,usr,home,etc,dev/shm,tmp,var/run,var/tmp,var/lock,proc} 28mkdir -p $ROOTDIR/{root,bin,lib,lib64,usr,home,etc,dev/shm,tmp,var/run,var/tmp,var/lock,proc}
@@ -33,6 +33,8 @@ do
33done 33done
34cp --parents /lib64/ld-linux-x86-64.so.2 $ROOTDIR 34cp --parents /lib64/ld-linux-x86-64.so.2 $ROOTDIR
35cp --parents /lib/ld-linux.so.2 $ROOTDIR 35cp --parents /lib/ld-linux.so.2 $ROOTDIR
36cp ../src/tools/unchroot $ROOTDIR/.
37touch $ROOTDIR/this-is-my-chroot
36 38
37cd $ROOTDIR; find . 39cd $ROOTDIR; find .
38mkdir -p usr/lib/firejail/ 40mkdir -p usr/lib/firejail/
diff --git a/test/fs_chroot.exp b/test/fs_chroot.exp
index 448a00a7a..4ddf8d32a 100755
--- a/test/fs_chroot.exp
+++ b/test/fs_chroot.exp
@@ -4,7 +4,7 @@ set timeout 10
4spawn $env(SHELL) 4spawn $env(SHELL)
5match_max 100000 5match_max 100000
6 6
7send -- "firejail --noprofile --chroot=/tmp/chroot\r" 7send -- "firejail --chroot=/tmp/chroot\r"
8expect { 8expect {
9 timeout {puts "TESTING ERROR 0\n";exit} 9 timeout {puts "TESTING ERROR 0\n";exit}
10 "Child process initialized" 10 "Child process initialized"
@@ -13,12 +13,24 @@ sleep 1
13 13
14send -- "cd /home;pwd\r" 14send -- "cd /home;pwd\r"
15expect { 15expect {
16 timeout {puts "TESTING ERROR 3\n";exit} 16 timeout {puts "TESTING ERROR 0.1\n";exit}
17 "home" 17 "home"
18} 18}
19sleep 1 19sleep 1
20send -- "bash\r" 20send -- "bash\r"
21sleep 1 21sleep 1
22send -- "ls /; pwd\r"
23expect {
24 timeout {puts "TESTING ERROR 0.2\n";exit}
25 "this-is-my-chroot"
26}
27expect {
28 timeout {puts "TESTING ERROR 0.3\n";exit}
29 "home"
30}
31
32
33
22send -- "ps aux; pwd\r" 34send -- "ps aux; pwd\r"
23expect { 35expect {
24 timeout {puts "TESTING ERROR 1\n";exit} 36 timeout {puts "TESTING ERROR 1\n";exit}
@@ -50,5 +62,6 @@ expect {
50} 62}
51sleep 1 63sleep 1
52 64
65
53puts "all done\n" 66puts "all done\n"
54 67
diff --git a/test/fs_chroot_asroot.exp b/test/fs_chroot_asroot.exp
new file mode 100755
index 000000000..7e18153e0
--- /dev/null
+++ b/test/fs_chroot_asroot.exp
@@ -0,0 +1,91 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "firejail --chroot=/tmp/chroot\r"
8expect {
9 timeout {puts "TESTING ERROR 0\n";exit}
10 "Child process initialized"
11}
12sleep 1
13
14send -- "cd /home;pwd\r"
15expect {
16 timeout {puts "TESTING ERROR 0.1\n";exit}
17 "home"
18}
19sleep 1
20send -- "bash\r"
21sleep 1
22send -- "ls /; pwd\r"
23expect {
24 timeout {puts "TESTING ERROR 0.2\n";exit}
25 "this-is-my-chroot"
26}
27expect {
28 timeout {puts "TESTING ERROR 0.3\n";exit}
29 "home"
30}
31
32send -- "umount /boot; pwd\r"
33expect {
34 timeout {puts "TESTING ERROR 0.4\n";exit}
35 "Bad system call"
36}
37expect {
38 timeout {puts "TESTING ERROR 0.5\n";exit}
39 "home"
40}
41
42send -- "/unchroot; pwd\r"
43expect {
44 timeout {puts "TESTING ERROR 0.6\n";exit}
45 "Bad system call"
46}
47expect {
48 timeout {puts "TESTING ERROR 0.7\n";exit}
49 "home"
50}
51
52
53
54
55
56send -- "ps aux; pwd\r"
57expect {
58 timeout {puts "TESTING ERROR 1\n";exit}
59 "/bin/bash"
60}
61expect {
62 timeout {puts "TESTING ERROR 2\n";exit}
63 "bash"
64}
65expect {
66 timeout {puts "TESTING ERROR 3\n";exit}
67 "ps aux"
68}
69expect {
70 timeout {puts "TESTING ERROR 4\n";exit}
71 "home"
72}
73sleep 1
74
75
76send -- "ps aux |wc -l; pwd\r"
77expect {
78 timeout {puts "TESTING ERROR 5\n";exit}
79 "5"
80}
81expect {
82 timeout {puts "TESTING ERROR 6\n";exit}
83 "home"
84}
85sleep 1
86
87
88
89
90puts "all done\n"
91
diff --git a/test/test-root.sh b/test/test-root.sh
index fcfe32a58..94ac3447d 100755
--- a/test/test-root.sh
+++ b/test/test-root.sh
@@ -5,6 +5,9 @@
5echo "TESTING: network interfaces" 5echo "TESTING: network interfaces"
6./net_interface.exp 6./net_interface.exp
7 7
8echo "TESTING: chroot"
9./fs_chroot_asroot.exp
10
8echo "TESTING: servers rsyslogd, sshd, nginx" 11echo "TESTING: servers rsyslogd, sshd, nginx"
9./servers.exp 12./servers.exp
10 13
@@ -46,9 +49,6 @@ echo hello > tmpfile
46./option_bind_file.exp 49./option_bind_file.exp
47rm -f tmpfile 50rm -f tmpfile
48 51
49echo "TESTING: chroot"
50./fs_chroot.exp
51
52echo "TESTING: firemon --interface" 52echo "TESTING: firemon --interface"
53./firemon-interface.exp 53./firemon-interface.exp
54 54
diff --git a/test/trace.exp b/test/trace.exp
index bca3ac3b3..2b5003d83 100755
--- a/test/trace.exp
+++ b/test/trace.exp
@@ -91,5 +91,5 @@ expect {
91sleep 1 91sleep 1
92 92
93 93
94puts "\n" 94puts "\nall done\n"
95 95