[Logwatch-Devel] Sendmail Unknown Users Patch
Erik Ogan
erik@ogan.net
Sun, 30 Mar 2003 11:09:14 -0600
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigDBAE0923F289C88C6311FBA7
Content-Type: multipart/mixed;
boundary="------------080402020409090908070607"
This is a multi-part message in MIME format.
--------------080402020409090908070607
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Erik Ogan wrote:
> Oh, this patch will fail for anyone who hasn't applied my previous 2. If
> you'd like this one but don't really want the other two, drop me a line
> & I'll create one from the base logwatch distribution.
<blush> This is what I get for not doing enough testing after
my last-minute change before I made the patch.
The patch I submitted has a scoping error. (<pulpit>I feel it
necessary to point out that it would cause a *COMPILE* time
error (that I would have caught) rather than a runtime bug if
"use strict" was in effect.</pulpit>)
The *CORRECT* (tested) patch is included with this message.
-e
--
Erik R. Ogan Mercenary Developer
PGP Key: http://erik.ogan.net/PGP.txt 0 o . _O-d
PGP Fingerprint: A3DB 678A 4737 32E7 F703 DC3A 6BFE 2BBC 4F41 A371
--------------080402020409090908070607
Content-Type: text/plain;
name="s.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="s.patch"
diff -u -r1.2 sendmail
--- log.d/scripts/services/sendmail 29 Mar 2003 16:49:38 -0000 1.2
+++ log.d/scripts/services/sendmail 30 Mar 2003 16:56:10 -0000
@@ -18,6 +18,13 @@
$HourReturns = 0;
$DaysReturns = 0;
+# Unknown users with bounces <= $UnknownUserThreshold will only be
+# printed if the detail level is >= 10. Setting this value to 0 disables
+# it.
+my $UnknownUsersThreshold = 0;
+my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
+my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
+
my %relay;
my %abuse;
my %largeHdrs;
@@ -56,7 +63,8 @@
} elsif ( $ThisLine =~ m/X-Scanned-By: MIMEDefang/) {
$Defang++;
} elsif ( ($User) = ($ThisLine =~ /^<([^ ]*)>... User unknown$/) ) {
- $UnknownUsers{$User}{$QueueID}++;
+ # Case fold
+ $UnknownUsers{lc $User}{$QueueID}++;
} elsif ( ($Host) = ($ThisLine =~ /\(Name server: ([^ ]+): host not found\)/)) {
$UnknownHosts{$Host}++;
} elsif ( ($Domain) = ($ThisLine =~ /Domain of sender address ([^ ]+) does not resolve/)) {
@@ -187,13 +195,20 @@
foreach $QueueID (sort keys %{ $UnknownUsers{$Usr} }) {
$SortedUsers{$Usr}{$Relays{$QueueID}}++;
}
+ @v = values %{$SortedUsers{$Usr}};
}
print "\n\nUnknown users:\n";
foreach $Usr (sort keys %SortedUsers) {
- print "\n $Usr\n";
- my $sort = CountOrder( %{$SortedUsers{$Usr}} );
- foreach $RelayHost (sort $sort keys %{ $SortedUsers{$Usr} }) {
- print " from $RelayHost $SortedUsers{$Usr}{$RelayHost} time(s).\n";
+ my $sum = 0;
+ unless ($Detail >= 10) {
+ grep { $sum += $_ } values %{$SortedUsers{$Usr}};
+ }
+ if ($Detail >= 10 || $sum > $UnknownUsersThreshold) {
+ print "\n $Usr\n";
+ my $sort = CountOrder( %{$SortedUsers{$Usr}} );
+ foreach $RelayHost (sort $sort keys %{ $SortedUsers{$Usr} }) {
+ print " from $RelayHost $SortedUsers{$Usr}{$RelayHost} time(s).\n";
+ }
}
}
}
--------------080402020409090908070607--
--------------enigDBAE0923F289C88C6311FBA7
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+hyTAa/4rvE9Bo3ERAn9ZAKDEoZxcmlpdugzUE3sGdRtVDjSBnACeNeRc
9RXpTp5SxZubwLZTrmSYx0c=
=iOlU
-----END PGP SIGNATURE-----
--------------enigDBAE0923F289C88C6311FBA7--