From aae99f73b30fcb53a67d9aeef5096a1d4c9b432f Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 9 Oct 2024 01:48:25 -0400 Subject: [PATCH] use world readable log dir if running as root --- sysd-mail-once | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sysd-mail-once b/sysd-mail-once index 2c9d026..a3eb11d 100755 --- a/sysd-mail-once +++ b/sysd-mail-once @@ -26,8 +26,13 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR errors=3 -tmp=(~) -cbase="${tmp[0]}/sysd-mail-once-state" +if [[ $EUID == 0 ]]; then + cbase=/var/local/sysd-mail-once +else + # (~) note: will work even if HOME is not set. + tmp=(~) + cbase="${tmp[0]}/sysd-mail-once-state" +fi to=root dryrun=false print_all=false -- 2.30.2