Re: Fwd: logwatch patch

Mike Tremaine <[email protected]>
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Kirk Bauer wrote:
> ---------- Forwarded message ----------
> From: Rem Isa <[email protected]>
> Date: Wed, 14 Nov 2007 12:55:03 +0100
> Subject:
> To: [email protected]
>
> Hello,
>
> a minor patch proposal for logwatch v7.3.2, unified diff format.
> Enables logwatch to cope with empty compressed logfiles, such as
> those generated by logrotated.
>
> Enjoy,
> Remi
>
> --- logwatch.pl.org     2007-11-14 12:50:50.000000000 +0100
> +++ logwatch.pl 2007-11-14 12:51:25.000000000 +0100
> @@ -876,7 +876,7 @@
>
>        my @FileStat = stat($Archive);
>        if ($CheckTime <= ($FileStat[9])) {
> -         if (($Archive =~ m/gz$/) && (-f "$Archive")) {
> +        if (($Archive =~ m/gz$/) && (-f "$Archive") && (-
> s "$Archive")) { #Remi 14.11.2007, case of empty compressed archive
> file.
>           #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
>   

This makes sense. I committed this [expanded to all Archives] I also put 
in a --subject switch for Hugo. Here is the diff.

Rigel:~/Projects/logwatch_cvs/logwatch/scripts mgt$ cvs diff logwatch.pl
Index: logwatch.pl
===================================================================
RCS file: /var/cvs/logwatch/scripts/logwatch.pl,v
retrieving revision 1.204
diff -r1.204 logwatch.pl
69a70
 > $Config{'subject'} = "";
199c200,201
<              "html_wrap=s"  => \$Config{'html_wrap'}
---
 >              "html_wrap=s"  => \$Config{'html_wrap'},
 >              "subject=s"    => \$Config{'subject'}
733c735
<          if (($Archive =~ m/gz$/) && (-f "$Archive")) {
---
 >          if (($Archive =~ m/gz$/) && (-f "$Archive") && (-s 
"$Archive")) {
737c739
<          } elsif (($Archive =~ m/bz2$/) && (-f "$Archive")) {
---
 >          } elsif (($Archive =~ m/bz2$/) && (-f "$Archive") && (-s 
"$Archive")) {
741c743
<          } elsif (-f "$Archive") {
---
 >          } elsif ((-f "$Archive") && (-s "$Archive")) {
1106c1108,1114
<          print OUTFILE "Subject: Logwatch for $Config{'hostname'} 
(${OStitle})\n";
---
 >          #If $Config{'subject'} exists lets use it.
 >          #This does not allow for variable expansion as the default 
below does -mgt
 >          if ($Config{'subject'}) {
 >             print OUTFILE "Subject: $Config{'subject'}\n";
 >          } else {
 >             print OUTFILE "Subject: Logwatch for $Config{'hostname'} 
(${OStitle})\n";
 >          }

I have not tested it so... :) Be warned.

-Mike
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.