summaryrefslogtreecommitdiff
path: root/gnulib/tests/test-idpriv-droptemp.sh
diff options
context:
space:
mode:
Diffstat (limited to 'gnulib/tests/test-idpriv-droptemp.sh')
m---------gnulib0
-rwxr-xr-xgnulib/tests/test-idpriv-droptemp.sh33
2 files changed, 33 insertions, 0 deletions
diff --git a/gnulib b/gnulib
deleted file mode 160000
-Subproject 443bc5ffcf7429e557f4a371b0661abe98ddbc1
diff --git a/gnulib/tests/test-idpriv-droptemp.sh b/gnulib/tests/test-idpriv-droptemp.sh
new file mode 100755
index 0000000..9b1b822
--- /dev/null
+++ b/gnulib/tests/test-idpriv-droptemp.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# A POSIX compliant 'id' program.
+if test -f /usr/xpg4/bin/id; then
+ ID=/usr/xpg4/bin/id
+else
+ ID=id
+fi
+
+# The user's original uid and gid.
+uid=`$ID -u`
+gid=`$ID -g`
+
+if test `$ID -u` = 0; then
+ # No need to ask for a password.
+ "${srcdir}/test-idpriv-droptemp.su.sh" "$uid" "$gid"
+else
+ echo "Need root privileges for the 'test-idpriv-droptemp' test. Deny if you don't trust." > /dev/tty
+ if (type sudo) > /dev/null 2>&1; then
+ # Use the 'sudo' program.
+ sudo "${srcdir}/test-idpriv-droptemp.su.sh" "$uid" "$gid"
+ else
+ # Use the 'su' program.
+ su root -c "${srcdir}/test-idpriv-droptemp.su.sh \"$uid\" \"$gid\""
+ fi
+ result=$?
+ case $result in
+ 0) exit 0;;
+ 77) exit 77;;
+ 13) exit 1;;
+ *) echo "Skipping test: root privileges not granted"; exit 77;;
+ esac
+fi