mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 13:43:47 +01:00
5fbd195918
This hack provides a way to make sure we can see coverage from test-switch-id. If you set OVERRIDE_GCDA_PERMISSIONS_HACK, we temporarily make the .gcda files mode 0666 before we run the test scripts, and then we set them to 0644 again afterwards. That's necessary because the test_switch_id.sh script does a setuid() to 'nobody' part way through, and drops the ability to change its mind back.
33 lines
1.0 KiB
Bash
Executable File
33 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if test "`id -u`" != '0'; then
|
|
echo "This test only works when run as root. Skipping." >&2
|
|
exit 77
|
|
fi
|
|
|
|
if test "`id -u nobody`" = ""; then
|
|
echo "This test requires that your system have a 'nobody' user. Sorry." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if test "$OVERRIDE_GCDA_PERMISSIONS_HACK" = "yes"; then
|
|
find src -type f -name '*gcda' -print0 | xargs -0 chmod 0666
|
|
fi
|
|
|
|
"${builddir:-.}/src/test/test-switch-id" nobody setuid || exit 1
|
|
"${builddir:-.}/src/test/test-switch-id" nobody root-bind-low || exit 1
|
|
"${builddir:-.}/src/test/test-switch-id" nobody setuid-strict || exit 1
|
|
"${builddir:-.}/src/test/test-switch-id" nobody built-with-caps || exit 0
|
|
# ... Go beyond this point only if we were built with capability support.
|
|
|
|
"${builddir:-.}/src/test/test-switch-id" nobody have-caps || exit 1
|
|
"${builddir:-.}/src/test/test-switch-id" nobody setuid-keepcaps || exit 1
|
|
|
|
if test "$OVERRIDE_GCDA_PERMISSIONS_HACK" = "yes"; then
|
|
find src -type f -name '*gcda' -print0 | xargs -0 chmod 0644
|
|
fi
|
|
|
|
echo "All okay"
|
|
|
|
exit 0
|