From fffce11c3da087172c069ec0ff4c788f5bcc522b Mon Sep 17 00:00:00 2001 From: netblue30 Date: Thu, 10 Nov 2016 20:15:22 -0500 Subject: testing --- test/root/configure | 27 ------------ test/root/firemon-events.exp | 72 +++++++++++++++++++++++++++++++ test/root/firemon-interface.exp | 34 --------------- test/root/net_interface.exp | 93 ----------------------------------------- test/root/option_tmpfs.exp | 8 +--- test/root/profile_tmpfs.exp | 37 ++++++++-------- test/root/root.sh | 31 ++------------ test/root/start.sh | 4 -- test/root/tmpfs-bad.profile | 1 + test/root/tmpfs.profile | 2 +- 10 files changed, 99 insertions(+), 210 deletions(-) delete mode 100755 test/root/configure create mode 100755 test/root/firemon-events.exp delete mode 100755 test/root/firemon-interface.exp delete mode 100755 test/root/net_interface.exp delete mode 100755 test/root/start.sh create mode 100644 test/root/tmpfs-bad.profile (limited to 'test/root') diff --git a/test/root/configure b/test/root/configure deleted file mode 100755 index 35d938340..000000000 --- a/test/root/configure +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# This file is part of Firejail project -# Copyright (C) 2014-2016 Firejail Authors -# License GPL v2 - -brctl addbr br0 -ifconfig br0 10.10.20.1/29 up -# NAT masquerade -iptables -t nat -A POSTROUTING -o eth0 -s 10.10.20.0/29 -j MASQUERADE -# port forwarding -# iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 10.10.20.2:80 - -brctl addbr br1 -ifconfig br1 10.10.30.1/24 up -brctl addbr br2 -ifconfig br2 10.10.40.1/24 up -brctl addbr br3 -ifconfig br3 10.10.50.1/24 up -brctl addbr br4 -ifconfig br4 10.10.60.1/24 up -ip link add link eth0 name eth0.5 type vlan id 5 -/sbin/ifconfig eth0.5 10.10.205.10/24 up -ip link add link eth0 name eth0.6 type vlan id 6 -/sbin/ifconfig eth0.6 10.10.206.10/24 up -ip link add link eth0 name eth0.7 type vlan id 7 -/sbin/ifconfig eth0.7 10.10.207.10/24 up - diff --git a/test/root/firemon-events.exp b/test/root/firemon-events.exp new file mode 100755 index 000000000..4f305e51d --- /dev/null +++ b/test/root/firemon-events.exp @@ -0,0 +1,72 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +# start firemon +set firemon_id $spawn_id +send -- "firemon\r" +sleep 1 + +# start firejail +spawn $env(SHELL) +set firejail_id $spawn_id +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} + +# get messages on firemon +set spawn_id $firemon_id +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "exec" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "/bin/bash -c /bin/bash" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "exec" +} +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "/bin/bash" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "fork" +} +expect { + timeout {puts "TESTING ERROR 6\n";exit} + "child" +} +expect { + timeout {puts "TESTING ERROR 7\n";exit} + "/bin/bash" +} +after 100 + +# exit firejail +set spawn_id $firejail_id +send -- "exit\r" +sleep 1 + +# get messages on firemon +set spawn_id $firemon_id +expect { + timeout {puts "TESTING ERROR 8\n";exit} + "exit" +} + +expect { + timeout {puts "TESTING ERROR 9\n";exit} + "EXIT SANDBOX" +} + + +puts "\nall done\n" + diff --git a/test/root/firemon-interface.exp b/test/root/firemon-interface.exp deleted file mode 100755 index 6a82ae41e..000000000 --- a/test/root/firemon-interface.exp +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/expect -f - -set timeout 10 -spawn $env(SHELL) -match_max 100000 - -send -- "firejail\r" -expect { - timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" -} -sleep 1 - -spawn $env(SHELL) -send -- "firemon --interface\r" -expect { - timeout {puts "TESTING ERROR 1\n";exit} - "lo UP" -} -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "10.10.20.1/29" -} -expect { - timeout {puts "TESTING ERROR 3\n";exit} - "10.10.50.1/24" -} -expect { - timeout {puts "TESTING ERROR 3\n";exit} - "br3" -} -sleep 1 - -puts "\n" diff --git a/test/root/net_interface.exp b/test/root/net_interface.exp deleted file mode 100755 index 2f87024d8..000000000 --- a/test/root/net_interface.exp +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/expect -f -# This file is part of Firejail project -# Copyright (C) 2014-2016 Firejail Authors -# License GPL v2 - -set timeout 10 -spawn $env(SHELL) -match_max 100000 - -send -- "ip link add link eth0 name eth0.100 type vlan id 100\r" -sleep 1 -send -- "ip link add link eth0 name eth0.101 type vlan id 101\r" -sleep 1 -send -- "ip link add link eth0 name eth0.102 type vlan id 102\r" -sleep 1 -send -- "ip link add link eth0 name eth0.103 type vlan id 103\r" -sleep 1 -send -- "ip link add link eth0 name eth0.104 type vlan id 104\r" -sleep 1 -puts "\n" - -send -- "/sbin/ifconfig eth0.100 10.200.0.1/24\r" -sleep 1 -send -- "/sbin/ifconfig eth0.101 10.200.1.1/24\r" -sleep 1 -send -- "/sbin/ifconfig eth0.102 10.200.2.1/24\r" -sleep 1 -send -- "/sbin/ifconfig eth0.103 10.200.3.1/24\r" -sleep 1 -send -- "/sbin/ifconfig eth0.104 10.200.4.1/24\r" -sleep 1 -puts "\n" - - - -send -- "firejail --noprofile --interface=eth0.100 --interface=eth0.101 --interface=eth0.102 --interface=eth0.103 --interface=eth0.104\r" -expect { - timeout {puts "TESTING ERROR 0\n";exit} - "maximum 4 interfaces are allowed" -} -sleep 1 - -send -- "firejail --noprofile --interface=eth0.100 --interface=eth0.101 --interface=eth0.102 --interface=eth0.103\r" -expect { - timeout {puts "TESTING ERROR 1\n";exit} - "eth0.100" -} -expect { - timeout {puts "TESTING ERROR 1.1\n";exit} - "UP" -} -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "eth0.101" -} -expect { - timeout {puts "TESTING ERROR 2.2\n";exit} - "UP" -} -expect { - timeout {puts "TESTING ERROR 3\n";exit} - "eth0.102" -} -expect { - timeout {puts "TESTING ERROR 3.1\n";exit} - "UP" -} -expect { - timeout {puts "TESTING ERROR 4\n";exit} - "eth0.103" -} -expect { - timeout {puts "TESTING ERROR 4.1\n";exit} - "UP" -} -sleep 1 -send -- "exit\r" -sleep 1 - -send -- "firejail --noprofile --interface=eth0.104\r" -expect { - timeout {puts "TESTING ERROR 5\n";exit} - "eth0.104" -} -expect { - timeout {puts "TESTING ERROR 5.1\n";exit} - "UP" -} -send -- "exit\r" -after 100 - -puts "all done\n" - diff --git a/test/root/option_tmpfs.exp b/test/root/option_tmpfs.exp index 20e42a858..3d492dfdb 100755 --- a/test/root/option_tmpfs.exp +++ b/test/root/option_tmpfs.exp @@ -16,13 +16,9 @@ expect { timeout {puts "TESTING ERROR 1\n";exit} "total 0" } -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "/root" -} -sleep 1 +after 100 send -- "exit\r" -sleep 2 +sleep 1 send -- "firejail --debug-check-filename --tmpfs=\"bla&&bla\"\r" expect { diff --git a/test/root/profile_tmpfs.exp b/test/root/profile_tmpfs.exp index da7c084a2..25f73b50b 100755 --- a/test/root/profile_tmpfs.exp +++ b/test/root/profile_tmpfs.exp @@ -4,34 +4,37 @@ set timeout 10 spawn $env(SHELL) match_max 100000 -send -- "mkdir /tmp/firejailtestdir\r" -sleep 1 -send -- "ls > /tmp/firejailtestdir/tmpfile\r" -sleep 1 - send -- "firejail --profile=tmpfs.profile\r" expect { timeout {puts "TESTING ERROR 0\n";exit} "Child process initialized" } - -# testing private only -send -- "bash\r" sleep 1 -send -- "ls -l /tmp/firejailtestdir;pwd\r" +send -- "ls -l /var;pwd\r" expect { - timeout {puts "TESTING ERROR 1.1\n";exit} - "tmpfile" {puts "TESTING ERROR 1\n";exit} - "home" + timeout {puts "TESTING ERROR 1\n";exit} + "total 0" } -sleep 1 -send -- "exit\r" -sleep 1 +after 100 send -- "exit\r" sleep 1 -send -- "rm -fr /tmp/firejailtestdir\r" -sleep 1 +send -- "firejail --debug-check-filename --profile=tmpfs-bad.profile\r" +expect { + timeout {puts "TESTING ERROR 13.1\n";exit} + "Checking filename bla&&bla" +} +expect { + timeout {puts "TESTING ERROR 13.2\n";exit} + "Error:" +} +expect { + timeout {puts "TESTING ERROR 13.3\n";exit} + "is an invalid filename" +} +after 100 + puts "\nall done\n" + diff --git a/test/root/root.sh b/test/root/root.sh index 960071d45..5576faad6 100755 --- a/test/root/root.sh +++ b/test/root/root.sh @@ -1,7 +1,5 @@ #!/bin/bash -./configure 2 > /dev/null - #******************************** # servers #******************************** @@ -76,30 +74,7 @@ echo hello > tmpfile rm -f tmpfile #******************************** -# networking +# firemon #******************************** -echo "TESTING: network interfaces (test/root/net_interface.exp)" -./net_interface.exp - -echo "TESTING: firemon --interface (test/root/firemon-interface.exp)" -./firemon-interface.exp - -#if [ -f /sys/fs/cgroup/g1/tasks ] -#then -# echo "TESTING: firemon --cgroup (firemon-cgroup.exp)" -# ./firemon-cgroup.exp -#fi -# -#echo "TESTING: chroot resolv.conf (chroot-resolvconf.exp)" -#rm -f tmpfile -#touch tmpfile -#rm -f /tmp/chroot/etc/resolv.conf -#ln -s tmp /tmp/chroot/etc/resolv.conf -#./chroot-resolvconf.exp -#rm -f tmpfile -#rm /tmp/chroot/etc/resolv.conf - -#echo "TESTING: chroot (fs_chroot_asroot.exp)" -#./fs_chroot_asroot.exp - - +echo "TESTING: firemon events (test/root/firemon-events.exp)" +./firemon-events.exp diff --git a/test/root/start.sh b/test/root/start.sh deleted file mode 100755 index 8e7a869cd..000000000 --- a/test/root/start.sh +++ /dev/null @@ -1,4 +0,0 @@ -#/bin/bash - -./configure -./root.sh | grep TESTING \ No newline at end of file diff --git a/test/root/tmpfs-bad.profile b/test/root/tmpfs-bad.profile new file mode 100644 index 000000000..7264e18ff --- /dev/null +++ b/test/root/tmpfs-bad.profile @@ -0,0 +1 @@ +tmpfs bla&&bla diff --git a/test/root/tmpfs.profile b/test/root/tmpfs.profile index 0680f4d69..55a6f7ebc 100644 --- a/test/root/tmpfs.profile +++ b/test/root/tmpfs.profile @@ -1 +1 @@ -tmpfs /tmp/firejailtestdir \ No newline at end of file +tmpfs /var -- cgit v1.2.3-54-g00ecf