[Logwatch-Devel] Support for bzip2'ed logfiles.

Laurent Fousse laurent at cabal.lateralis.org
Sat May 27 04:46:17 MST 2006


Hello,

I've switched my exim logfile archives format from gzip to bzip2, and
I had one report full of garbage. I thought I could be lucky and
logwatch would already support bzip2, but it doesn't. So here's a
patch that adds this support (yet untested, waiting to tomorrow's
report).

Laurent.
-------------- next part --------------
--- logwatch.pl	2006-05-27 13:34:06.000000000 +0200
+++ logwatch.pl.new	2006-05-27 13:34:39.000000000 +0200
@@ -74,6 +74,7 @@
 $Config{'numeric'} = 0;
 $Config{'pathtocat'} = "cat";
 $Config{'pathtozcat'} = "zcat";
+$Config{'pathtobzcat'} = "bzcat";
 $Config{'output'} = "unformatted";
 $Config{'encode'} = 0;
 
@@ -842,6 +843,13 @@
             my $arguments = "$Archive 2>/dev/null >> $DestFile";
             system("$Config{'pathtozcat'} $arguments") == 0
                or die "system $Config{'pathtozcat'} failed: $?" 
+         } elsif (($Archive =~ m/bz2$/) && (-e "$Archive")) {
+         #These system calls are not secure but we are getting closer
+         #What needs to go is all the pipes and instead we need a command loop
+         #For each filter to apply -mgt
+            my $arguments = "$Archive 2>/dev/null >> $DestFile";
+            system("$Config{'pathtobzcat'} $arguments") == 0
+               or die "system $Config{'pathtobzcat'} failed: $?" 
          } elsif (-e "$Archive") {
             my $arguments = "$Archive 2>/dev/null >> $DestFile";
             system("$Config{'pathtocat'} $arguments") == 0


More information about the Logwatch-Devel mailing list