Skip to content

Commit

Permalink
chroot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Feb 28, 2023
1 parent 8b8fa55 commit 55fb69f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion test/chroot/chroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ rm -f unchroot
gcc -o unchroot unchroot.c
sudo ./configure


echo "TESTING: chroot disabled (test/chroot/fs_chroot_disabled.exp)"
sudo sed -i s/"chroot yes"/"# chroot no"/g /etc/firejail/firejail.config
./fs_chroot_disabled.exp

sudo sed -i s/"# chroot no"/"chroot yes"/g /etc/firejail/firejail.config

echo "TESTING: chroot (test/chroot/fs_chroot.exp)"
sudo sed -i s/"# chroot no"/"chroot yes"/g /etc/firejail/firejail.config
./fs_chroot.exp

echo "TESTING: unchroot as root (test/chroot/unchroot-as-root.exp)"
Expand Down
10 changes: 6 additions & 4 deletions test/chroot/configure
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ROOTDIR="/tmp/chroot" # default chroot directory
DEFAULT_FILES="/bin/bash /bin/sh " # basic chroot files
DEFAULT_FILES+="/etc/passwd /etc/nsswitch.conf /etc/group "
DEFAULT_FILES+=`find /lib -name libnss*` # files required by glibc
DEFAULT_FILES+=" /bin/cp /bin/ls /bin/cat /bin/ps /bin/netstat /bin/ping /usr/bin/touch /bin/grep"
DEFAULT_FILES+=" /bin/cp /bin/ls /bin/cat /bin/ps /bin/ping /usr/bin/touch /bin/grep"

rm -fr $ROOTDIR
mkdir -p $ROOTDIR/{root,bin,lib,lib64,usr,home,etc,dev/shm,tmp,var/run,var/tmp,var/lock,var/log,proc,sys}
Expand All @@ -18,6 +18,10 @@ mkdir -p $ROOTDIR/home/netblue/.config/firejail
chown netblue:netblue $ROOTDIR/home/netblue
chown netblue:netblue $ROOTDIR/home/netblue/.config
cp /home/netblue/.Xauthority $ROOTDIR/home/netblue/.
mkdir -p $ROOTDIR/home/runner/.config/firejail
chown runner:runner $ROOTDIR/home/runner
chown runner:runner $ROOTDIR/home/runner/.config

cp -a /etc/skel $ROOTDIR/etc/.
mkdir $ROOTDIR/home/someotheruser
mkdir $ROOTDIR/boot
Expand All @@ -27,8 +31,6 @@ cp /etc/group $ROOTDIR/etc/.
cp /etc/hosts $ROOTDIR/etc/.
cp /etc/hostname $ROOTDIR/etc/.
mkdir -p $ROOTDIR/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/openssl-1.0.0 $ROOTDIR/usr/lib/x86_64-linux-gnu/.
cp -a /usr/lib/ssl $ROOTDIR/usr/lib/.
touch $ROOTDIR/var/log/syslog
touch $ROOTDIR/var/tmp/somefile
SORTED=`for FILE in $* $DEFAULT_FILES; do echo " $FILE "; ldd $FILE | grep -v dynamic | cut -d " " -f 3; done | sort -u`
Expand All @@ -41,7 +43,7 @@ cp --parents /lib/ld-linux.so.2 $ROOTDIR
cp unchroot $ROOTDIR/.
touch $ROOTDIR/this-is-my-chroot

cd $ROOTDIR; find .
cd $ROOTDIR;
mkdir -p usr/lib/firejail/
cp /usr/lib/firejail/libtrace.so usr/lib/firejail/.

Expand Down

0 comments on commit 55fb69f

Please sign in to comment.