net-mail/amavis-logwatch: new revision with some bugfix patches.
authorMichael Orlitzky <mjo@gentoo.org>
Thu, 24 Aug 2017 13:14:42 +0000 (09:14 -0400)
committerMichael Orlitzky <mjo@gentoo.org>
Thu, 24 Aug 2017 13:16:21 +0000 (09:16 -0400)
Upstream development has stalled for this package, so we now include a
few patches needed to support modern versions of perl and amavisd-new.

Package-Manager: Portage-2.3.6, Repoman-2.3.1

net-mail/amavis-logwatch/amavis-logwatch-1.51.03-r1.ebuild [new file with mode: 0644]
net-mail/amavis-logwatch/files/ignore-amavis-startup-notifications.patch [new file with mode: 0644]
net-mail/amavis-logwatch/files/ignore-utf8smtp-lines.patch [new file with mode: 0644]
net-mail/amavis-logwatch/files/redundant-argument-to-sprintf.patch [new file with mode: 0644]
net-mail/amavis-logwatch/files/unescaped-left-brace.patch [new file with mode: 0644]

diff --git a/net-mail/amavis-logwatch/amavis-logwatch-1.51.03-r1.ebuild b/net-mail/amavis-logwatch/amavis-logwatch-1.51.03-r1.ebuild
new file mode 100644 (file)
index 0000000..891d142
--- /dev/null
@@ -0,0 +1,44 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+DESCRIPTION="A log analyzer for amavisd-new"
+HOMEPAGE="http://logreporters.sourceforge.net/"
+SRC_URI="mirror://sourceforge/logreporters/${P}.tgz"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+RDEPEND="dev-lang/perl"
+
+PATCHES=(
+       "${FILESDIR}/unescaped-left-brace.patch"
+       "${FILESDIR}/redundant-argument-to-sprintf.patch"
+       "${FILESDIR}/ignore-amavis-startup-notifications.patch"
+       "${FILESDIR}/ignore-utf8smtp-lines.patch"
+)
+
+src_prepare() {
+       default
+       # Replace the default config file location with ours.
+       local cfg_default='/usr/local/etc/${progname_prefix}-logwatch.conf'
+       local cfg_gentoo='/etc/${progname_prefix}-logwatch.conf';
+       sed -i "s~${cfg_default}~${cfg_gentoo}~" ${PN} \
+               || die 'failed to update the default config location'
+}
+
+src_compile() {
+       # The default make target just outputs instructions. We don't want
+       # the user to see these, so we avoid the default emake.
+       :
+}
+
+src_install() {
+       dodoc Bugs Changes README
+       doman ${PN}.1
+       dobin ${PN}
+       insinto /etc
+       doins ${PN}.conf
+}
diff --git a/net-mail/amavis-logwatch/files/ignore-amavis-startup-notifications.patch b/net-mail/amavis-logwatch/files/ignore-amavis-startup-notifications.patch
new file mode 100644 (file)
index 0000000..4dd0191
--- /dev/null
@@ -0,0 +1,31 @@
+From 15bf4096ea496a28210e2f4c1f34ab28b413566a Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Thu, 24 Aug 2017 08:52:18 -0400
+Subject: [PATCH 3/4] Ignore amavisd-new "starting child processes"
+ notifications.
+
+Newer versions of amavisd-new log the following constantly:
+
+  sd_notify (no socket): STATUS=Starting child process(es), ready for work.
+
+It's of no use to us, so add it to the global "ignore" list.
+---
+ amavis-logwatch | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/amavis-logwatch b/amavis-logwatch
+index 1aab787..06b60c8 100644
+--- a/amavis-logwatch
++++ b/amavis-logwatch
+@@ -2044,6 +2044,8 @@ sub create_ignore_list() {
+         # unanchored
+    push @ignore_list_final, qr/\bRUSAGE\b/;
+    push @ignore_list_final, qr/: Sending .* to UNIX socket/;
++
++   push @ignore_list_final, qr/sd_notify \(no socket\): STATUS=Starting child process\(es\), ready for work./
+ }
+ 
+ # Notes:
+-- 
+2.13.0
+
diff --git a/net-mail/amavis-logwatch/files/ignore-utf8smtp-lines.patch b/net-mail/amavis-logwatch/files/ignore-utf8smtp-lines.patch
new file mode 100644 (file)
index 0000000..83fd4cb
--- /dev/null
@@ -0,0 +1,32 @@
+From a8dac25fe398e42abdb89b85b1435d52386827b4 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Thu, 24 Aug 2017 09:05:04 -0400
+Subject: [PATCH 4/4] Ignore UTF8SMTP lines.
+
+Lines that look like,
+
+  UTF8SMTP :10024 /var/...: <sender@example.net> -> <rcpt@example.com>
+  BODY=8BITMIME SMTPUTF8 Received: from mx.example.com ([127.0.0.1]) by...
+
+were previously unmatched because of the relatively-new "UTF8SMTP".
+Similar lines that have "ESMTP" instead of "UTF8SMTP" are already
+ignored, so it makes sense to ignore the "UTF8SMTP" lines too.
+---
+ amavis-logwatch | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/amavis-logwatch b/amavis-logwatch
+index 06b60c8..deb9146 100644
+--- a/amavis-logwatch
++++ b/amavis-logwatch
+@@ -2132,6 +2132,7 @@ while (<>) {
+         or ($p1 =~ /^SpamControl/)
+         or ($p1 =~ /^Perl/)
+         or ($p1 =~ /^ESMTP/)
++        or ($p1 =~ /^UTF8SMTP/)
+         or ($p1 =~ /^(?:\(!+\))?(\S+ )?(?:FWD|SEND) from /)            # log level 4
+         or ($p1 =~ /^(?:\(!+\))?(\S+ )?(?:ESMTP|FWD|SEND) via /)       # log level 4
+         or ($p1 =~ /^tempdir being removed/)
+-- 
+2.13.0
+
diff --git a/net-mail/amavis-logwatch/files/redundant-argument-to-sprintf.patch b/net-mail/amavis-logwatch/files/redundant-argument-to-sprintf.patch
new file mode 100644 (file)
index 0000000..91f456a
--- /dev/null
@@ -0,0 +1,48 @@
+From 02cf771776d2f1ad9d7872f3959e41a548adfab9 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Thu, 24 Aug 2017 08:20:59 -0400
+Subject: [PATCH 2/4] Fix redundant argument to sprintf warning.
+
+Perl 5.22 now warns about redundant (i.e. extra) arguments to the
+sprintf function. If your format string only has two place-holders but
+you pass three place-fillers, you get warned:
+
+  Redundant argument in sprintf at ./amavis-logwatch line 1338...
+
+The issue there was that the format string passed to sprintf was
+constructed dynamically; sometimes it would contain two place-holders,
+and sometimes three. Three place-fillers were always passed, so when
+only two place-holders were used, the warning would be thrown. This was
+fixed by testing whether or not there are two or three place-holders,
+and passing the appropriate number of place-fillers.
+---
+ amavis-logwatch | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/amavis-logwatch b/amavis-logwatch
+index 8972497..1aab787 100644
+--- a/amavis-logwatch
++++ b/amavis-logwatch
+@@ -1334,8 +1334,17 @@ sub print_summary_report (\@) {
+                      $$divisor == $Totals{$keyname} ? 100.00 : $Totals{$keyname} * 100 / $$divisor;
+             }
+             else {
+-               push @{$lines[$cur_level]}, 
+-                  sprintf "$fmt  %-23s $extra\n", $total, $desc, commify ($Totals{$keyname});
++              my $new_line;
++              if ($extra eq '') {
++                  $new_line = sprintf("$fmt  %-23s \n", $total, $desc);
++              }
++              else {
++                  $new_line = sprintf("$fmt  %-23s $extra\n",
++                                      $total,
++                                      $desc,
++                                      commify ($Totals{$keyname}));
++              }
++              push @{$lines[$cur_level]}, $new_line
+             }
+          }
+       }
+-- 
+2.13.0
+
diff --git a/net-mail/amavis-logwatch/files/unescaped-left-brace.patch b/net-mail/amavis-logwatch/files/unescaped-left-brace.patch
new file mode 100644 (file)
index 0000000..2cb293b
--- /dev/null
@@ -0,0 +1,38 @@
+From 79f37650aa72fe3feeed682ee2b79686ee2b6547 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Thu, 24 Aug 2017 08:16:05 -0400
+Subject: [PATCH 1/4] Fix unescaped left brace warning in monster regex.
+
+New versions of Perl are starting to complain about unescaped braces
+in regular expressions, and supposedly the warning will become a fatal
+error in Perl 5.30. This particular warning is,
+
+  Unescaped left brace in regex is deprecated, passed through in regex;
+  marked by <-- HERE in m/^(CLEAN|SPAM(?:MY)?|INFECTED \(.*?\)|BANNED \(.*?\)
+  |BAD-HEADER(?:-\d)?|UNCHECKED|MTA-BLOCKED|OVERSIZED|OTHER|TEMPFAIL)(?:
+  { <-- HERE [^}]+})?, ([^[]+ )?(?:([^<]+) )?[<(](.*?)[>)] -> ([(<].*?[)>]),
+  (?:.*Hits: ([-+.\d]+))(?:.* size: (\d+))?(?:.* autolearn=(\w+))?/ at
+  /usr/bin/amavis-logwatch line 2286.
+
+and it was fixed by going to line 2286 and putting a backslash before
+the left brace.
+---
+ amavis-logwatch | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/amavis-logwatch b/amavis-logwatch
+index 4ad07f6..8972497 100644
+--- a/amavis-logwatch
++++ b/amavis-logwatch
+@@ -2283,7 +2283,7 @@ while (<>) {
+       #XXX elsif (($action, $key, $ip, $from, $to) = ( $p1 =~ /^(?:Virus found - quarantined|(?:(Passed|Blocked) )?INFECTED) \(([^\)]+)\),[A-Z .]*(?: \[($re_IP)\])?(?: \[$re_IP\])* [<(]([^>)]*)[>)] -> [(<]([^(<]+)[(>]/o ))
+ 
+       # the first IP is the envelope sender.
+-      if ($p1 !~ /^(CLEAN|SPAM(?:MY)?|INFECTED \(.*?\)|BANNED \(.*?\)|BAD-HEADER(?:-\d)?|UNCHECKED|MTA-BLOCKED|OVERSIZED|OTHER|TEMPFAIL)(?: {[^}]+})?, ([^[]+ )?(?:([^<]+) )?[<(](.*?)[>)] -> ([(<].*?[)>]), (?:.*Hits: ([-+.\d]+))(?:.* size: (\d+))?(?:.* autolearn=(\w+))?/) {
++      if ($p1 !~ /^(CLEAN|SPAM(?:MY)?|INFECTED \(.*?\)|BANNED \(.*?\)|BAD-HEADER(?:-\d)?|UNCHECKED|MTA-BLOCKED|OVERSIZED|OTHER|TEMPFAIL)(?: \{[^}]+})?, ([^[]+ )?(?:([^<]+) )?[<(](.*?)[>)] -> ([(<].*?[)>]), (?:.*Hits: ([-+.\d]+))(?:.* size: (\d+))?(?:.* autolearn=(\w+))?/) {
+          inc_unmatched('passblock');
+          next;
+       }
+-- 
+2.13.0
+