From 12efd6ecd284b8c639a41522330c67eae7bc04ae Mon Sep 17 00:00:00 2001 From: Sven Hoexter Date: Wed, 28 May 2025 12:48:21 +0200 Subject: [PATCH] New upstream version 1.1.9 --- ChangeLog | 16 ++++++++++++++++ pffrombyto.1 | 2 +- pflogsumm | 44 +++++++++++++++++++++----------------------- pflogsumm.1 | 6 +++--- pftobyfrom.1 | 2 +- 5 files changed, 42 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d1c594..d554b86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,22 @@ ChangeLog for pflogsumm http://jimsun.LinxNet.com/postfix_contrib.html.] +rel-1.1.9 20250527 + + Bugfix: Messages rejected in cleanup were incorrectly counted + as received. + + Bugfix: In the unlikely (?) event a qid was used more than once + in the same logfile input only the size of the message with the + first occurrence of that qid would be counted. + + Bugfix: Eliminated errant debugging message that escaped my + attention in versions 1.1.7 and 1.1.8. + + Documentation bugfix: "Addresses" misspelled as "adresses." Thanks + and a tip o' the hat to Sven Hoexter (sven-at-stormbind-dot-net) for + the heads up. + rel-1.1.8 20250525 Removed the following deprecated options diff --git a/pffrombyto.1 b/pffrombyto.1 index fbe0bad..efb1f25 100644 --- a/pffrombyto.1 +++ b/pffrombyto.1 @@ -55,7 +55,7 @@ .\" ======================================================================== .\" .IX Title "PFFROMBYTO 1" -.TH PFFROMBYTO 1 2025-05-22 1.1.8 "User Contributed Perl Documentation" +.TH PFFROMBYTO 1 2025-05-22 1.1.9 "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff --git a/pflogsumm b/pflogsumm index 42a48e3..561651b 100755 --- a/pflogsumm +++ b/pflogsumm @@ -6,7 +6,7 @@ eval 'exec perl -S $0 "$@"' pflogsumm - Produce Postfix MTA logfile summary -Copyright (C) 1998-2025 by James S. Seymour, Release 1.1.8 +Copyright (C) 1998-2025 by James S. Seymour, Release 1.1.9 =head1 SYNOPSIS @@ -184,7 +184,7 @@ Copyright (C) 1998-2025 by James S. Seymour, Release 1.1.8 If your postfix install has an SRS plugin running, many addresses in the report will contain the SRS-formatted - email addresses, also for non-local adresses (f.i. + email addresses, also for non-local addresses (f.i. senders). This option will try to undo the "damage". Addresses of the form: @@ -411,7 +411,7 @@ eval { require Date::Calc }; my $hasDateCalc = $@ ? 0 : 1; my $mailqCmd = "mailq"; -my $release = "1.1.8"; +my $release = "1.1.9"; # Variables and constants used throughout pflogsumm use vars qw( @@ -463,7 +463,6 @@ my ( $cmd, $qid, $addr, $orig_to, $size, $relay, $status, $delay, $dateStr, $dateStrRFC3339, %panics, %fatals, %warnings, %masterMsgs, - %msgSizes, %deferred, %bounced, %noMsgSize, %msgDetail, $msgsRcvd, $msgsDlvrd, $sizeRcvd, $sizeDlvrd, @@ -666,6 +665,7 @@ while(<>) { if($rejSubTyp eq "reject" or $rejSubTyp eq "milter-reject") { ++$rejects{$cmd}{$rejReas}{$rejRmdr} unless($opts{'rejectDetail'} == 0); ++$msgsRjctd; + --$msgsRcvd; # It will have already been counted as "Received," even though it ultimately is not } elsif($rejSubTyp eq "warning") { ++$warns{$cmd}{$rejReas}{$rejRmdr} unless($opts{'rejectDetail'} == 0); ++$msgsWrnd; @@ -676,6 +676,7 @@ while(<>) { ++$discards{$cmd}{$rejReas}{$rejRmdr} unless($opts{'rejectDetail'} == 0); ++$msgsDscrdd; } + delete($rcvdMsg{$qid}); # We're done with this ++$rejPerHr[$msgHr]; ++${$msgsPerDay{$revMsgDateStr}}[4]; } elsif($qid eq 'warning') { @@ -735,9 +736,7 @@ while(<>) { ++$rcvPerHr[$msgHr]; ++${$msgsPerDay{$revMsgDateStr}}[0]; ++$msgsRcvd; - $rcvdMsg{$qid} = gimme_domain($1); # Whence it came - # DEBUG DEBUG DEBUG - #print STDERR "Received: $qid\n"; + $rcvdMsg{$qid}{'whence'} = gimme_domain($1); # Whence it came } elsif(my($rejSubTyp) = $logRmdr =~ /\[\d+\]: \w+: (reject(?:_warning)?|hold|discard): /) { if($rejSubTyp eq 'reject') { proc_smtpd_reject($logRmdr, \%rejects, \$msgsRjctd, @@ -803,7 +802,7 @@ while(<>) { my $toRmdr; if((($addr, $size) = $logRmdr =~ /from=<([^>]*)>, size=(\d+)/) == 2) { - next if($msgSizes{$qid}); # avoid double-counting! + next if($rcvdMsg{$qid}{'size'}); # avoid double-counting! if($addr) { if($opts{'m'} && $addr =~ /^(.*!)*([^!]+)!([^!@]+)@([^\.]+)$/) { $addr = "$4!" . ($1? "$1" : "") . $3 . "\@$2"; @@ -815,15 +814,15 @@ while(<>) { } else { $addr = "from=<>" } - $msgSizes{$qid} = $size; + $rcvdMsg{$qid}{'size'} = $size; push(@{$msgDetail{$qid}}, $addr) if($opts{'e'}); # Avoid counting forwards - if($rcvdMsg{$qid}) { + if($rcvdMsg{$qid}{'whence'}) { # Get the domain out of the sender's address. If there is - # none: Use the client hostname/IP-address + # none: Use the client domain/IP-address my $domAddr; unless((($domAddr = $addr) =~ s/^[^@]+\@(.+)$/$1/) == 1) { - $domAddr = $rcvdMsg{$qid} eq "pickup"? $addr : $rcvdMsg{$qid}; + $domAddr = $rcvdMsg{$qid}{'whence'} eq "pickup"? $addr : $rcvdMsg{$qid}{'whence'}; } ++$sendgDomCnt unless(${$sendgDom{$domAddr}}[MSG_CNT_I]); @@ -833,7 +832,6 @@ while(<>) { ++${$sendgUser{$addr}}[MSG_CNT_I]; ${$sendgUser{$addr}}[MSG_SIZE_I] += $size; $sizeRcvd += $size; - delete($rcvdMsg{$qid}); # limit hash size } } elsif((($addr, $orig_to, $relay, $delay, $status, $toRmdr) = $logRmdr =~ @@ -851,8 +849,9 @@ while(<>) { if($status eq 'sent') { # was it actually forwarded, rather than delivered? - if($toRmdr =~ /forwarded as /) { + if((my $newQid) = ($toRmdr =~ /\(forwarded as ([^\)]+)\)/)) { ++$msgsFwdd; + delete($rcvdMsg{$qid}); # We're done with this next; } ++$recipDomCnt unless(${$recipDom{$domAddr}}[MSG_CNT_I]); @@ -868,12 +867,10 @@ while(<>) { ++$dlvPerHr[$msgHr]; ++${$msgsPerDay{$revMsgDateStr}}[1]; ++$msgsDlvrd; - # DEBUG DEBUG DEBUG - #print STDERR "Delivered: $qid\n"; - if($msgSizes{$qid}) { - ${$recipDom{$domAddr}}[MSG_SIZE_I] += $msgSizes{$qid}; - ${$recipUser{$addr}}[MSG_SIZE_I] += $msgSizes{$qid}; - $sizeDlvrd += $msgSizes{$qid}; + if($rcvdMsg{$qid}{'size'}) { + ${$recipDom{$domAddr}}[MSG_SIZE_I] += $rcvdMsg{$qid}{'size'}; + ${$recipUser{$addr}}[MSG_SIZE_I] += $rcvdMsg{$qid}{'size'}; + $sizeDlvrd += $rcvdMsg{$qid}{'size'}; } else { ${$recipDom{$domAddr}}[MSG_SIZE_I] += 0; ${$recipUser{$addr}}[MSG_SIZE_I] += 0; @@ -923,7 +920,6 @@ while(<>) { my ($bounceReas) = $logRmdr =~ /, status=bounced \((.+)\)/; unless(defined($opts{'verbMsgDetail'})) { $bounceReas = said_string_trimmer($bounceReas, 66); - $bounceReas =~ s/^\d{3} //; } ++$bounced{$relay}{$bounceReas}; } @@ -941,7 +937,7 @@ while(<>) { ++$rcvPerHr[$msgHr]; ++${$msgsPerDay{$revMsgDateStr}}[0]; ++$msgsRcvd; - $rcvdMsg{$qid} = "pickup"; # Whence it came + $rcvdMsg{$qid}{'whence'} = "pickup"; # Whence it came } elsif($cmd eq 'smtp' && $opts{'smtpDetail'} != 0) { # Was an IPv6 problem here @@ -953,6 +949,9 @@ while(<>) { print $unProcd "$_\n" if $unProcd; } } + elsif($cmd =~ /^n?qmgr$/ && $logRmdr =~ /\bremoved$/) { + delete($rcvdMsg{$qid}); # We're done with this + } else { print $unProcd "$_\n" if $unProcd; @@ -1583,7 +1582,6 @@ sub gimme_domain { my $slashSepRegex = '([^\s\/]+)\/((?:\d{1,3}\.){3}\d{1,3}|[\da-fA-F:]+(?:::(?:[\da-fA-F:]+)?)?|[\da-fA-F:]+:(?:\d{1,3}\.){3}\d{1,3})'; my ($fqdn, $ipaddr); - print STDERR "dbg: \$_: \"$_\"\n" if(/unknown=0/); unless((($fqdn, $ipaddr) = /$bracketRegex/i) == 2) { ($fqdn, $ipaddr) = /$slashSepRegex/i; } diff --git a/pflogsumm.1 b/pflogsumm.1 index 1b8dbef..488ce95 100644 --- a/pflogsumm.1 +++ b/pflogsumm.1 @@ -55,7 +55,7 @@ .\" ======================================================================== .\" .IX Title "PFLOGSUMM 1" -.TH PFLOGSUMM 1 2025-05-25 1.1.8 "User Contributed Perl Documentation" +.TH PFLOGSUMM 1 2025-05-27 1.1.9 "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -63,7 +63,7 @@ .SH NAME pflogsumm \- Produce Postfix MTA logfile summary .PP -Copyright (C) 1998\-2025 by James S. Seymour, Release 1.1.8 +Copyright (C) 1998\-2025 by James S. Seymour, Release 1.1.9 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 8 @@ -243,7 +243,7 @@ Copyright (C) 1998\-2025 by James S. Seymour, Release 1.1.8 \& \& If your postfix install has an SRS plugin running, many \& addresses in the report will contain the SRS\-formatted -\& email addresses, also for non\-local adresses (f.i. +\& email addresses, also for non\-local addresses (f.i. \& senders). This option will try to undo the "damage". \& \& Addresses of the form: diff --git a/pftobyfrom.1 b/pftobyfrom.1 index b41e649..4d59013 100644 --- a/pftobyfrom.1 +++ b/pftobyfrom.1 @@ -55,7 +55,7 @@ .\" ======================================================================== .\" .IX Title "PFTOBYFROM 1" -.TH PFTOBYFROM 1 2025-05-22 1.1.8 "User Contributed Perl Documentation" +.TH PFTOBYFROM 1 2025-05-22 1.1.9 "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l -- 2.39.5