diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-chroot.sh | 27 | ||||
-rwxr-xr-x | test/test-pseudo_disable-fork-env_i.sh (renamed from test/test-forkoff-env_i.sh) | 0 | ||||
-rwxr-xr-x | test/test-pseudo_disable-fork.sh (renamed from test/test-forkoff.sh) | 0 | ||||
-rwxr-xr-x | test/test-pseudo_unload-fork-env_i.sh | 29 | ||||
-rwxr-xr-x | test/test-pseudo_unload-fork.sh | 18 | ||||
-rwxr-xr-x | test/test-reexec-chroot.sh | 30 |
6 files changed, 104 insertions, 0 deletions
diff --git a/test/test-chroot.sh b/test/test-chroot.sh new file mode 100755 index 0000000..02c9ff6 --- /dev/null +++ b/test/test-chroot.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Return vals: 2 - invalid arg list +# 1 - chroot failed +# 0 - chroot succeeded +cat > chroot_test.c << EOF +#include <unistd.h> +int main(int argc, char *argv[]) { + if (argc != 2) + return 2; + return (chroot(argv[1]) == -1); +} +EOF + +gcc -o chroot_test chroot_test.c + +./chroot_test `pwd` + +if [ "$?" = "0" ] +then + #echo "Passed." + rm -f chroot_test chroot_test.c + exit 0 +fi +#echo "Failed" +rm -f chroot_test chroot_test.c +exit 1 diff --git a/test/test-forkoff-env_i.sh b/test/test-pseudo_disable-fork-env_i.sh index 1e679aa..1e679aa 100755 --- a/test/test-forkoff-env_i.sh +++ b/test/test-pseudo_disable-fork-env_i.sh diff --git a/test/test-forkoff.sh b/test/test-pseudo_disable-fork.sh index 13a42a4..13a42a4 100755 --- a/test/test-forkoff.sh +++ b/test/test-pseudo_disable-fork.sh diff --git a/test/test-pseudo_unload-fork-env_i.sh b/test/test-pseudo_unload-fork-env_i.sh new file mode 100755 index 0000000..d6658e0 --- /dev/null +++ b/test/test-pseudo_unload-fork-env_i.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Verify normal operation... +uid=`env -i id -u` +gid=`env -i id -g` +if [ $uid -ne 0 -o $gid -ne 0 ]; then + exit 1 +fi + +export PSEUDO_UNLOAD=1 +# Verify we dropped OUT of pseudo control, even with env -i +# This checks that env -i replacement functionality still works +# as expected +uid=`env -i id -u` +gid=`env -i id -g` +if [ $uid -eq 0 -o $gid -eq 0 ]; then + exit 1 +fi + +export PSEUDO_UNLOAD=1 +# Verify that once PSEUDO_UNLOAD has been issued, that +# we can't restore pseudo into memory +uid=`env -i PSEUDO_DISABLED=0 id -u` +gid=`env -i PSEUDO_DISABLED=0 id -g` +if [ $uid -eq 0 -o $gid -eq 0 ]; then + exit 1 +fi + +exit 0 diff --git a/test/test-pseudo_unload-fork.sh b/test/test-pseudo_unload-fork.sh new file mode 100755 index 0000000..9f79198 --- /dev/null +++ b/test/test-pseudo_unload-fork.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Verify normal operation... +uid=`id -u` +gid=`id -g` +if [ $uid -ne 0 -o $gid -ne 0 ]; then + exit 1 +fi + +export PSEUDO_UNLOAD=1 +# Verify we dropped OUT of pseudo control +uid=`id -u` +gid=`id -g` +if [ $uid -eq 0 -o $gid -eq 0 ]; then + exit 1 +fi + +exit 0 diff --git a/test/test-reexec-chroot.sh b/test/test-reexec-chroot.sh new file mode 100755 index 0000000..bde93f1 --- /dev/null +++ b/test/test-reexec-chroot.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Test if we re-invoke pseudo that chroot still works + +# Return vals: 2 - invalid arg list +# 1 - chroot failed +# 0 - chroot succeeded +cat > chroot_test.c << EOF +#include <unistd.h> +int main(int argc, char *argv[]) { + if (argc != 2) + return 2; + return (chroot(argv[1]) == -1); +} +EOF + +gcc -o chroot_test chroot_test.c + +# The following should just run chroot_test since pseudo is already loaded +./bin/pseudo ./chroot_test `pwd` + +if [ "$?" = "0" ] +then + #echo "Passed." + rm -f chroot_test chroot_test.c + exit 0 +fi +#echo "Failed" +rm -f chroot_test chroot_test.c +exit 1 |