Line 0
Link Here
|
|
|
1 |
--- src/logcheck.orig 2017-07-10 17:15:49 UTC |
2 |
+++ src/logcheck |
3 |
@@ -24,17 +24,10 @@ |
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 %%PREFIX%%/sbin/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 |
- exit 1 |
13 |
-fi |
14 |
- |
15 |
-if [ ! -f /usr/bin/lockfile-create -o \ |
16 |
- ! -f /usr/bin/lockfile-remove -o \ |
17 |
- ! -f /usr/bin/lockfile-touch ]; then |
18 |
- echo "fatal: lockfile-progs is a prerequisite for logcheck, and was not found." |
19 |
+ # su -s %%LOCALBASE%%/bin/bash -c "$0 $*" logcheck |
20 |
exit 1 |
21 |
fi |
22 |
|
23 |
@@ -69,13 +62,13 @@ EVENTSSUBJECT="System Events" |
24 |
ADDTAG="no" |
25 |
|
26 |
# Set the default paths |
27 |
-RULEDIR="/etc/logcheck" |
28 |
-CONFFILE="/etc/logcheck/logcheck.conf" |
29 |
-STATEDIR="/var/lib/logcheck" |
30 |
-LOGFILES_LIST="/etc/logcheck/logcheck.logfiles" |
31 |
-LOGFILES_LIST_D="/etc/logcheck/logcheck.logfiles.d" |
32 |
-LOGFILE_FALLBACK="/var/log/syslog" |
33 |
-LOGTAIL="/usr/sbin/logtail2" |
34 |
+RULEDIR="%%ETCDIR%%" |
35 |
+CONFFILE="%%ETCDIR%%/logcheck.conf" |
36 |
+STATEDIR="%%DBDIR%%" |
37 |
+LOGFILES_LIST="%%ETCDIR%%/logcheck.logfiles" |
38 |
+LOGFILES_LIST_D="%%ETCDIR%%/logcheck.logfiles.d" |
39 |
+LOGFILE_FALLBACK="/var/log/messages" |
40 |
+LOGTAIL="%%PREFIX%%/sbin/logtail2" |
41 |
CAT="/bin/cat" |
42 |
SYSLOG_SUMMARY="/usr/bin/syslog-summary" |
43 |
|
44 |
@@ -90,20 +83,15 @@ FQDN=0 |
45 |
SORTUNIQ=0 |
46 |
SUPPORT_CRACKING_IGNORE=0 |
47 |
SYSLOGSUMMARY=0 |
48 |
-LOCKDIR=/run/lock/logcheck |
49 |
+LOCKDIR=/var/run/logcheck |
50 |
LOCKFILE="$LOCKDIR/logcheck" |
51 |
|
52 |
# Carry out the clean up tasks |
53 |
cleanup() { |
54 |
|
55 |
- if [ -n "$LOCK" ]; then |
56 |
- debug "cleanup: Killing lockfile-touch - $LOCK" |
57 |
- kill "$LOCK" && unset LOCK |
58 |
- fi |
59 |
- |
60 |
- if [ -f "$LOCKFILE.lock" ]; then |
61 |
- debug "cleanup: Removing lockfile: $LOCKFILE.lock" |
62 |
- lockfile-remove "$LOCKFILE" |
63 |
+ if [ -f "$LOCKFILE" ]; then |
64 |
+ debug "cleanup: Removing lockfile: $LOCKFILE" |
65 |
+ rm -f "$LOCKFILE" |
66 |
fi |
67 |
|
68 |
if [ -d "$TMPDIR" ]; then |
69 |
@@ -145,14 +133,9 @@ error() { |
70 |
if [ "$2" = "noclean" ]; then |
71 |
debug "error: Not removing lockfile" |
72 |
else |
73 |
- if [ -n "$LOCK" ]; then |
74 |
- debug "error: Killing lockfile-touch - $LOCK" |
75 |
- kill "$LOCK" && unset LOCK |
76 |
- fi |
77 |
- |
78 |
- if [ -f "$LOCKFILE.lock" ]; then |
79 |
- debug "error: Removing lockfile: $LOCKFILE.lock" |
80 |
- lockfile-remove "$LOCKFILE" |
81 |
+ if [ -f "$LOCKFILE" ]; then |
82 |
+ debug "error: Removing lockfile: $LOCKFILE" |
83 |
+ rm -f "$LOCKFILE" |
84 |
fi |
85 |
|
86 |
fi |
87 |
@@ -171,7 +154,7 @@ $message |
88 |
${TMPDIR:+Check temporary directory: $TMPDIR |
89 |
} |
90 |
Also verify that the logcheck user can read all files referenced in |
91 |
-/etc/logcheck/logcheck.logfiles! |
92 |
+%%ETCDIR%%/logcheck.logfiles! |
93 |
|
94 |
$(export) |
95 |
EOF |
96 |
@@ -223,7 +206,7 @@ cleanrules() { |
97 |
error "Couldn't read $x" |
98 |
fi |
99 |
done |
100 |
- for rulefile in $(run-parts --list "$dir"); do |
101 |
+ for rulefile in $(ls -1R "$dir"); do |
102 |
rulefile="$(basename "$rulefile")" |
103 |
if [ -f "${dir}/${rulefile}" ]; then |
104 |
debug "cleanrules: ${dir}/${rulefile}" |
105 |
@@ -538,9 +521,9 @@ fi |
106 |
|
107 |
# Hostname either fully qualified or not. |
108 |
if [ "$FQDN" -eq 1 ]; then |
109 |
- HOSTNAME="$(hostname --fqdn 2>/dev/null)" |
110 |
+ HOSTNAME="$(hostname -f 2>/dev/null)" |
111 |
else |
112 |
- HOSTNAME="$(hostname --short 2>/dev/null)" |
113 |
+ HOSTNAME="$(hostname -s 2>/dev/null)" |
114 |
fi |
115 |
|
116 |
# Now check for the other options |
117 |
@@ -623,30 +606,25 @@ fi |
118 |
|
119 |
trap 'cleanup' 0 |
120 |
|
121 |
-debug "Trying to get lockfile: $LOCKFILE.lock" |
122 |
+debug "Trying to get lockfile: $LOCKFILE" |
123 |
if [ ! -d "$LOCKDIR" ]; then |
124 |
mkdir -m 0755 "$LOCKDIR" |
125 |
fi |
126 |
-lockfile-create --retry 1 "$LOCKFILE" > /dev/null 2>&1 |
127 |
+lockfile -r 1 "$LOCKFILE" > /dev/null 2>&1 |
128 |
|
129 |
|
130 |
if [ $? -eq 1 ]; then |
131 |
trap 0 |
132 |
- if [ -e "${LOCKFILE}.lock" ]; then |
133 |
+ if [ -e "${LOCKFILE}" ]; then |
134 |
error "Another logcheck process is still running" "noclean" |
135 |
else |
136 |
- error "Failed to get lockfile: $LOCKFILE.lock" "noclean" |
137 |
+ error "Failed to get lockfile: $LOCKFILE" "noclean" |
138 |
fi |
139 |
- |
140 |
-else |
141 |
- debug "Running lockfile-touch $LOCKFILE.lock" |
142 |
- lockfile-touch "$LOCKFILE" & |
143 |
- LOCK="$!" |
144 |
fi |
145 |
|
146 |
# Create the secure temporary directory or exit |
147 |
-TMPDIR="$(mktemp -d -p "${TMP:-/tmp}" logcheck.XXXXXX)" \ |
148 |
- || TMPDIR="$(mktemp -d -p /var/tmp logcheck.XXXXXX)" \ |
149 |
+TMPDIR="$(mktemp -d ${TMP:-/tmp}/logcheck.XXXXXX)" \ |
150 |
+ || TMPDIR="$(mktemp -d /var/tmp/logcheck.XXXXXX)" \ |
151 |
|| error "Could not create temporary directory" |
152 |
|
153 |
# Now clean the rulefiles in the directories |