munge/0003-Sharness-Fix-EACCES-failure-succeeding-for-root.patch
2021-04-30 09:36:47 +01:00

68 lines
2.3 KiB
Diff

From 014cff3c0ba16fc645eeceeb16eb6be8132c59fd Mon Sep 17 00:00:00 2001
From: Chris Dunlap <cdunlap@llnl.gov>
Date: Fri, 4 Dec 2020 23:50:39 -0800
Subject: [PATCH 3/4] Sharness: Fix EACCES failure succeeding for root
When the test suite is run by root, the following failure occurs in
"0103-munged-security-logfile.t":
10 - logfile not writable by user failure
This sets the logfile perms to 0400 to check for an error when the
logfile is not writable by the user. However, root will not get a
"permission denied" error here. Consequently, the expected failure
erroneously succeeds.
Add a check for whether the test is being run by the root user, and
set the ROOT prerequisite when this is true. Furthermore, add the
!ROOT prereq to the above test so it will be skipped when run by root.
Tested:
- Arch Linux
- CentOS Stream 8, 8.3.2011, 7.9.2009, 6.10
- Debian sid, 10.8, 9.13, 8.11, 7.11, 6.0.10, 5.0.10, 4.0
- Fedora 33, 32, 31
- FreeBSD 12.2, 11.4
- NetBSD 9.1, 9.0, 8.1
- OpenBSD 6.8, 6.7, 6.6
- openSUSE 15.2, 15.1
- Raspberry Pi OS (Raspbian 10) [armv7l]
- Ubuntu 20.10, 20.04.2 LTS, 18.04.5 LTS, 16.04.7 LTS, 14.04.6 LTS, 12.04.5 LTS
---
t/0103-munged-security-logfile.t | 4 +++-
t/sharness.d/10-root.sh | 6 ++++++
2 files changed, 9 insertions(+), 1 deletion(-)
create mode 100644 t/sharness.d/10-root.sh
diff --git a/t/0103-munged-security-logfile.t b/t/0103-munged-security-logfile.t
index 40b59a6..9e951b9 100755
--- a/t/0103-munged-security-logfile.t
+++ b/t/0103-munged-security-logfile.t
@@ -118,8 +118,10 @@ test_expect_success 'logfile non-regular-file override failure' '
'
# Check for an error when the logfile is not writable by user.
+# Skip this test if running as root since the root user will not get the
+# expected EACCESS failure.
##
-test_expect_success 'logfile not writable by user failure' '
+test_expect_success !ROOT 'logfile not writable by user failure' '
rm -f "${MUNGE_LOGFILE}" &&
touch "${MUNGE_LOGFILE}" &&
chmod 0400 "${MUNGE_LOGFILE}" &&
diff --git a/t/sharness.d/10-root.sh b/t/sharness.d/10-root.sh
new file mode 100644
index 0000000..5a2fd28
--- /dev/null
+++ b/t/sharness.d/10-root.sh
@@ -0,0 +1,6 @@
+##
+# Is the test being run by the root user?
+##
+if test "$(id -u)" = 0; then
+ test_set_prereq ROOT
+fi
--
2.30.0