diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-11-06 15:35:15 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-12-15 13:10:57 -0500 |
commit | fd0c6671d13333f2ddb41e792b40162c841adae6 (patch) | |
tree | 4bb4a74576089a101af75e71745c993655da301b /src/test/test_switch_id.sh | |
parent | e8cc839e41adc4975a61fee62abe7f6664fd0c0e (diff) | |
download | tor-fd0c6671d13333f2ddb41e792b40162c841adae6.tar.gz tor-fd0c6671d13333f2ddb41e792b40162c841adae6.zip |
Add unit tests for switch_id(), including tests for capabilities
Diffstat (limited to 'src/test/test_switch_id.sh')
-rwxr-xr-x | src/test/test_switch_id.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/test_switch_id.sh b/src/test/test_switch_id.sh new file mode 100755 index 0000000000..1b4e0998b5 --- /dev/null +++ b/src/test/test_switch_id.sh @@ -0,0 +1,25 @@ +#!/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 + +"${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 + + +echo "All okay" + +exit 0 |