test_switch_id.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. if test "`id -u`" != '0'; then
  3. echo "This test only works when run as root. Skipping." >&2
  4. exit 77
  5. fi
  6. if test "`id -u nobody`" = ""; then
  7. echo "This test requires that your system have a 'nobody' user. Sorry." >&2
  8. exit 1
  9. fi
  10. if test "$OVERRIDE_GCDA_PERMISSIONS_HACK" = "yes"; then
  11. find src -type f -name '*gcda' -print0 | xargs -0 chmod 0666
  12. fi
  13. "${builddir:-.}/src/test/test-switch-id" nobody setuid || exit 1
  14. "${builddir:-.}/src/test/test-switch-id" nobody root-bind-low || exit 1
  15. "${builddir:-.}/src/test/test-switch-id" nobody setuid-strict || exit 1
  16. "${builddir:-.}/src/test/test-switch-id" nobody built-with-caps || exit 0
  17. # ... Go beyond this point only if we were built with capability support.
  18. "${builddir:-.}/src/test/test-switch-id" nobody have-caps || exit 1
  19. "${builddir:-.}/src/test/test-switch-id" nobody setuid-keepcaps || exit 1
  20. if test "$OVERRIDE_GCDA_PERMISSIONS_HACK" = "yes"; then
  21. find src -type f -name '*gcda' -print0 | xargs -0 chmod 0644
  22. fi
  23. echo "All okay"
  24. exit 0