9cfb1ea
From f7333277c2709b147e2f2a3ab357ec3a195fb1f5 Mon Sep 17 00:00:00 2001
9cfb1ea
From: Chris Dunlap <cdunlap@llnl.gov>
9cfb1ea
Date: Fri, 4 Dec 2020 21:31:34 -0800
9cfb1ea
Subject: [PATCH 2/4] Sharness: Fix dup of failing check when run by root
9cfb1ea
9cfb1ea
When the test suite is run by root, the following two failures occur in
9cfb1ea
"0103-munged-security-logfile.t":
9cfb1ea
9cfb1ea
  10 - logfile not writable by user failure
9cfb1ea
  31 - logfile failure writes single message to stderr
9cfb1ea
9cfb1ea
This second test, "logfile failure writes single message to stderr",
9cfb1ea
checks for a regression of a duplicate error message being written to
9cfb1ea
stderr by forcing an expected failure -- namely, setting the logfile
9cfb1ea
perms to 0400 and expecting an error when opening the logfile because
9cfb1ea
the user does not have write-permissions.  This expected failure is
9cfb1ea
the check being performed in the first test, "logfile not writable
9cfb1ea
by user failure".
9cfb1ea
9cfb1ea
Fix the test for "logfile failure writes single message to stderr"
9cfb1ea
by forcing a different error that is not affected by root privileges.
9cfb1ea
In particular, set the logfile perms to 0602 which will fail because
9cfb1ea
the logfile is now writable by other; this will fail regardless of
9cfb1ea
whether or not the user is root.
9cfb1ea
9cfb1ea
Tested:
9cfb1ea
- Arch Linux
9cfb1ea
- CentOS Stream 8, 8.3.2011, 7.9.2009, 6.10
9cfb1ea
- Debian sid, 10.8, 9.13, 8.11, 7.11, 6.0.10, 5.0.10, 4.0
9cfb1ea
- Fedora 33, 32, 31
9cfb1ea
- FreeBSD 12.2, 11.4
9cfb1ea
- NetBSD 9.1, 9.0, 8.1
9cfb1ea
- OpenBSD 6.8, 6.7, 6.6
9cfb1ea
- openSUSE 15.2, 15.1
9cfb1ea
- Raspberry Pi OS (Raspbian 10) [armv7l]
9cfb1ea
- Ubuntu 20.10, 20.04.2 LTS, 18.04.5 LTS, 16.04.7 LTS, 14.04.6 LTS, 12.04.5 LTS
9cfb1ea
---
9cfb1ea
 t/0103-munged-security-logfile.t | 8 +++++---
9cfb1ea
 1 file changed, 5 insertions(+), 3 deletions(-)
9cfb1ea
9cfb1ea
diff --git a/t/0103-munged-security-logfile.t b/t/0103-munged-security-logfile.t
9cfb1ea
index fafd973..40b59a6 100755
9cfb1ea
--- a/t/0103-munged-security-logfile.t
9cfb1ea
+++ b/t/0103-munged-security-logfile.t
9cfb1ea
@@ -343,14 +343,16 @@ test_expect_success 'logfile dir writable by other with sticky bit' '
9cfb1ea
     chmod 0755 "${MUNGE_LOGDIR}"
9cfb1ea
 '
9cfb1ea
 
9cfb1ea
-# Check for a regression of a duplicate error message being written to stderr
9cfb1ea
-#   for a failure to open the logfile.
9cfb1ea
+# Check for a regression of a duplicate error message being written to stderr.
9cfb1ea
+# To generate an error, test for the logfile being writable by other since this
9cfb1ea
+#   will not be affected by root privileges.
9cfb1ea
+#
9cfb1ea
 ##
9cfb1ea
 test_expect_success 'logfile failure writes single message to stderr' '
9cfb1ea
     local ERR NUM &&
9cfb1ea
     rm -f "${MUNGE_LOGFILE}" &&
9cfb1ea
     touch "${MUNGE_LOGFILE}" &&
9cfb1ea
-    chmod 0400 "${MUNGE_LOGFILE}" &&
9cfb1ea
+    chmod 0602 "${MUNGE_LOGFILE}" &&
9cfb1ea
     test_must_fail munged_start_daemon t-keep-logfile 2>err.$$ &&
9cfb1ea
     cat err.$$ &&
9cfb1ea
     ERR=$(sed -n -e "s/.*Error: //p" err.$$ | sort | uniq -c | sort -n -r) &&
9cfb1ea
-- 
9cfb1ea
2.30.0
9cfb1ea