pthread-once tests: Fix crash on mingw.
[gnulib.git] / tests / test-idpriv-drop.sh
blobc5689b16bc35c760748f50e5b4d7615610e07199
1 #!/bin/sh
3 # A POSIX compliant 'id' program.
4 if test -f /usr/xpg4/bin/id; then
5 ID=/usr/xpg4/bin/id
6 else
7 ID=id
8 fi
10 # The user's original uid and gid.
11 uid=`$ID -u`
12 gid=`$ID -g`
14 if test `$ID -u` = 0; then
15 # No need to ask for a password.
16 "${srcdir}/test-idpriv-drop.su.sh" "$uid" "$gid"
17 else
18 echo "Need root privileges for the 'test-idpriv-drop' test. Deny if you don't trust." > /dev/tty
19 if (type sudo) > /dev/null 2>&1; then
20 # Use the 'sudo' program.
21 sudo "${srcdir}/test-idpriv-drop.su.sh" "$uid" "$gid"
22 else
23 # Use the 'su' program.
24 su root -c "${srcdir}/test-idpriv-drop.su.sh \"$uid\" \"$gid\""
26 result=$?
27 case $result in
28 0) exit 0;;
29 77) exit 77;;
30 13) exit 1;;
31 *) echo "Skipping test: root privileges not granted"; exit 77;;
32 esac