Re: milter-greylist patch for logwatch

Phil Hollenback <[email protected]>
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Ugo Bellavance <ugob <at> camo-route.com> writes:
> Mike Tremaine wrote:
> > On Sat, 2005-07-09 at 14:47, Sean Sheedy wrote:
> >> Here are 3 patches I've applied to logwatch on my Fedora Core 3 system.
> >> I hope you find them useful.
> >
> > Thanks! We've done a few releases since Fedora 3 so you might want to
> > check out the lastest stable rpm from logwatch.org [or even better get
> > it from CVS]
> >
> >> sendmail.diff:  Handle log messages from enabling the greet_pause
> >> feature in sendmail, and from the milter-greylist sendmail milter.
> >>
> >
> > PreGreeting should already be in... Greylisting is not so I'll take a
> > look at this one, Bjorn coded a nice way of adding milter counts so this
> > might be the place to catch it. [Ofcourse there are lots of different
> > approaches to greylists.]
>
> 	has the section about milter-greylist been implemented yet?  I tried to
> hack it into my config, but without much success.  I could then tell
> people on the milter-greylist newsgroup, it would be very appreciated.

I noticed that milter-greylist was still missing from the 7.3.2
version of logwatch so I reworked that part of this patch to follow
the current structure.  Seems to work ok in my environment.  Here's
the patch:

--- sendmail.orig       2007-02-06 05:06:26.000000000 -0800
+++ sendmail    2007-02-06 05:40:47.000000000 -0800
@@ -281,7 +281,8 @@
 %CollectError,           %CommandUnrecognized,    %DisabledMailbox,
 %DNSMap,
 %DomainErrors,           %DummyConnection,        %ETRNs,
-%ForwardErrors,          %KnownSpammer,           %LargeHdrs,
+%ForwardErrors,          %Greylist,
+%KnownSpammer,           %LargeHdrs,
 %LargeMsgs,              %LastCmd,
 %LoadAvg,                %LostInputChannel,
 %LostQueueFile,          %LowSpace,               %MailBomber,
@@ -960,6 +961,8 @@
       ($Reason,$Address) = ($ThisLine =~ /^(8-bit character in mailbox address)
"<(.+)>"/)
    ) {
       $AddressError{$Reason}{$Address}++;
+   } elsif ( ($User) = ($ThisLine =~ /^Milter: to=<([^ ]*)>, reject=451 4\.7\.1
Greylisting in action/) ) {
+      $Greylist{$User}++;
    # file: access
    } elsif ($ThisLine =~ /ruleset=check_relay, arg1=([^,]*),.* reject=550
5\.7\.1 Access denied/) {
       # We block some particularly annoying spam domains with the
@@ -1734,6 +1737,17 @@
 }
 $TotalError[++$ErrorIndex] = 0;

+if (keys %Greylist) {
+   eval "$PrintCond" if ($Detail >= 3);
+   print "\n\nGreylisted receives:" if ($Detail >= 3);
+   foreach $ThisOne (sort keys %Greylist) {
+      print "\n    $ThisOne : $Greylist{$ThisOne} Time(s)" if ($Detail >= 5);;
+      $TotalError[$ErrorIndex] += $Greylist{$ThisOne};
+   }
+   print "\n\tTotal:  $TotalError[$ErrorIndex]" if ($Detail >= 3);
+}
+$TotalError[++$ErrorIndex] = 0;
+
 if (keys %BadRcptThrottle) {
    eval "$PrintCond" if ($Detail >= 3);
    my $BadRcptThrottleThreshold =  $ENV{'sendmail_badrcptthrottlethreshold'} ||
"1";


One further refinement would be to count the number of messages auto-whitelisted
as well, extracting from these log messages:

Feb  4 17:06:40 server sendmail[20782]: l1516YcW020782: Milter add: header:
X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by
milter-greylist-3.0 (server.example.com [192.0.34.166]); Sun, 04 Feb 2007
17:06:40 -0800 (EST)
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.