You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
1.2 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. aptdropprivs() { runapt "${APTTESTHELPERSBINDIR}/aptdropprivs" "$@"; }
  8. testsuccess aptdropprivs -- /bin/true
  9. testsuccess aptdropprivs --user "$USER" -- /bin/true
  10. testsuccess aptdropprivs --user 'nobody' -- /bin/true
  11. testsuccess aptdropprivs --user '_apt' -- /bin/true
  12. IDBIN='/usr/bin/id'
  13. testsuccessequal "$("$IDBIN")" aptdropprivs --user "$USER" -- "$IDBIN"
  14. SUDOBIN='/usr/bin/sudo'
  15. 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"
  16. if [ "$(id -u)" = '0' ]; then
  17. testsuccessequal '_apt' aptdropprivs --user '_apt' -- "$IDBIN" '-un'
  18. testsuccess aptdropprivs --user '_apt' -- '/bin/sh' '-c' 'export'
  19. cp rootdir/tmp/testsuccess.output apt.env
  20. testsuccessequal "export HOME='/nonexistent'" grep '^export HOME' apt.env
  21. testsuccessequal "export USER='_apt'
  22. export USERNAME='_apt'" grep '^export USER' apt.env
  23. testsuccessequal "export LOGNAME='_apt'" grep '^export LOGNAME' apt.env
  24. testsuccessequal "export SHELL='/bin/sh'" grep '^export SHELL=' apt.env
  25. fi