openat: don’t close (-1)
[gnulib.git] / tests / test-idpriv-droptemp.su.sh
blob3c77e5151abfb64c7160d6695e82b08b1152bf2b
1 #!/bin/sh
2 # This script must be run as superuser.
4 origuid=$1
5 origgid=$2
7 # A POSIX compliant 'id' program.
8 if test -f /usr/xpg4/bin/id; then
9 ID=/usr/xpg4/bin/id
10 else
11 ID=id
14 if test `$ID -u` != 0; then
15 echo "Skipping test: not superuser"
16 exit 77
19 ${CHECKER} ./test-idpriv-droptemp${EXEEXT} || exit 13 # normal
21 chown root:root test-idpriv-droptemp${EXEEXT} 2>/dev/null || \
22 chown root:wheel test-idpriv-droptemp${EXEEXT} 2>/dev/null || \
23 { echo "Skipping test: root privilege not sufficient on this file system"
24 exit 77
26 chmod 4755 test-idpriv-droptemp${EXEEXT}
27 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setuid root
28 chmod 2755 test-idpriv-droptemp${EXEEXT}
29 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setgid root
30 chmod 6755 test-idpriv-droptemp${EXEEXT}
31 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setuid and setgid root
33 if chown nobody test-idpriv-droptemp${EXEEXT} 2>/dev/null; then
34 chmod 4755 test-idpriv-droptemp${EXEEXT}
35 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setuid nobody
36 chmod 2755 test-idpriv-droptemp${EXEEXT}
37 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setgid root
38 chmod 6755 test-idpriv-droptemp${EXEEXT}
39 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setuid nobody and setgid root
42 if chown root:nobody test-idpriv-droptemp${EXEEXT} 2>/dev/null; then
43 chmod 4755 test-idpriv-droptemp${EXEEXT}
44 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setuid root
45 chmod 2755 test-idpriv-droptemp${EXEEXT}
46 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setgid nobody
47 chmod 6755 test-idpriv-droptemp${EXEEXT}
48 ./test-idpriv-droptemp${EXEEXT} || exit 13 # setuid root and setgid nobody
51 chown "$origuid:$origgid" test-idpriv-droptemp${EXEEXT}
52 chmod 755 test-idpriv-droptemp${EXEEXT}