aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2011-10-26 16:51:34 -0500
committerPeter Seebach <peter.seebach@windriver.com>2011-11-02 13:31:41 -0500
commit6177474388f243c9ff783da074a531ef8fd173fd (patch)
tree8f3df61d79586d6a737e08d4a12f25b606871b5e /test
parent4a646c8bbe73ca830cb8c2e80be4b457d925cdd4 (diff)
downloadpseudo-6177474388f243c9ff783da074a531ef8fd173fd.tar.gz
pseudo-6177474388f243c9ff783da074a531ef8fd173fd.tar.bz2
pseudo-6177474388f243c9ff783da074a531ef8fd173fd.zip
Implement PSEUDO_UNLOAD, replacing existing PSEUDO_RELOADED semantics.
Change from internal PSEUDO_RELOADED to external PSEUDO_UNLOAD environment variable. Enable external programs to have a safe and reliable way to unload pseudo on the next exec*. PSEUDO_UNLOAD also will disable pseudo if we're in a fork/clone situation in the same way PSEUDO_DISABLED=1 would. Rename the PSEUDO_DISABLED tests, and create a similar set for the new PSEUDO_UNLOAD. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/test-chroot.sh27
-rwxr-xr-xtest/test-pseudo_disable-fork-env_i.sh (renamed from test/test-forkoff-env_i.sh)0
-rwxr-xr-xtest/test-pseudo_disable-fork.sh (renamed from test/test-forkoff.sh)0
-rwxr-xr-xtest/test-pseudo_unload-fork-env_i.sh29
-rwxr-xr-xtest/test-pseudo_unload-fork.sh18
-rwxr-xr-xtest/test-reexec-chroot.sh30
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