Add support for zstd-compressed log files

- Resolves: RHEL-102044
This commit is contained in:
Pavel Simovec 2025-07-15 16:49:01 +02:00
parent 831e1630dd
commit fb627bb4cf
2 changed files with 47 additions and 1 deletions

View File

@ -2,11 +2,12 @@
Summary: Analyzes and Reports on system logs
Name: logwatch
Version: 7.11
Release: 2%{?dist}
Release: 3%{?dist}
License: MIT
URL: https://sourceforge.net/projects/logwatch/
Source0: https://sourceforge.net/projects/logwatch/files/%{name}-%{version}/%{name}-%{version}.tar.gz
Patch0: sshd-sort-by-count.patch
Patch1: zstd-log-support.patch
BuildRequires: perl-generators
Requires: grep
Requires: perl(Date::Manip)
@ -130,6 +131,10 @@ echo "# Configuration overrides for specific logfiles/services may be placed her
%{_unitdir}/logwatch.timer
%changelog
* Tue Jul 15 2025 Pavel Simovec <psimovec@redhat.com> - 7.11-3
- Add support for zstd-compressed log files
- Resolves: RHEL-102044
* Wed Nov 27 2024 Pavel Simovec <psimovec@redhat.com> - 7.11-2
- sshd: sort IP adresses by report count
- Resolves: RHEL-58995

41
zstd-log-support.patch Normal file
View File

@ -0,0 +1,41 @@
diff --color -urN a/conf/logwatch.conf b/conf/logwatch.conf
--- a/conf/logwatch.conf 2025-07-15 12:47:54.895159550 +0200
+++ b/conf/logwatch.conf 2025-07-15 16:35:29.127282999 +0200
@@ -191,5 +191,6 @@
# PathTozcat = "zcat"
# PathTobzcat = "bzcat"
# PathToxzcat = "zxcat"
+# PathTozstdcat = "zstdcat"
# vi: shiftwidth=3 tabstop=3 et
diff --color -urN a/scripts/logwatch.pl b/scripts/logwatch.pl
--- a/scripts/logwatch.pl 2025-07-15 12:47:54.869744800 +0200
+++ b/scripts/logwatch.pl 2025-07-15 16:34:26.473278680 +0200
@@ -96,6 +96,7 @@
$Config{'pathtozcat'} = "zcat";
$Config{'pathtobzcat'} = "bzcat";
$Config{'pathtoxzcat'} = "xzcat";
+$Config{'pathtozstdcat'} = "zstdcat";
$Config{'output'} = "stdout"; #8.0
$Config{'format'} = "text"; #8.0
$Config{'encode'} = "none"; #8.0
@@ -746,7 +747,7 @@
# Handle compressed log files using the archive codepath
foreach my $lf (@{$LogFileData{$LogFile}{'logfiles'}}) {
- if ($lf =~ /\.(?:gz|bz2|xz)$/) {
+ if ($lf =~ /\.(?:gz|bz2|xz|zst)$/) {
push @{$LogFileData{$LogFile}{'archives'}}, $lf;
} else {
push @FileList, $lf;
@@ -798,6 +799,10 @@
my $arguments = "'${Archive}' 2>/dev/null >> $DestFile";
system("$Config{'pathtoxzcat'} $arguments") == 0
or die "system '$Config{'pathtoxzcat'} $arguments' failed: $?"
+ } elsif (($Archive =~ m/zst$/) && (-f "$Archive") && (-s "$Archive")) {
+ my $arguments = "'${Archive}' 2>/dev/null >> $DestFile";
+ system("$Config{'pathtozstdcat'} $arguments") == 0
+ or die "system '$Config{'pathtozstdcat'} $arguments' failed: $?"
} elsif ((-f "$Archive") && (-s "$Archive")) {
my $arguments = "'${Archive}' >> $DestFile";
system("$Config{'pathtocat'} $arguments") == 0