ports/187005: [PATCH] mail/mailscanner: Update to current stable version
Kevin Kobb
kkobb at skylinecorp.com
Mon Feb 24 13:20:00 UTC 2014
>Number: 187005
>Category: ports
>Synopsis: [PATCH] mail/mailscanner: Update to current stable version
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Mon Feb 24 13:20:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator: Kevin Kobb
>Release: FreeBSD 9.2-RELEASE-p2 amd64
>Organization:
>Environment:
FreeBSD mail.skylinecorp.com 9.2-RELEASE-p2 FreeBSD 9.2-RELEASE-p2 #0 r258794: Sun Dec 1 19:46:46 EST 2013 root at mail.skylinecorp.com:/usr/obj/usr/src/sys/T310 amd64
>Description:
MailScanner port is not at the current stable version. Also has some nasty tmp file bugs reported by brad at comstyle.com.
>How-To-Repeat:
Check port versus upstream release. Look for stale temp files in SpamAssassin-Temp directory.
>Fix:
See attached patch file.
Patch attached with submission follows:
diff -urN mailscanner.orig/Makefile mailscanner/Makefile
--- mailscanner.orig/Makefile 2013-09-24 13:58:08.000000000 -0400
+++ mailscanner/Makefile 2014-02-21 03:51:46.000000000 -0500
@@ -2,8 +2,8 @@
# $FreeBSD: head/mail/mailscanner/Makefile 327742 2013-09-20 19:59:12Z bapt $
PORTNAME= MailScanner
-PORTVERSION= 4.84.5
-PORTREVISION= 3
+PORTVERSION= 4.84.6
+#PORTREVISION= 0
CATEGORIES= mail
MASTER_SITES= http://www.mailscanner.info/files/4/tar/
DISTNAME= ${PORTNAME}-install-${PORTVERSION}-${PATCHLEVEL}
@@ -38,7 +38,7 @@
CONFLICTS= MailScanner-devel-[0-9]*
-PATCHLEVEL= 2
+PATCHLEVEL= 1
USES= perl5
diff -urN mailscanner.orig/distinfo mailscanner/distinfo
--- mailscanner.orig/distinfo 2014-02-17 07:39:42.000000000 -0500
+++ mailscanner/distinfo 2014-02-21 03:52:35.000000000 -0500
@@ -1,2 +1,2 @@
-SHA256 (MailScanner-install-4.84.5-2.tar.gz) = 3467a53159cc95a8b4f93a326a59e2d3acc0ad6f90f048f048742fe13ac741f1
-SIZE (MailScanner-install-4.84.5-2.tar.gz) = 9510489
+SHA256 (MailScanner-install-4.84.6-1.tar.gz) = 566b6e2abf86de1acdff4f7fc5e6112aebab986954532a25f69b9f576ec70077
+SIZE (MailScanner-install-4.84.6-1.tar.gz) = 9524836
diff -urN mailscanner.orig/files/CHANGES.port mailscanner/files/CHANGES.port
--- mailscanner.orig/files/CHANGES.port 2014-02-17 07:39:42.000000000 -0500
+++ mailscanner/files/CHANGES.port 2014-02-21 04:32:12.000000000 -0500
@@ -1,3 +1,10 @@
+Version 4.84.6
+==============
+- Upgrade to 4.84.6
+- Added some patches for tmp file bugs
+ reported/provided by brad at comstyle.com
+ from the OpenBSD port and GitHub repository.
+
Version 4.84.5_3 (not bumped)
================
- Use OptionsNG
diff -urN mailscanner.orig/files/patch-lib__MailScanner__CustomFunctions__LastSpam.pm mailscanner/files/patch-lib__MailScanner__CustomFunctions__LastSpam.pm
--- mailscanner.orig/files/patch-lib__MailScanner__CustomFunctions__LastSpam.pm 1969-12-31 19:00:00.000000000 -0500
+++ mailscanner/files/patch-lib__MailScanner__CustomFunctions__LastSpam.pm 2014-02-21 04:11:40.000000000 -0500
@@ -0,0 +1,20 @@
+--- ./lib/MailScanner/CustomFunctions/LastSpam.pm.orig 2011-08-20 08:24:49.000000000 -0400
++++ ./lib/MailScanner/CustomFunctions/LastSpam.pm 2014-02-21 04:11:09.000000000 -0500
+@@ -32,7 +32,6 @@
+ my $Debug = 0; # Set to 1 to enable debug output to STDERR
+ #my $tmpfilename = "/tmp/MailScanner.LastSpam.$$.conf"; # Temp MS.conf file
+ # Temp MS.conf file
+-my($tmpfh, $tmpfilename) = tempfile("MailScanner.LastSpam.XXXXXX", TMPDIR => 1, UNLINK => 0);
+ my %modtime = (); # Time domain list magic word file was last changed
+ my %filename = (); # Map Config option to magic word file
+ my %magicwords = {}; # Map Config option --> domains --> magic words
+@@ -550,8 +549,7 @@
+ sub SetupRuleset {
+ my($opkeyword) = @_;
+
+- my $fh = new FileHandle;
+- $fh->open("> $tmpfilename") or die "$!";
++ my($fh, $tmpfilename) = tempfile("MailScanner.LastSpam.XXXXXX", TMPDIR => 1, UNLINK => 0);
+ my $rf = $rulesetfilename{$opkeyword};
+ #print STDERR "RF = $rf\n";
+ #print STDERR $opkeyword . " = $rf\n";
diff -urN mailscanner.orig/files/patch-lib__MailScanner__CustomFunctions__Ruleset-from-Function.pm mailscanner/files/patch-lib__MailScanner__CustomFunctions__Ruleset-from-Function.pm
--- mailscanner.orig/files/patch-lib__MailScanner__CustomFunctions__Ruleset-from-Function.pm 1969-12-31 19:00:00.000000000 -0500
+++ mailscanner/files/patch-lib__MailScanner__CustomFunctions__Ruleset-from-Function.pm 2014-02-21 04:24:49.000000000 -0500
@@ -0,0 +1,20 @@
+--- ./lib/MailScanner/CustomFunctions/Ruleset-from-Function.pm.orig 2011-08-20 08:25:42.000000000 -0400
++++ ./lib/MailScanner/CustomFunctions/Ruleset-from-Function.pm 2014-02-21 04:16:55.000000000 -0500
+@@ -31,7 +31,6 @@
+
+ my $Debug = 0; # Set to 1 to enable debug output to STDERR
+ #my $tmpfilename = "/tmp/MailScanner.$$.conf"; # Temp MS.conf file
+-my($tmpfh, $tmpfilename) = tempfile("MailScanner.XXXXXX", TMPDIR => 1, UNLINK => 0);
+
+
+
+@@ -60,8 +59,7 @@
+ my $option = 'virusscanning'; # External (MailScanner.conf-version)
+
+ # Make the temporary 1-line MailScanner.conf file, use it and delete it
+- my $fh = new FileHandle;
+- $fh->open("> $tmpfilename") or die "$!";
++ my($fh, $tmpfilename) = tempfile("MailScanner.XXXXXX", TMPDIR => 1, UNLINK => 0);
+ print $fh $option . " = $ruleset\n";
+ $fh->close;
+
diff -urN mailscanner.orig/files/patch-lib__MailScanner__TNEF.pm mailscanner/files/patch-lib__MailScanner__TNEF.pm
--- mailscanner.orig/files/patch-lib__MailScanner__TNEF.pm 2014-02-17 07:39:42.000000000 -0500
+++ mailscanner/files/patch-lib__MailScanner__TNEF.pm 2014-02-21 04:06:30.000000000 -0500
@@ -1,20 +1,110 @@
---- ./lib/MailScanner/TNEF.pm.orig 2011-08-20 08:32:02.000000000 -0400
-+++ ./lib/MailScanner/TNEF.pm 2012-03-15 11:28:31.000000000 -0400
-@@ -229,15 +229,14 @@
+--- ./lib/MailScanner/TNEF.pm.orig 2013-06-17 09:29:16.000000000 -0400
++++ ./lib/MailScanner/TNEF.pm 2014-02-21 04:03:15.000000000 -0500
+@@ -229,18 +229,25 @@
# Create the subdir to unpack it into
#my $unpackdir = "tnef.$$";
- my ($tmpfh, $unpackdir) = tempfile("tnefXXXXXX", TMPDIR => $dir, UNLINK => 0);
-- $dir =~ s,^.*/,,;
-+ my $unpackdir = tempdir("tnefXXXXXX");
- $unpackdir = $message->MakeNameSafe($unpackdir, $dir);
- unless (mkdir "$dir/$unpackdir", 0777) {
+- # This line shouldn't be here any more! $dir =~ s,^.*/,,;
+- $unpackdir = $message->MakeNameSafe($unpackdir, $dir);
+- unless (mkdir "$dir/$unpackdir", 0777) {
++ my $unpackdir = tempdir("tnefXXXXXX", DIR => $dir);
++ unless (-d $unpackdir) {
MailScanner::Log::WarnLog("Trying to unpack %s in message %s, could not create subdirectory %s, failed to unpack TNEF message", $tnefname, $message->{id},
- "$dir/$unpackdir");
+- "$dir/$unpackdir");
++ "$unpackdir");
return 0;
}
- chmod 0700, "$dir/$unpackdir";
-+ chmod 0770, "$dir/$unpackdir";
++ # Convert Incoming Work Permissions to an octal value and add search.
++ my $perms = oct(sprintf("%s", MailScanner::Config::Value('workperms')))
++ | 0111;
++ chmod $perms, $unpackdir;
++ # Try to set Incoming Work User and Group.
++ my $uname = MailScanner::Config::Value('workuser');
++ my $gname = MailScanner::Config::Value('workgroup');
++ my $uid = $uname?getpwnam($uname):-1;
++ my $gid = $gname?getgrnam($gname):-1;
++ chown $uid, $gid, $unpackdir;
my $cmd = MailScanner::Config::Value('tnefexpander') .
- " -f $dir/$tnefname -C $dir/$unpackdir --overwrite";
+- " -f $dir/$tnefname -C $dir/$unpackdir --overwrite";
++ " -f $dir/$tnefname -C $unpackdir --overwrite";
+
+ my($kid);
+ my($TimedOut, $PipeReturn, $pid);
+@@ -311,15 +318,15 @@
+
+ unless (MailScanner::Config::Value('replacetnef',$message) =~ /[12]/) {
+ # Just need to move all the unpacked files into the main attachments dir
+- my $dirh = new DirHandle "$dir/$unpackdir";
++ my $dirh = new DirHandle "$$unpackdir";
+ return 0 unless defined $dirh;
+ while (defined(my $unpacked = $dirh->read)) {
+- next unless -f "$dir/$unpackdir/$unpacked";
++ next unless -f "$$unpackdir/$unpacked";
+ # Add a 't' to the safename to mark it as a tnef member.
+ my $safe = $message->MakeNameSafe('t'.$unpacked, $dir);
+ # This will cause big problems as $safe has a type, and shouldn't!
+ $message->{file2parent}{$safe} = $tnefname;
+- my $name1 = "$dir/$unpackdir/$unpacked";
++ my $name1 = "$unpackdir/$unpacked";
+ $name1 =~ /(.*)/;
+ $name1 = $1;
+ my $name2 = "$dir/$safe";
+@@ -333,19 +340,21 @@
+ $safe =~ s#^(.*/)([^/])([^/]+)$#$1$3#; # I assert $2 will equal 't'.
+ $message->{file2parent}{$safe} = $tnefname;
+ }
+- rmdir "$dir/$unpackdir"; # Directory should be empty now
++ # The following may result in a warning from a virus scanner that
++ # tries to lstat the directory, but it was empty so it can be ignored.
++ rmdir "$$unpackdir"; # Directory should be empty now
+ return 1;
+ }
+ #print STDERR "In TNEF External Decoder\n";
+
+- my $dirh = new DirHandle "$dir/$unpackdir";
++ my $dirh = new DirHandle "$unpackdir";
+ return 0 unless defined $dirh;
+ my($type, $encoding);
+ $message->{entity}->make_multipart;
+ my($safename, @replacements, $unpacked);
+ while (defined($unpacked = $dirh->read)) {
+- #print STDERR "Directory entry is \"$unpacked\" in \"$dir/$unpackdir\"\n";
+- next unless -f "$dir/$unpackdir/$unpacked";
++ #print STDERR "Directory entry is \"$unpacked\" in \"$unpackdir\"\n";
++ next unless -f "$unpackdir/$unpacked";
+ # Add a 't' to the safename to mark it as a tnef member.
+ $safename = $message->MakeNameSafe('t'.$unpacked, $dir);
+ if (/^msg[\d-]+\.txt$/) {
+@@ -353,15 +362,15 @@
+ } else {
+ ($type, $encoding) = ("application/octet-stream", "base64");
+ }
+- #print STDERR "Renaming '$dir/$unpackdir/$unpacked' to '$dir/$safename'\n";
+- my $oldname = "$dir/$unpackdir/$unpacked";
++ #print STDERR "Renaming '$unpackdir/$unpacked' to '$dir/$safename'\n";
++ my $oldname = "$unpackdir/$unpacked";
+ my $newname = "$dir/$safename";
+ $oldname =~ /^(.*)$/;
+ $oldname = $1;
+ $newname =~ /^(.*)$/;
+ $newname = $1;
+ rename $oldname, $newname;
+- #rename "$dir/$unpackdir/$unpacked", "$dir/$safename";
++ #rename "$unpackdir/$unpacked", "$dir/$safename";
+ # JKF 20090421 CHMOD, then CHOWN and CHGRP it if necessary.
+ chmod $perms, $newname;
+ #chmod $perms, "$dir/$safename";
+@@ -381,7 +390,9 @@
+ $message->{bodymodified} = 1;
+ $message->{foundtnefattachments} = 1;
+ undef $dirh;
+- rmdir "$dir/$unpackdir"; # Directory should be empty now
++ # The following may result in a warning from a virus scanner that
++ # tries to lstat the directory, but it was empty so it can be ignored.
++ rmdir "$unpackdir"; # Directory should be empty now
+ #$message->{entity}->dump_skeleton();
+
+ MailScanner::Log::InfoLog("Message %s added TNEF contents %s",
diff -urN mailscanner.orig/files/patch-lib__bitdefender-wrapper mailscanner/files/patch-lib__bitdefender-wrapper
--- mailscanner.orig/files/patch-lib__bitdefender-wrapper 1969-12-31 19:00:00.000000000 -0500
+++ mailscanner/files/patch-lib__bitdefender-wrapper 2014-02-21 04:24:49.000000000 -0500
@@ -0,0 +1,19 @@
+--- ./lib/bitdefender-wrapper.orig 2011-08-20 08:20:04.000000000 -0400
++++ ./lib/bitdefender-wrapper 2014-02-21 04:19:02.000000000 -0500
+@@ -34,7 +34,6 @@
+ extras=''
+
+ #LogFile=/tmp/log.bdc.$$
+-LogFile=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+
+ if [ -x ${PackageDir}/bdscan ]; then
+ # Version 7.5 is installed
+@@ -60,7 +59,7 @@
+ fi
+
+ umask 077
+-rm -f $LogFile
++LogFile=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+ ${PackageDir}/$prog --log=$LogFile $extras "$@" >/dev/null 2>&1
+ cat $LogFile
+ rm -f $LogFile
diff -urN mailscanner.orig/files/patch-lib__clamav-wrapper mailscanner/files/patch-lib__clamav-wrapper
--- mailscanner.orig/files/patch-lib__clamav-wrapper 1969-12-31 19:00:00.000000000 -0500
+++ mailscanner/files/patch-lib__clamav-wrapper 2014-02-21 04:24:49.000000000 -0500
@@ -0,0 +1,55 @@
+--- ./lib/clamav-wrapper.orig 2011-08-20 08:32:02.000000000 -0400
++++ ./lib/clamav-wrapper 2014-02-21 04:21:05.000000000 -0500
+@@ -52,7 +52,6 @@
+ # You may want to check this script for bash-isms
+
+ #TempDir="/tmp/clamav.$$"
+-TempDir=$(mktemp) || { echo "$0: Cannot make name for temporary dir" >&2; exit 1; }
+ ClamUser="clamav"
+ ClamGroup="clamav"
+
+@@ -99,23 +98,23 @@
+ # LESS COMMON unpackers, which probably aren't installed by default
+ # (hence disabled)
+ # Uncomment ONE of the following lines if you have unrar installed
+-#ExtraScanOptions="$ExtraScanOptions --unrar"
++ExtraScanOptions="$ExtraScanOptions --unrar"
+ #ExtraScanOptions="$ExtraScanOptions --unrar=/path/to/unrar"
+
+ # Uncomment ONE of the following lines if you have unarj installed
+-#ExtraScanOptions="$ExtraScanOptions --unarj"
++ExtraScanOptions="$ExtraScanOptions --unarj"
+ #ExtraScanOptions="$ExtraScanOptions --unarj=/path/to/unarj"
+
+ # Uncomment ONE of the following lines if you have unace installed
+-#ExtraScanOptions="$ExtraScanOptions --unace"
++ExtraScanOptions="$ExtraScanOptions --unace"
+ #ExtraScanOptions="$ExtraScanOptions --unace=/path/to/unace"
+
+ # Uncomment ONE of the following lines if you have lha installed
+-#ExtraScanOptions="$ExtraScanOptions --lha"
++ExtraScanOptions="$ExtraScanOptions --lha"
+ #ExtraScanOptions="$ExtraScanOptions --lha=/path/to/lha"
+
+ # Uncomment ONE of the following lines if you have zoo installed
+-#ExtraScanOptions="$ExtraScanOptions --zoo"
++ExtraScanOptions="$ExtraScanOptions --zoo"
+ #ExtraScanOptions="$ExtraScanOptions --zoo=/path/to/unzoo"
+
+ # Now increase the allowed expansion size of zip files
+@@ -140,14 +139,10 @@
+ PATH=$PATH:/usr/ucb
+ export PATH
+
+-# Check if the tmpdir exists, if so delete so we start with a clean slate
+-if [ -x "${TempDir}" ]; then
+- rm -rf ${TempDir} >/dev/null 2>&1
+-fi
+
+ # Make the Temp dir
+ umask 0077
+-mkdir "${TempDir}" >/dev/null 2>&1
++TempDir=$(mktemp -d) || { echo "$0: Cannot create temporary dir" >&2; exit 1; }
+
+ # In case we get interupted....
+ trap "rm -rf ${TempDir}" EXIT
diff -urN mailscanner.orig/files/patch-lib__kaspersky-wrapper mailscanner/files/patch-lib__kaspersky-wrapper
--- mailscanner.orig/files/patch-lib__kaspersky-wrapper 1969-12-31 19:00:00.000000000 -0500
+++ mailscanner/files/patch-lib__kaspersky-wrapper 2014-02-21 04:24:49.000000000 -0500
@@ -0,0 +1,50 @@
+--- ./lib/kaspersky-wrapper.orig 2011-08-20 08:32:02.000000000 -0400
++++ ./lib/kaspersky-wrapper 2014-02-21 04:22:39.000000000 -0500
+@@ -42,14 +42,13 @@
+ Scanner=kav4fs/bin/kav4fs-kavscanner
+ if [ -x ${PackageDir}/$Scanner ]; then
+ #Report=/tmp/kavoutput.tmp.$$
+- Report=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+ ScanOptions="-xp -i0" # Don't report progress, don't attempt to clean
+ if [ "x$1" = "x-IsItInstalled" ]; then
+ exit 0
+ fi
+
+ Args=`echo "$@" | sed -e 's/ -I/ -i/g; s/^-I/-i/g; s/-- / /g;'`
+- rm -f $Report
++ Report=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+ # 29/09/05 JKF Removed -j3 on advice from Kaspersky users
+ ${PackageDir}/$Scanner $ScanOptions -o$Report -q "$@"
+ cat $Report
+@@ -61,14 +60,13 @@
+ Scanner=kav4unix/bin/kavscanner
+ if [ -x ${PackageDir}/$Scanner ]; then
+ #Report=/tmp/kavoutput.tmp.$$
+- Report=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+ ScanOptions="-xp -i0" # Don't report progress, don't attempt to clean
+ if [ "x$1" = "x-IsItInstalled" ]; then
+ exit 0
+ fi
+
+ Args=`echo "$@" | sed -e 's/ -I/ -i/g; s/^-I/-i/g; s/-- / /g;'`
+- rm -f $Report
++ Report=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+ # 29/09/05 JKF Removed -j3 on advice from Kaspersky users
+ ${PackageDir}/$Scanner $ScanOptions -o$Report -q "$@"
+ cat $Report
+@@ -80,14 +78,13 @@
+ Scanner=bin/kavscanner
+ if [ -x ${PackageDir}/$Scanner ]; then
+ #Report=/tmp/kavoutput.tmp.$$
+- Report=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+ ScanOptions="-xp -i0" # Don't report progress, don't attempt to clean
+ if [ "x$1" = "x-IsItInstalled" ]; then
+ exit 0
+ fi
+
+ Args=`echo "$@" | sed -e 's/ -I/ -i/g; s/^-I/-i/g; s/-- / /g;'`
+- rm -f $Report
++ Report=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+ # 29/09/05 JKF Removed -j3 on advice from Kaspersky users
+ ${PackageDir}/$Scanner $ScanOptions -o$Report -q "$@"
+ cat $Report
diff -urN mailscanner.orig/files/patch-lib__trend-autoupdate mailscanner/files/patch-lib__trend-autoupdate
--- mailscanner.orig/files/patch-lib__trend-autoupdate 1969-12-31 19:00:00.000000000 -0500
+++ mailscanner/files/patch-lib__trend-autoupdate 2014-02-21 04:24:49.000000000 -0500
@@ -0,0 +1,11 @@
+--- ./lib/trend-autoupdate.orig 2011-08-20 08:27:46.000000000 -0400
++++ ./lib/trend-autoupdate 2014-02-21 04:24:23.000000000 -0500
+@@ -16,7 +16,7 @@
+ shift
+
+ #TEMPDIR=/tmp/trend-update.$$
+-TEMPDIR=$(mktemp) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
++TEMPDIR=$(mktemp -d) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
+ # In case it's a link
+ rm -f $TEMPDIR >/dev/null 2>&1
+ # In case it's a dir
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list