]>
Commit | Line | Data |
---|---|---|
34b491e7 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" | |
5 | . "$TESTDIR/framework" | |
6 | ||
7 | setupenvironment | |
8 | configarchitecture 'amd64' | |
9 | ||
10 | aptdropprivs() { runapt "${APTTESTHELPERSBINDIR}/aptdropprivs" "$@"; } | |
11 | ||
12 | testsuccess aptdropprivs -- /bin/true | |
13 | testsuccess aptdropprivs --user "$USER" -- /bin/true | |
14 | testsuccess aptdropprivs --user 'nobody' -- /bin/true | |
15 | testsuccess aptdropprivs --user '_apt' -- /bin/true | |
16 | ||
17 | IDBIN='/usr/bin/id' | |
18 | testsuccessequal "$("$IDBIN")" aptdropprivs --user "$USER" -- "$IDBIN" | |
19 | ||
20 | SUDOBIN='/usr/bin/sudo' | |
21 | testequal "sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?" aptdropprivs --user 'nobody' -- "$SUDOBIN" "$IDBIN" | |
22 | ||
23 | if [ "$(id -u)" = '0' ]; then | |
24 | testsuccessequal '_apt' aptdropprivs --user '_apt' -- "$IDBIN" '-un' | |
25 | testsuccess aptdropprivs --user '_apt' -- '/bin/sh' '-c' 'export' | |
26 | cp rootdir/tmp/testsuccess.output apt.env | |
27 | testsuccessequal "export HOME='/nonexistent'" grep '^export HOME' apt.env | |
28 | testsuccessequal "export USER='_apt' | |
29 | export USERNAME='_apt'" grep '^export USER' apt.env | |
30 | testsuccessequal "export LOGNAME='_apt'" grep '^export LOGNAME' apt.env | |
31 | testsuccessequal "export SHELL='/bin/sh'" grep '^export SHELL=' apt.env | |
32 | fi |