diff options
author | 2023-02-28 10:07:35 -0500 | |
---|---|---|
committer | 2023-02-28 10:07:35 -0500 | |
commit | 55fb69f4f500e8a6cbd3ce2cdc95c03d46b078e0 (patch) | |
tree | 1a3401e24c0efa8d1ceb0d535386eed9725eea38 /test | |
parent | Merge branch 'master' of ssh://github.com/netblue30/firejail (diff) | |
download | firejail-55fb69f4f500e8a6cbd3ce2cdc95c03d46b078e0.tar.gz firejail-55fb69f4f500e8a6cbd3ce2cdc95c03d46b078e0.tar.zst firejail-55fb69f4f500e8a6cbd3ce2cdc95c03d46b078e0.zip |
chroot testing
Diffstat (limited to 'test')
-rwxr-xr-x | test/chroot/chroot.sh | 4 | ||||
-rwxr-xr-x | test/chroot/configure | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/test/chroot/chroot.sh b/test/chroot/chroot.sh index a1fb3ee38..3b10cbc59 100755 --- a/test/chroot/chroot.sh +++ b/test/chroot/chroot.sh | |||
@@ -11,12 +11,14 @@ rm -f unchroot | |||
11 | gcc -o unchroot unchroot.c | 11 | gcc -o unchroot unchroot.c |
12 | sudo ./configure | 12 | sudo ./configure |
13 | 13 | ||
14 | |||
14 | echo "TESTING: chroot disabled (test/chroot/fs_chroot_disabled.exp)" | 15 | echo "TESTING: chroot disabled (test/chroot/fs_chroot_disabled.exp)" |
16 | sudo sed -i s/"chroot yes"/"# chroot no"/g /etc/firejail/firejail.config | ||
15 | ./fs_chroot_disabled.exp | 17 | ./fs_chroot_disabled.exp |
16 | 18 | ||
17 | sudo sed -i s/"# chroot no"/"chroot yes"/g /etc/firejail/firejail.config | ||
18 | 19 | ||
19 | echo "TESTING: chroot (test/chroot/fs_chroot.exp)" | 20 | echo "TESTING: chroot (test/chroot/fs_chroot.exp)" |
21 | sudo sed -i s/"# chroot no"/"chroot yes"/g /etc/firejail/firejail.config | ||
20 | ./fs_chroot.exp | 22 | ./fs_chroot.exp |
21 | 23 | ||
22 | echo "TESTING: unchroot as root (test/chroot/unchroot-as-root.exp)" | 24 | echo "TESTING: unchroot as root (test/chroot/unchroot-as-root.exp)" |
diff --git a/test/chroot/configure b/test/chroot/configure index af511f9c7..f7bfedf10 100755 --- a/test/chroot/configure +++ b/test/chroot/configure | |||
@@ -8,7 +8,7 @@ ROOTDIR="/tmp/chroot" # default chroot directory | |||
8 | DEFAULT_FILES="/bin/bash /bin/sh " # basic chroot files | 8 | DEFAULT_FILES="/bin/bash /bin/sh " # basic chroot files |
9 | DEFAULT_FILES+="/etc/passwd /etc/nsswitch.conf /etc/group " | 9 | DEFAULT_FILES+="/etc/passwd /etc/nsswitch.conf /etc/group " |
10 | DEFAULT_FILES+=`find /lib -name libnss*` # files required by glibc | 10 | DEFAULT_FILES+=`find /lib -name libnss*` # files required by glibc |
11 | DEFAULT_FILES+=" /bin/cp /bin/ls /bin/cat /bin/ps /bin/netstat /bin/ping /usr/bin/touch /bin/grep" | 11 | DEFAULT_FILES+=" /bin/cp /bin/ls /bin/cat /bin/ps /bin/ping /usr/bin/touch /bin/grep" |
12 | 12 | ||
13 | rm -fr $ROOTDIR | 13 | rm -fr $ROOTDIR |
14 | mkdir -p $ROOTDIR/{root,bin,lib,lib64,usr,home,etc,dev/shm,tmp,var/run,var/tmp,var/lock,var/log,proc,sys} | 14 | mkdir -p $ROOTDIR/{root,bin,lib,lib64,usr,home,etc,dev/shm,tmp,var/run,var/tmp,var/lock,var/log,proc,sys} |
@@ -18,6 +18,10 @@ mkdir -p $ROOTDIR/home/netblue/.config/firejail | |||
18 | chown netblue:netblue $ROOTDIR/home/netblue | 18 | chown netblue:netblue $ROOTDIR/home/netblue |
19 | chown netblue:netblue $ROOTDIR/home/netblue/.config | 19 | chown netblue:netblue $ROOTDIR/home/netblue/.config |
20 | cp /home/netblue/.Xauthority $ROOTDIR/home/netblue/. | 20 | cp /home/netblue/.Xauthority $ROOTDIR/home/netblue/. |
21 | mkdir -p $ROOTDIR/home/runner/.config/firejail | ||
22 | chown runner:runner $ROOTDIR/home/runner | ||
23 | chown runner:runner $ROOTDIR/home/runner/.config | ||
24 | |||
21 | cp -a /etc/skel $ROOTDIR/etc/. | 25 | cp -a /etc/skel $ROOTDIR/etc/. |
22 | mkdir $ROOTDIR/home/someotheruser | 26 | mkdir $ROOTDIR/home/someotheruser |
23 | mkdir $ROOTDIR/boot | 27 | mkdir $ROOTDIR/boot |
@@ -27,8 +31,6 @@ cp /etc/group $ROOTDIR/etc/. | |||
27 | cp /etc/hosts $ROOTDIR/etc/. | 31 | cp /etc/hosts $ROOTDIR/etc/. |
28 | cp /etc/hostname $ROOTDIR/etc/. | 32 | cp /etc/hostname $ROOTDIR/etc/. |
29 | mkdir -p $ROOTDIR/usr/lib/x86_64-linux-gnu | 33 | mkdir -p $ROOTDIR/usr/lib/x86_64-linux-gnu |
30 | cp -a /usr/lib/x86_64-linux-gnu/openssl-1.0.0 $ROOTDIR/usr/lib/x86_64-linux-gnu/. | ||
31 | cp -a /usr/lib/ssl $ROOTDIR/usr/lib/. | ||
32 | touch $ROOTDIR/var/log/syslog | 34 | touch $ROOTDIR/var/log/syslog |
33 | touch $ROOTDIR/var/tmp/somefile | 35 | touch $ROOTDIR/var/tmp/somefile |
34 | SORTED=`for FILE in $* $DEFAULT_FILES; do echo " $FILE "; ldd $FILE | grep -v dynamic | cut -d " " -f 3; done | sort -u` | 36 | SORTED=`for FILE in $* $DEFAULT_FILES; do echo " $FILE "; ldd $FILE | grep -v dynamic | cut -d " " -f 3; done | sort -u` |
@@ -41,7 +43,7 @@ cp --parents /lib/ld-linux.so.2 $ROOTDIR | |||
41 | cp unchroot $ROOTDIR/. | 43 | cp unchroot $ROOTDIR/. |
42 | touch $ROOTDIR/this-is-my-chroot | 44 | touch $ROOTDIR/this-is-my-chroot |
43 | 45 | ||
44 | cd $ROOTDIR; find . | 46 | cd $ROOTDIR; |
45 | mkdir -p usr/lib/firejail/ | 47 | mkdir -p usr/lib/firejail/ |
46 | cp /usr/lib/firejail/libtrace.so usr/lib/firejail/. | 48 | cp /usr/lib/firejail/libtrace.so usr/lib/firejail/. |
47 | 49 | ||