Hi,
here's the new patch...I hope it's all alright now.
And sorry about not mentioning Bernhard in the first place,
it just didn't occur to me.
Cheers,
Ondrej.
>From ec19d2d04b057ccc6f39de987c60b1ea2e4431cf Mon Sep 17 00:00:00 2001
From: Ondrej Oprala <[email protected]>
Date: Thu, 9 Aug 2012 15:40:39 +0200
Subject: [PATCH] tests: Add error checking for root-only tests running
setuidgid
* NEWS: Mention the test improvement.
* tests/init.cfg: Modify the require_root_ function to check
for setuidgid calls and proper permissions.
Improved-by: Bernhard Voelker
---
NEWS | 6 ++++++
tests/init.cfg | 16 ++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/NEWS b/NEWS
index 46d0a41..ec7526e 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,12 @@ GNU coreutils NEWS -*-
outline -*-
certain options like -a, -l, -t and -x.
[This bug was present in "the beginning".]
+** Improved tests
+
+ root-only tests now properly check for permissions of dummy
+ user $NON_ROOT_USERNAME before trying to run binaries from the
+ src dir.
+
* Noteworthy changes in release 8.18 (2012-08-12) [stable]
diff --git a/tests/init.cfg b/tests/init.cfg
index 4ff5ad4..5863450 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -341,11 +341,27 @@ or use the shortcut target of the toplevel Makefile,
fi
}
+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)}
+
+ 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"; }
--
1.7.11.2