Hi postfix users, Ever since I added SRS to my mail setup, reading daily pflogsumm reports got a lot harder since most senders were changed to SRS addresses. This also threw off statistics since multiple sender addresses were used when actually the sender was the same.
Attached is a patch for pflogsumm that unmunges SRS'ed addresses before using them in the report. Basically I looked at how verp unmunging was done, and copied that with a regex for SRS. The regex is based on the SRS format found on Wikipedia and used in the papers in libsrs docs. @Jim: maybe you could be so kind to include this in the next pflogsumm version? Kind regards, Tom
--- pflogsumm.pl.orig 2016-03-24 11:07:30.806142020 +0100 +++ pflogsumm.pl 2016-03-24 11:36:39.468481189 +0100 @@ -17,7 +17,7 @@ [--rej-add-from] [--reject-detail <cnt>] [--smtp-detail <cnt>] [--smtpd-stats] [--smtpd-warning-detail <cnt>] [--syslog-name=string] [-u <cnt>] [--verbose-msg-detail] - [--verp-mung[=<n>]] [--zero-fill] [file1 [filen]] + [--verp-mung[=<n>]] [--srs-mung] [--zero-fill] [file1 [filen]] pflogsumm.pl -[help|version] @@ -238,6 +238,18 @@ See "NOTES" regarding this option. + --srs-mung Undo SRS address munging. + + 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. + senders). This option will try to undo the "damage". + + Addresses of the form: + SRS0=A6cv=PT=sender.example.com=supp...@srs.example.net + will be reformatted to their original value: + supp...@sender.example.com + --version Print program name and version and bail out. --zero-fill "Zero-fill" certain arrays so reports come out with @@ -496,7 +508,7 @@ [--rej-add-from] [--reject-detail <cnt>] [--smtp-detail <cnt>] [--smtpd-stats] [--smtpd-warning-detail <cnt>] [--syslog-name=string] [-u <cnt>] [--verbose-msg-detail] - [--verp-mung[=<n>]] [--zero-fill] [file1 [filen]] + [--verp-mung[=<n>]] [--srs-mung] [--zero-fill] [file1 [filen]] $progName --[version|help]"; @@ -538,6 +550,7 @@ "uucp-mung" => \$opts{'m'}, "verbose-msg-detail" => \$opts{'verbMsgDetail'}, "verp-mung:i" => \$opts{'verpMung'}, + "srs-mung" => \$opts{'srsMung'}, "version" => \$opts{'version'}, "zero-fill" => \$opts{'zeroFill'} ) || die "$usageMsg\n"; @@ -795,6 +808,7 @@ $addr =~ s/(@.+)/\L$1/ unless($opts{'i'}); $addr = lc($addr) if($opts{'i'}); $addr = verp_mung($addr); + $addr = srs_mung($addr); } else { $addr = "from=<>" } @@ -1682,6 +1696,7 @@ if(defined($from)) { $rejAddFrom = $opts{'rejAddFrom'}; $from = verp_mung($from); + $from = srs_mung($from); $from = lc($from) if($opts{'i'}); } @@ -1738,6 +1753,16 @@ } return $addr; +} + +sub srs_mung { + my $addr = $_[0]; + + if(defined($opts{'srsMung'})) { + $addr =~ s/^SRS(?:[01])(?:[=+-])(?:[^=]+=[\w\.]+==)*(?:[^=]+=[^=]+=)([\w\.]+)=(.+)@[\w\.]+$/$2\@$1/i; + } + + return $addr; } ###
signature.asc
Description: OpenPGP digital signature