1--- src/logcheck.orig	2025-08-10 23:32:15 UTC
2+++ src/logcheck
3@@ -24,16 +24,16 @@ if [ "$(id -u)" = 0 ]; then
4
5 if [ "$(id -u)" = 0 ]; then
6     echo "logcheck should not be run as root. Use su to invoke logcheck:"
7-    echo "su -s /bin/bash -c \"/usr/sbin/logcheck${*:+ $*}\" logcheck"
8+    echo "su -m %%LOGCHECK_USER%% -c \"%%LOCALBASE%%/bin/bash %%LOCALBASE%%/sbin/logcheck${*:+ $*}\" logcheck"
9     echo "Or use sudo: sudo -u logcheck logcheck${*:+ $*}."
10     # you may want to uncomment that hack to let logcheck invoke itself.
11-    # su -s /bin/bash -c "$0 $*" logcheck
12+    # su -s %%LOCALBASE%%/bin/bash -c "$0 $*" logcheck
13     exit 1
14 fi
15
16-if [ ! -f /usr/bin/lockfile-create ] || \
17-   [ ! -f /usr/bin/lockfile-remove ] || \
18-   [ ! -f /usr/bin/lockfile-touch ]; then
19+if [ ! -f %%LOCALBASE%%/bin/lockfile-create ] || \
20+   [ ! -f %%LOCALBASE%%/bin/lockfile-remove ] || \
21+   [ ! -f %%LOCALBASE%%/bin/lockfile-touch ]; then
22     echo "fatal: lockfile-progs is a prerequisite for logcheck, but was not found."
23     exit 1
24 fi
25@@ -71,13 +71,13 @@ ADDTAG="no"
26 ADDTAG="no"
27
28 # Default paths
29-RULEDIR="/etc/logcheck"
30-CONFFILE="/etc/logcheck/logcheck.conf"
31-STATEDIR="/var/lib/logcheck"
32-LOGFILES_LIST="/etc/logcheck/logcheck.logfiles"
33-LOGFILES_LIST_D="/etc/logcheck/logcheck.logfiles.d"
34-LOGFILE_FALLBACK="/var/log/syslog"
35-LOGTAIL="/usr/sbin/logtail2"
36+RULEDIR="%%ETCDIR%%"
37+CONFFILE="%%ETCDIR%%/logcheck.conf"
38+STATEDIR="%%DBDIR%%"
39+LOGFILES_LIST="%%ETCDIR%%/logcheck.logfiles"
40+LOGFILES_LIST_D="%%ETCDIR%%/logcheck.logfiles.d"
41+LOGFILE_FALLBACK="/var/log/messages"
42+LOGTAIL="%%PREFIX%%/sbin/logtail2"
43 SYSLOG_SUMMARY="/usr/bin/syslog-summary"
44
45 # Defaults for options
46@@ -99,7 +99,7 @@ else
47 elif [ -d "$TMPDIR" ] && [ -w "$TMPDIR" ]; then
48 	LOCKDIR="$TMPDIR/logcheck"
49 else
50-	LOCKDIR="/tmp/logcheck"
51+	LOCKDIR=/var/run/logcheck
52 fi
53 LOCKFILE="$LOCKDIR/logcheck"
54
55@@ -191,8 +191,8 @@ logfiles specified in;
56 }
57 - verify that the logcheck user can read all
58 logfiles specified in;
59-  /etc/logcheck/logcheck.logfiles
60-  /etc/logcheck/logcheck.logfiles.d/*.logfiles
61+  %%ETCDIR%%/logcheck/logcheck.logfiles
62+  %%ETCDIR%%/logcheck/logcheck.logfiles.d/*.logfiles
63 - check the system has enough space; (df -h output follows):
64 $(df -h 2>&1|| :)
65 - check the settings (environment follows):
66@@ -245,7 +245,7 @@ cleanrules() {
67 								error "Could not read $x"
68 						fi
69 				done
70-				for rulefile in $(run-parts --list "$dir"); do
71+				for rulefile in $(ls -1R "$dir"); do
72 						rulefile="$(basename "$rulefile")"
73 						if [ -f "${dir}/${rulefile}" ]; then
74 								debug "cleanrules: ${dir}/${rulefile} -> $cleaned/$rulefile"
75@@ -511,7 +511,7 @@ logoutput() {
76 										 >> "$TMPDIR/report" || error "Could not write message about first-time check of journal to report"
77 								echo "Only recent entries (from the last 5 hours) will be checked" \
78 										 >> "$TMPDIR/report" || error "Could not write message about first-time check of journal to report"
79-								echo "If you do not wish to check the systemd journal, please see /etc/logcheck/logcheck.logfiles.d/journal.logfiles" \
80+								echo "If you do not wish to check the systemd journal, please see %%ETCDIR%%/logcheck.logfiles.d/journal.logfiles" \
81 										 >> "$TMPDIR/report" || error "Could not write message about first-time check of journal to report"
82 								offsettime="--since=-5h"
83 						fi
84@@ -597,7 +597,7 @@ if [ -r "$CONFFILE" ]; then
85
86 # Now source the config file - before things that should not be changed
87 if [ -r "$CONFFILE" ]; then
88-		# shellcheck source=/etc/logcheck/logcheck.conf
89+		# shellcheck source=%%ETCDIR%%/logcheck.conf
90 		. "$CONFFILE"
91 elif [ -f "$CONFFILE" ]; then
92 		error  "Config file $CONFFILE could not be read"
93@@ -628,9 +628,9 @@ if [ "$FQDN" -eq 1 ]; then
94
95 # HOSTNAME is either 'fully qualified' or 'short'
96 if [ "$FQDN" -eq 1 ]; then
97-		HOSTNAME="$(hostname --fqdn 2>/dev/null)"
98+		HOSTNAME="$(hostname -f 2>/dev/null)"
99 else
100-		HOSTNAME="$(hostname --short 2>/dev/null)"
101+		HOSTNAME="$(hostname -s 2>/dev/null)"
102 fi
103
104 # Now check for the other options
105@@ -735,8 +735,8 @@ fi
106 fi
107
108 # Create a secure temporary working directory (or exit)
109-TMPDIR="$(mktemp -d -p "${TMP:-/tmp}" logcheck.XXXXXX)" \
110-		|| TMPDIR="$(mktemp -d -p /var/tmp logcheck.XXXXXX)" \
111+TMPDIR="$(mktemp -d ${TMP:-/tmp}/logcheck.XXXXXX)" \
112+		|| TMPDIR="$(mktemp -d /var/tmp/logcheck.XXXXXX)" \
113 		|| error "Could not create temporary directory"
114
115 debug "Using working dir: $TMPDIR"
116