diff options
author | Jim Meyering <jim@meyering.net> | 2003-07-16 08:30:06 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-07-16 08:30:06 +0000 |
commit | a0306325d29f753b690d50661e9a0b990746ac9b (patch) | |
tree | 3c1c7bb52f13c7d3defd1bb42ce40659a49cd80c /tests/priv-check | |
parent | 152d9ca5225fd52a56afff9047de80357f8c838f (diff) | |
download | coreutils-a0306325d29f753b690d50661e9a0b990746ac9b.tar.xz |
Move setuidgid-related and
NON_ROOT_USERNAME-checking code to this file.
Diffstat (limited to 'tests/priv-check')
-rw-r--r-- | tests/priv-check | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/priv-check b/tests/priv-check index b37f99632..877081790 100644 --- a/tests/priv-check +++ b/tests/priv-check @@ -13,6 +13,7 @@ priv_check_temp=priv-check.$$ touch $priv_check_temp || framework_failure=1 chmod a-w $priv_check_temp || framework_failure=1 +# FIXME: use id -u, as below -- avoiding use of a temporary file (echo foo >> $priv_check_temp) >/dev/null 2>&1 overwrite_status=$? give_msg=no @@ -35,4 +36,26 @@ EOF (exit 77); exit } +test "$PRIV_CHECK_ARG" = require-root && +{ + # When running as root, always ensure that we have a valid non-root username. + : ${NON_ROOT_USERNAME=nobody} + + # Ensure that the supplied username is valid and with UID != 0. + coreutils_non_root_uid=`setuidgid $NON_ROOT_USERNAME id -u` + test $? = 0 || \ + { + echo "$0: This command failed: \`setuidgid $NON_ROOT_USERNAME id -u'" 1>&2 + echo "$0: Skipping this test. To enable it, set the envvar" 1>&2 + echo "$0: NON_ROOT_USERNAME to a non-root user name." 1>&2 + (exit 77); exit 77 + } + test "$coreutils_non_root_uid" = 0 && \ + { + echo "$0: The specified NON_ROOT_USERNAME ($NON_ROOT_USERNAME)" 1>&2 + echo "$0: is invalid because its UID is 0." 1>&2 + (exit 1); exit 1 + } +} + rm -f $priv_check_temp |