use world readable log dir if running as root master
authorIan Kelling <iank@fsf.org>
Wed, 9 Oct 2024 05:48:25 +0000 (01:48 -0400)
committerIan Kelling <iank@fsf.org>
Wed, 9 Oct 2024 05:48:25 +0000 (01:48 -0400)
sysd-mail-once

index 2c9d0263748e9b715acddb5bf3c0d57d28bb1dd9..a3eb11d12e88767c7a70ea02fa535619eb5dcf01 100755 (executable)
@@ -26,8 +26,13 @@ set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 errors=3
 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
 to=root
 dryrun=false
 print_all=false