annotate tests/test-idpriv-drop.su.sh @ 40221:8c1a17df67e0

tests: Prepare for using valgrind. tests/*.sh: Invoke all test programs through ${CHECKER}. tests/*/*.sh: Likewise.
author Bruno Haible <bruno@clisp.org>
date Sun, 10 Mar 2019 11:32:11 +0100
parents 1202c081f797
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11614
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 #!/bin/sh
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 # This script must be run as superuser.
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 origuid=$1
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 origgid=$2
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 # A POSIX compliant 'id' program.
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 if test -f /usr/xpg4/bin/id; then
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 ID=/usr/xpg4/bin/id
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 else
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 ID=id
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 fi
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 if test `$ID -u` != 0; then
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 echo "Skipping test: not superuser"
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 exit 77
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 fi
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
40221
8c1a17df67e0 tests: Prepare for using valgrind.
Bruno Haible <bruno@clisp.org>
parents: 13444
diff changeset
19 ${CHECKER} ./test-idpriv-drop${EXEEXT} || exit 13 # normal
11614
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 chown root:root test-idpriv-drop${EXEEXT} 2>/dev/null || \
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 chown root:wheel test-idpriv-drop${EXEEXT} 2>/dev/null || \
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 { echo "Skipping test: root privilege not sufficient on this file system"
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 exit 77
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 }
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 chmod 4755 test-idpriv-drop${EXEEXT}
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 ./test-idpriv-drop${EXEEXT} || exit 13 # setuid root
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 chmod 2755 test-idpriv-drop${EXEEXT}
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 ./test-idpriv-drop${EXEEXT} || exit 13 # setgid root
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 chmod 6755 test-idpriv-drop${EXEEXT}
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 ./test-idpriv-drop${EXEEXT} || exit 13 # setuid and setgid root
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 if chown nobody test-idpriv-drop${EXEEXT} 2>/dev/null; then
13444
1202c081f797 idpriv-drop: Fix tests.
Ian Beckwith <ianb@erislabs.net>
parents: 11614
diff changeset
34 chmod 4755 test-idpriv-drop${EXEEXT}
1202c081f797 idpriv-drop: Fix tests.
Ian Beckwith <ianb@erislabs.net>
parents: 11614
diff changeset
35 ./test-idpriv-drop${EXEEXT} || exit 13 # setuid nobody
1202c081f797 idpriv-drop: Fix tests.
Ian Beckwith <ianb@erislabs.net>
parents: 11614
diff changeset
36 chmod 2755 test-idpriv-drop${EXEEXT}
1202c081f797 idpriv-drop: Fix tests.
Ian Beckwith <ianb@erislabs.net>
parents: 11614
diff changeset
37 ./test-idpriv-drop${EXEEXT} || exit 13 # setgid root
1202c081f797 idpriv-drop: Fix tests.
Ian Beckwith <ianb@erislabs.net>
parents: 11614
diff changeset
38 chmod 6755 test-idpriv-drop${EXEEXT}
1202c081f797 idpriv-drop: Fix tests.
Ian Beckwith <ianb@erislabs.net>
parents: 11614
diff changeset
39 ./test-idpriv-drop${EXEEXT} || exit 13 # setuid nobody and setgid root
11614
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 fi
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 if chown root:nobody test-idpriv-drop${EXEEXT} 2>/dev/null; then
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 chmod 4755 test-idpriv-drop${EXEEXT}
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 ./test-idpriv-drop${EXEEXT} || exit 13 # setuid root
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 chmod 2755 test-idpriv-drop${EXEEXT}
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 ./test-idpriv-drop${EXEEXT} || exit 13 # setgid nobody
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 chmod 6755 test-idpriv-drop${EXEEXT}
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 ./test-idpriv-drop${EXEEXT} || exit 13 # setuid root and setgid nobody
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 fi
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 chown "$origuid:$origgid" test-idpriv-drop${EXEEXT}
b3e5d914be7d Tests for module 'idpriv-drop'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 chmod 755 test-idpriv-drop${EXEEXT}