Update to 4.84.6

Fix temporary file bugs
Pointed out by:	brad@comstyle.com

PR:		ports/187005
Submitted by:	Kevin Kobb (maintainer)

Style and shebang fixes and stage.
This commit is contained in:
Chris Rees 2014-02-28 20:04:59 +00:00
parent 630785f97e
commit 02314e3ece
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=346574
7 changed files with 212 additions and 69 deletions

View file

@ -2,8 +2,8 @@
# $FreeBSD$
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,9 +38,12 @@ RUN_DEPENDS:= ${BUILD_DEPENDS} \
CONFLICTS= MailScanner-devel-[0-9]*
PATCHLEVEL= 2
PATCHLEVEL= 1
USES= perl5
USES= perl5 shebangfix
SHEBANG_FILES= bin/[^c]* bin/clean* \
lib/[^M]* lib/${PORTNAME}/[^C]* lib/${PORTNAME}/*.p[ml] \
lib/${PORTNAME}.pm lib/${PORTNAME}/CustomFunctions/*
WRKSRC= ${WRKDIR}/${PORTNAME}-install-${PORTVERSION}
SUB_FILES= MailScanner.8 pkg-message pkg-install pkg-deinstall
@ -51,9 +54,6 @@ SUB_LIST= DATADIR=${DATADIR} \
ETC_FILES="${ETC_FILES}" \
MCP_FILES="${MCP_FILES}"
MAN8= MailScanner.8
MLINKS= MailScanner.8 mailscanner.8
OPTIONS_DEFINE= SPAMASSASSIN CLAMAV CLAMAVMODULE BDC
SPAMASSASSIN_DESC= Install SpamAssassin
CLAMAV_DESC= Install ClamAV
@ -62,7 +62,6 @@ BDC_DESC= Install BitDefender
OPTIONS_DEFAULT= SPAMASSASSIN CLAMAV
NO_STAGE= yes
.include <bsd.port.options.mk>
.if ${PORT_OPTIONS:MSPAMASSASSIN}
@ -202,16 +201,16 @@ do-build:
do-install:
@${ECHO_MSG} -n ">> Installing files in ${PREFIX}/sbin..."
@${INSTALL_SCRIPT} ${WRKSRC}/bin/MailScanner ${PREFIX}/sbin/mailscanner
@${LN} -s ${PREFIX}/sbin/mailscanner ${PREFIX}/sbin/MailScanner
${INSTALL_SCRIPT} ${WRKSRC}/bin/MailScanner ${STAGEDIR}${PREFIX}/sbin/mailscanner
${LN} -sf ${PREFIX}/sbin/mailscanner ${STAGEDIR}${PREFIX}/sbin/MailScanner
@${ECHO_MSG} " [DONE]"
@${ECHO_MSG} -n \
">> Installing files in ${PREFIX}/libexec/MailScanner..."
@${MKDIR} -m ${BINMODE} ${PREFIX}/libexec/MailScanner
@cd ${WRKSRC}/lib && ${FIND} * -name "*-wrapper" -exec \
${INSTALL_SCRIPT} {} ${PREFIX}/libexec/MailScanner/{}.sample \;
@cd ${WRKSRC}/lib && ${FIND} * -name "*-autoupdate" -exec \
${INSTALL_SCRIPT} {} ${PREFIX}/libexec/MailScanner/{}.sample \;
${MKDIR} ${STAGEDIR}${PREFIX}/libexec/MailScanner
cd ${WRKSRC}/lib && ${FIND} * -name "*-wrapper" -exec \
${INSTALL_SCRIPT} {} ${STAGEDIR}${PREFIX}/libexec/MailScanner/{}.sample \;
cd ${WRKSRC}/lib && ${FIND} * -name "*-autoupdate" -exec \
${INSTALL_SCRIPT} {} ${STAGEDIR}${PREFIX}/libexec/MailScanner/{}.sample \;
.for FILE in analyse_SpamAssassin_cache clean.SA.cache clean.quarantine \
mailscanner_create_locks processing_messages_alert Quick.Peek \
update_bad_phishing_emails update_phishing_sites \
@ -219,74 +218,72 @@ do-install:
cron/update_bad_phishing_sites.cron update_virus_scanners \
cron/update_virus_scanners.cron update_spamassassin \
cron/update_spamassassin.cron
@${INSTALL_SCRIPT} ${WRKSRC}/bin/${FILE} \
${PREFIX}/libexec/MailScanner/
${INSTALL_SCRIPT} ${WRKSRC}/bin/${FILE} \
${STAGEDIR}${PREFIX}/libexec/MailScanner/
.endfor
@${ECHO_MSG} " [DONE]"
@${ECHO_MSG} -n ">> Installing files in ${PREFIX}/etc/MailScanner..."
@${MKDIR} -m ${BINMODE} ${PREFIX}/etc/MailScanner
${MKDIR} ${STAGEDIR}${PREFIX}/etc/MailScanner
.for FILE in ${ETC_FILES}
@${INSTALL_DATA} ${WRKSRC}/etc/${FILE} \
${PREFIX}/etc/MailScanner/${FILE}.sample
${INSTALL_DATA} ${WRKSRC}/etc/${FILE} \
${STAGEDIR}${PREFIX}/etc/MailScanner/${FILE}.sample
.endfor
@${MKDIR} ${PREFIX}/etc/MailScanner/rules
@cd ${WRKSRC}/etc/rules \
${MKDIR} ${STAGEDIR}${PREFIX}/etc/MailScanner/rules
cd ${WRKSRC}/etc/rules \
&& ${INSTALL_DATA} EXAMPLES README \
${PREFIX}/etc/MailScanner/rules
${STAGEDIR}${PREFIX}/etc/MailScanner/rules
.for RULES in spam.whitelist.rules bounce.rules max.message.size.rules
@${INSTALL_DATA} ${WRKSRC}/etc/rules/${RULES} \
${PREFIX}/etc/MailScanner/rules/${RULES}.sample
${INSTALL_DATA} ${WRKSRC}/etc/rules/${RULES} \
${STAGEDIR}${PREFIX}/etc/MailScanner/rules/${RULES}.sample
.endfor
@${MKDIR} -m ${BINMODE} ${PREFIX}/etc/MailScanner/mcp
${MKDIR} ${STAGEDIR}${PREFIX}/etc/MailScanner/mcp
.for FILE in ${MCP_FILES}
@${INSTALL_DATA} ${WRKSRC}/etc/mcp/${FILE} \
${PREFIX}/etc/MailScanner/mcp/${FILE}.sample
${INSTALL_DATA} ${WRKSRC}/etc/mcp/${FILE} \
${STAGEDIR}${PREFIX}/etc/MailScanner/mcp/${FILE}.sample
.endfor
@${MKDIR} ${PREFIX}/etc/MailScanner/conf.d
@${INSTALL_DATA} ${WRKSRC}/etc/conf.d/README \
${PREFIX}/etc/MailScanner/conf.d/README
${MKDIR} ${STAGEDIR}${PREFIX}/etc/MailScanner/conf.d
${INSTALL_DATA} ${WRKSRC}/etc/conf.d/README \
${STAGEDIR}${PREFIX}/etc/MailScanner/conf.d/README
@${ECHO_MSG} " [DONE]"
@${ECHO_MSG} -n ">> Installing files in ${DATADIR}..."
@${MKDIR} ${DATADIR}
@cd ${WRKSRC}/etc && ${FIND} reports -type d ! -name "*.old" -exec \
${MKDIR} -m ${BINMODE} ${DATADIR}/{} \;
@cd ${WRKSRC}/etc \
${MKDIR} ${STAGEDIR}${DATADIR}
cd ${WRKSRC}/etc && ${FIND} reports -type d ! -name "*.old" -exec \
${MKDIR} ${STAGEDIR}${DATADIR}/{} \;
cd ${WRKSRC}/etc \
&& ${FIND} reports \( -type d -name "*.old" -prune \) \
-o \( -type f ! \( -name "*.orig" -o -name "*.bak" \) \
-exec ${INSTALL_DATA} {} ${DATADIR}/{}.sample \; \)
@${INSTALL_SCRIPT} ${WRKSRC}/bin/upgrade_MailScanner_conf ${DATADIR}
@${LN} -s ${DATADIR}/upgrade_MailScanner_conf \
${DATADIR}/upgrade_languages_conf
-exec ${INSTALL_DATA} {} ${STAGEDIR}${DATADIR}/{}.sample \; \)
${INSTALL_SCRIPT} ${WRKSRC}/bin/upgrade_MailScanner_conf \
${STAGEDIR}${DATADIR}
${LN} -sf ${DATADIR}/upgrade_MailScanner_conf \
${STAGEDIR}${DATADIR}/upgrade_languages_conf
@${ECHO_MSG} " [DONE]"
@${ECHO_MSG} -n ">> Installing files in ${PREFIX}/lib..."
@${MKDIR} ${PREFIX}/lib/MailScanner/MailScanner/CustomFunctions
@${INSTALL_SCRIPT} ${WRKSRC}/lib/MailScanner.pm \
${PREFIX}/lib/MailScanner/MailScanner.pm
@cd ${WRKSRC}/lib/MailScanner \
${MKDIR} ${STAGEDIR}${PREFIX}/lib/MailScanner/MailScanner/CustomFunctions
${INSTALL_SCRIPT} ${WRKSRC}/lib/MailScanner.pm \
${STAGEDIR}${PREFIX}/lib/MailScanner/MailScanner.pm
cd ${WRKSRC}/lib/MailScanner \
&& ${FIND} * -type f ! -name "*.orig" -exec \
${INSTALL_SCRIPT} {} ${PREFIX}/lib/MailScanner/MailScanner/{} \;
${INSTALL_SCRIPT} {} ${STAGEDIR}${PREFIX}/lib/MailScanner/MailScanner/{} \;
@${ECHO_MSG} " [DONE]"
.if ${PORT_OPTIONS:MDOCS}
@${ECHO_MSG} -n ">> Installing docs and manpage..."
@${MKDIR} ${DOCSDIR}
@${INSTALL_DATA} ${FILESDIR}/README.FreeBSD.port ${DOCSDIR}
@${INSTALL_SCRIPT} ${FILESDIR}/Sophos.install.freebsd ${DOCSDIR}
@cd ${WRKSRC} && ${INSTALL_DATA} ${DOC_FILES} ${DOCSDIR}
${MKDIR} ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${FILESDIR}/README.FreeBSD.port ${STAGEDIR}${DOCSDIR}
${INSTALL_SCRIPT} ${FILESDIR}/Sophos.install.freebsd ${STAGEDIR}${DOCSDIR}
cd ${WRKSRC} && ${INSTALL_DATA} ${DOC_FILES} ${STAGEDIR}${DOCSDIR}
@${REINPLACE_CMD} \
-e 's,%%LOCALBASE%%,${LOCALBASE},' \
-e 's,%%PREFIX%%,${PREFIX},' \
${DOCSDIR}/Sophos.install.freebsd
@${RM} -f ${DOCSDIR}/Sophos.install.freebsd.bak
${STAGEDIR}${DOCSDIR}/Sophos.install.freebsd
@${RM} -f ${STAGEDIR}${DOCSDIR}/Sophos.install.freebsd.bak
.else
@${ECHO_MSG} -n ">> Installing manpage..."
.endif
@cd ${WRKDIR} && \
${INSTALL_MAN} ${MAN8} ${MAN5PREFIX}/man/man8
cd ${WRKDIR} && \
${INSTALL_MAN} ${PORTNAME}.8 ${STAGEDIR}${PREFIX}/man/man8
${LN} -sf ${PREFIX}/man/man8/${PORTNAME}.8 \
${STAGEDIR}${PREFIX}/man/man8/${PORTNAME:L}.8
@${ECHO_MSG} " [DONE]"
post-install:
@${SETENV} PKG_PREFIX=${PREFIX} \
${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
@${CAT} ${PKGMESSAGE}
.include <bsd.port.mk>

View file

@ -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

View file

@ -1,3 +1,17 @@
Version 4.84.6
==============
- Upgrade to 4.84.6
- Added some patches for tmp file bugs
reported/provided by brad@comstyle.com
from the OpenBSD port and GitHub repository.
Version 4.84.6
==============
- Upgrade to 4.84.6
- Added some patches for tmp file bugs
reported/provided by brad@comstyle.com
from the OpenBSD port and GitHub repository.
Version 4.84.5_3 (not bumped)
================
- Use OptionsNG

View file

@ -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";

View file

@ -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;

View file

@ -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",

View file

@ -134,6 +134,8 @@ libexec/MailScanner/vba32-autoupdate.sample
libexec/MailScanner/vba32-wrapper.sample
libexec/MailScanner/vexira-autoupdate.sample
libexec/MailScanner/vexira-wrapper.sample
man/man8/MailScanner.8.gz
man/man8/mailscanner.8.gz
sbin/mailscanner
sbin/MailScanner
%%DATADIR%%/reports/ca/rejection.report.txt.sample