[Logwatch] 3.2 sendmail issue

Kenneth Porter shiva@sewingwitch.com
26 Jun 2002 18:15:09 -0700


--=-9HSsv4frSr5No0i4ZLt0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

As promised, the patch. This adds the expression for the alternate black
hole logging, and it also sorts keys in all report loops to make it
easier to see when multiple entries are from related domains. The
sorting has not been exhaustively tested.

--=-9HSsv4frSr5No0i4ZLt0
Content-Disposition: inline; filename=sendmail.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=sendmail.diff; charset=ISO-8859-1

--- sendmail.3.2	Tue Jun 18 12:18:32 2002
+++ sendmail	Wed Jun 26 18:09:35 2002
@@ -97,6 +97,9 @@
    } elsif ( ($Relay,$BlSite) =3D ($ThisLine =3D~ /^ruleset=3Dcheck_relay,=
 arg1=3D[^,]*, arg2=3D[^,]*, relay=3D([^,]*), reject=3D550\s*[\d.]*\s*Mail =
from [^ ]* refused by blackhole site (.*)/) ) {
       $Temp =3D "From " . $Relay . " by " . $BlSite;
       $BlackHoled{$Temp}++;
+   } elsif ( ($Relay,$BlSite) =3D ($ThisLine =3D~ /^ruleset=3Dcheck_rcpt, =
arg1=3D[^,]*, relay=3D([^,]*), reject=3D550\s*[\d.]*\s*<[^ ]*>\.\.\. Mail f=
rom [^ ]* refused by blackhole site ([^ ]*)/) ) {
+      $Temp =3D "From " . $Relay . " by " . $BlSite;
+      $BlackHoled{$Temp}++;
    } elsif ( ($User) =3D ($ThisLine =3D~ /^ruleset=3Dcheck_mail, arg1=3D<(=
[^ ]*)>, relay=3D[^,]*, reject=3D451\s*[\d.]*\s*Domain of sender address [^=
 ]* does not resolve/) ) {
       $DomainErrors{$User . ": (does not resolve)"}++;
    } elsif ( ($User) =3D ($ThisLine =3D~ /^ruleset=3Dcheck_mail, arg1=3D<(=
[^ ]*)>, relay=3D[^,]*, reject=3D553\s*[\d.]*\s*<[^ ]*>\.\.\. Domain of sen=
der address [^ ]* does not exist/) ) {
@@ -177,42 +180,42 @@
=20
    if (keys %UnknownUsers) {
       print "\n\nUnknown users:\n";
-      foreach $ThisOne (keys %UnknownUsers) {
+      foreach $ThisOne (sort keys %UnknownUsers) {
          print "    " . $ThisOne . ": " . $UnknownUsers{$ThisOne} . " Time=
s(s)\n";
       }
    }
=20
    if (keys %RelayDenied) {
       print "\n\nRelaying denied:\n";
-      foreach $ThisOne (keys %RelayDenied) {
+      foreach $ThisOne (sort keys %RelayDenied) {
          print "    " . $ThisOne . ": " . $RelayDenied{$ThisOne} . " Times=
(s)\n";
       }
    }
=20
    if (keys %BlackHoled) {
       print "\n\nBlackholed:\n";
-      foreach $ThisOne (keys %BlackHoled) {
+      foreach $ThisOne (sort keys %BlackHoled) {
          print "    " . $ThisOne . ": " . $BlackHoled{$ThisOne} . " Times(=
s)\n";
       }
    }
=20
    if (keys %DomainErrors) {
       print "\n\nUnresolveable or non-existent domains:\n";
-      foreach $ThisOne (keys %DomainErrors) {
+      foreach $ThisOne (sort keys %DomainErrors) {
          print "    " . $ThisOne . ": " . $DomainErrors{$ThisOne} . " Time=
s(s)\n";
       }
    }
=20
    if (keys %AuthWarns) {
       print "\n\nAuthentication warnings:\n";
-      foreach $ThisOne (keys %AuthWarns) {
+      foreach $ThisOne (sort keys %AuthWarns) {
          print "    " . $ThisOne . ": " . $AuthWarns{$ThisOne} . " Times(s=
)\n";
       }
    }
=20
    if (keys %ForwardErrors) {
       print "\n\nForwarding errors:\n";
-      foreach $ThisOne (keys %ForwardErrors) {
+      foreach $ThisOne (sort keys %ForwardErrors) {
          print "    " . $ThisOne . ": " . $ForwardErrors{$ThisOne} . " Tim=
es(s)\n";
       }
    }
@@ -225,11 +228,11 @@
    }
 	if (keys %relay) {
 		print "\n\nWe do not relay for these (host,ruser,luser):\n";
-      foreach $host (keys %relay) {
+      foreach $host (sort keys %relay) {
 			print "\n    $host\n";
-			foreach $ruser (keys %{ $relay{$host} }) {
+			foreach $ruser (sort keys %{ $relay{$host} }) {
 				print "      $ruser\n";
-				foreach $luser (keys %{$relay{$host}{$ruser}}) {
+				foreach $luser (sort keys %{$relay{$host}{$ruser}}) {
 					printf "            %-30s %i \n",$luser,$relay{$host}{$ruser}{$luser}=
;
 				}
 			}
@@ -237,9 +240,9 @@
    }
    if (keys %notLocal) {
       print "\n\nAddress not local from these (host, user): \n";
-      foreach $host (keys %notLocal ) {
+      foreach $host (sort keys %notLocal ) {
 			print "\n    $host\n";
-			foreach $luser (keys %{ $notLocal{$host} }) {
+			foreach $luser (sort keys %{ $notLocal{$host} }) {
 				printf "     %-30s %i \n",$luser,$notLocal{$host}{$luser};
 			}
 		}
@@ -247,10 +250,10 @@
 	my $total;
 	if (keys %abuse) {
 		print "\n\nrejected VRFY (host,ruser):\n";
-      foreach $host (keys %abuse) {
+      foreach $host (sort keys %abuse) {
 			print "\n    $host\n";
 			$total=3D0;
-			foreach $luser (keys %{$abuse{$host}}) {
+			foreach $luser (sort keys %{$abuse{$host}}) {
 				print "       $luser\n";
 				$total+=3D$abuse{$host}{$luser};
 			}

--=-9HSsv4frSr5No0i4ZLt0--