openat: don’t close (-1)
[gnulib.git] / tests / test-idpriv-droptemp.sh
blob9b1b822836de37b163b99251a49106ad597351f2
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-droptemp.su.sh" "$uid" "$gid"
17 else
18 echo "Need root privileges for the 'test-idpriv-droptemp' 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-droptemp.su.sh" "$uid" "$gid"
22 else
23 # Use the 'su' program.
24 su root -c "${srcdir}/test-idpriv-droptemp.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