Skip to content

Commit

Permalink
fix(logcheck): updated patch for ubuntu-24.04 and debian-12
Browse files Browse the repository at this point in the history
  • Loading branch information
juju4 committed Dec 22, 2024
1 parent 2435169 commit 29a68e5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions files/patch-logcheck-replace3
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--- logcheck.orig 2024-11-17 17:26:14.789270872 +0000
+++ logcheck 2024-12-06 13:00:42.045819802 +0000
@@ -92,6 +92,7 @@
SORTUNIQ=0
SUPPORT_CRACKING_IGNORE=0
SYSLOGSUMMARY=0
+LINES=10000
LOCKDIR=/run/lock/logcheck
LOCKFILE="$LOCKDIR/logcheck"

@@ -335,6 +336,15 @@
--file -
return $?
else
+ outlines="$(wc -l "$TMPDIR/report" | awk '{ print $1 }')"
+ if [ "$LINES" -gt "0" ] && [ "${outlines:=0}" -gt "$LINES" ]; then
+ {
+ printf "Log output has been truncated in this mail\\n"
+ printf "Output is %d lines, truncated to %d.\\n" "$outlines" "$LINES"
+ head -n "$LINES" "$TMPDIR/report"
+ } > "$TMPDIR/report2"
+ mv "$TMPDIR/report2" "$TMPDIR/report"
+ fi
mime-construct "${MIMECONSTRUCTARGS[@]}" --subject "$subject" --to "$SENDMAILTO" "${ENCODING[@]}" \
--file "$TMPDIR/report"
fi
@@ -780,7 +790,8 @@
# First sort the logs to remove duplicate lines (including from different logfiles with
# the same lines) to reduce CPU and memory usage.
debug "Sorting logs"
-$SORT "$TMPDIR/logoutput"/* | sed -e 's/[[:space:]]\+$//' > "$TMPDIR/logoutput-sorted" \
+$SORT "$TMPDIR/logoutput"/* | sed -e 's/[[:space:]]\+$//' \
+ | sed -f /etc/logcheck/logcheck.replace > "$TMPDIR/logoutput-sorted" \
|| error "Could not save sorted log content to $TMPDIR/logoutput-sorted"
debug "After sorting, we have the following log entries to check" "$TMPDIR/logoutput-sorted"

2 changes: 1 addition & 1 deletion vars/Debian-12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ harden_sshd_crypto_mac: 'hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh

sshd_validate: 'sshd -f %s -T -C user=nobody -C host=localhost -C addr=localhost'

harden_logcheck_patch: patch-logcheck-replace2
harden_logcheck_patch: patch-logcheck-replace3

aptconf_unattended: /etc/apt/apt.conf.d/50unattended-upgrades
monitrc: /etc/monit/monitrc
Expand Down
2 changes: 1 addition & 1 deletion vars/Ubuntu-24.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ harden_sshd_crypto_cipher: 'chacha20-poly1305@openssh.com,aes256-gcm@openssh.com
harden_sshd_crypto_mac: 'hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com'
sshd_validate: 'sshd -f %s -T -C user=nobody -C host=localhost -C addr=localhost'

harden_logcheck_patch: patch-logcheck-replace2
harden_logcheck_patch: patch-logcheck-replace3

monitrc: /etc/monit/monitrc
monit_confdir: /etc/monit/conf-available
Expand Down

0 comments on commit 29a68e5

Please sign in to comment.