diff options
author | Jim Meyering <meyering@redhat.com> | 2012-09-06 12:00:16 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-09-07 11:03:24 +0200 |
commit | 51a4b04954ad5ad12de1d1b82a3603fc350a3bfa (patch) | |
tree | 075ddcfbd97b30b2d096e67d2c40eb1b4366536c /init.cfg | |
parent | 47fd706a7540e7ae3d19c625d90c28b88a8a640c (diff) | |
download | coreutils-51a4b04954ad5ad12de1d1b82a3603fc350a3bfa.tar.xz |
tests: improve checks for setuidgid-using root-only tests
* init.cfg (setuidgid_has_perm_): New function.
(require_root_): Use it.
Improved-by: Bernhard Voelker
* NEWS (Build-related): Mention the improvement.
Diffstat (limited to 'init.cfg')
-rw-r--r-- | init.cfg | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -346,11 +346,31 @@ or use the shortcut target of the toplevel Makefile, fi } +# Test whether we can run our just-built rm setuidgid-to-root, +# i.e., that $NON_ROOT_USERNAME has access to the build directory. +setuidgid_has_perm_() +{ + local rm_version=$( + setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm --version | + sed -n 'ls/.* //p' + ) + case ":$rm_version:" in + :$PACKAGE_VERSION:) ;; + *) return 1;; + esac +} + require_root_() { uid_is_privileged_ || skip_ "must be run as root" NON_ROOT_USERNAME=${NON_ROOT_USERNAME=nobody} NON_ROOT_GROUP=${NON_ROOT_GROUP=$(id -g $NON_ROOT_USERNAME)} + + # When the current test invokes setuidgid, call setuidgid_has_perm_ + # to check for a common problem. + grep '^[ ]*setuidgid' "../$0" \ + && { setuidgid_has_perm_ \ + || skip_ "user $NON_ROOT_USERNAME lacks execute permissions"; } } skip_if_root_() { uid_is_privileged_ && skip_ "must be run as non-root"; } |