ports/57382: [PATCH] security/amavisd-new 20030616.p5
Martin Matuska
martin at tradex.sk
Tue Sep 30 00:50:26 UTC 2003
>Number: 57382
>Category: ports
>Synopsis: [PATCH] security/amavisd-new 20030616.p5
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Sep 29 17:50:21 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Martin Matuska <martin at tradex.sk>
>Release: FreeBSD 4.8-RELEASE-p10 i386
>Organization:
>Environment:
FreeBSD 4.8-RELEASE-p10 i386
>Description:
This patch changes the following:
a) rc_subr support - amavisd.sh, amavis-milter.sh
b) uses /var/run/amavis for PID storage by default
c) uses /var/log/amavis for LOG storage by default
>How-To-Repeat:
>Fix:
diff -Nbur amavisd-new.orig/Makefile amavisd-new/Makefile
--- amavisd-new.orig/Makefile Wed Aug 27 10:30:05 2003
+++ amavisd-new/Makefile Tue Sep 30 02:25:45 2003
@@ -8,6 +8,7 @@
PORTNAME= amavisd-new
PORTVERSION= 20030616.p5
+PORTREVISION= 1
CATEGORIES= security
MASTER_SITES= http://www.ijs.si/software/amavisd/
DISTNAME= ${PORTNAME}-${PORTVERSION:S/.p/-p/}
@@ -43,6 +44,8 @@
AMAVISUSER?= vscan
AMAVISGROUP?= vscan
AMAVISDIR?= /var/amavis
+AMAVISPIDDIR?= /var/run/amavis
+AMAVISLOGDIR?= /var/log/amavis
AMAVISQUARANTINE?= /var/virusmails
WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION:C/\.p.+//}
@@ -63,23 +66,38 @@
BUILD_WRKSRC= ${WRKSRC}/helper-progs
.endif
-pre-build:
- for file in amavisd.sh INSTALL DEINSTALL MESSAGE; do \
- ${SED} -e 's,%%AMAVISUSER%%,${AMAVISUSER},g' \
+SED_SCRIPT= -e 's,%%AMAVISUSER%%,${AMAVISUSER},g' \
-e 's,%%AMAVISGROUP%%,${AMAVISGROUP},g' \
-e 's,%%AMAVISDIR%%,${AMAVISDIR},g' \
+ -e 's,%%AMAVISPIDDIR%%,${AMAVISPIDDIR},g' \
+ -e 's,%%AMAVISLOGDIR%%,${AMAVISLOGDIR},g' \
-e 's,%%AMAVISQUARANTINE%%,${AMAVISQUARANTINE},g' \
-e 's,%%DOCSDIR%%,${DOCSDIR},g' \
- -e 's,%%PREFIX%%,${PREFIX},g' \
- < ${FILESDIR}/$${file}.tmpl > ${WRKDIR}/$${file}; \
- done
- for file in amavisd.conf amavisd; do \
- ${SED} -e 's,%%AMAVISUSER%%,${AMAVISUSER},g' \
+ -e 's,%%PREFIX%%,${PREFIX},g'
+
+SED_CONF= -e 's,%%AMAVISUSER%%,${AMAVISUSER},g' \
-e 's,%%AMAVISGROUP%%,${AMAVISGROUP},g' \
-e 's,%%AMAVISDIR%%,${AMAVISDIR},g' \
+ -e 's,%%AMAVISPIDDIR%%,${AMAVISPIDDIR},g' \
+ -e 's,%%AMAVISLOGDIR%%,${AMAVISLOGDIR},g' \
-e 's,%%AMAVISQUARANTINE%%,${AMAVISQUARANTINE},g' \
- -e 's,%%PREFIX%%,${PREFIX},g' \
- < ${WRKSRC}/$${file} > ${WRKDIR}/$${file}; \
+ -e 's,%%PREFIX%%,${PREFIX},g'
+
+USE_RC_SUBR= yes
+RC_DIR= ${PREFIX}/etc/rc.d
+RC_SUFX= .sh
+SED_SCRIPT+= -e 's|%%RC_SUBR%%|${RC_SUBR}|g' \
+ -e 's|%%RC_DIR%%|${RC_DIR}|g' \
+ -e 's|%%RC_SUFX%%|${RC_SUFX}|g'
+PLIST_SUB+= RC_DIR=${RC_DIR} \
+ RC_SUFX=${RC_SUFX}
+
+pre-build:
+ for file in amavisd.sh amavis-milter.sh INSTALL DEINSTALL MESSAGE; do \
+ ${SED} ${SED_SCRIPT} < ${FILESDIR}/$${file}.tmpl > ${WRKDIR}/$${file}; \
+ done
+ for file in amavisd.conf amavisd; do \
+ ${SED} ${SED_CONF} < ${WRKSRC}/$${file} > ${WRKDIR}/$${file}; \
done
pre-install:
@@ -92,7 +110,8 @@
.endif
${INSTALL_SCRIPT} ${WRKDIR}/amavisd ${PREFIX}/sbin
${INSTALL_SCRIPT} ${WRKDIR}/amavisd.conf ${PREFIX}/etc/amavisd.conf-dist
- ${INSTALL_SCRIPT} ${WRKDIR}/amavisd.sh ${PREFIX}/etc/rc.d
+ ${INSTALL_SCRIPT} ${WRKDIR}/amavisd.sh ${PREFIX}/etc/rc.d/amavisd${RC_SUFX}
+ ${INSTALL_SCRIPT} ${WRKDIR}/amavis-milter.sh ${PREFIX}/etc/rc.d/amavis-milter${RC_SUFX}
.if !defined(NOPORTDOCS)
@${MKDIR} ${DOCSDIR}
.for FILE in AAAREADME.first INSTALL LICENSE RELEASE_NOTES README_FILES/*
diff -Nbur amavisd-new.orig/files/DEINSTALL.tmpl amavisd-new/files/DEINSTALL.tmpl
--- amavisd-new.orig/files/DEINSTALL.tmpl Sun Apr 20 12:02:44 2003
+++ amavisd-new/files/DEINSTALL.tmpl Tue Sep 30 02:25:45 2003
@@ -7,6 +7,8 @@
GROUP=%%AMAVISGROUP%%
DIR=%%AMAVISDIR%%
QUARANTINE=%%AMAVISQUARANTINE%%
+LOGDIR=%%AMAVISLOGDIR%%
+PIDDIR=%%AMAVISPIDDIR%%
if [ "$2" = "POST-DEINSTALL" ]; then
@@ -24,5 +26,13 @@
if [ -e ${QUARANTINE} ]; then
echo "You should manually remove the \"${QUARANTINE}\" directory."
+ fi
+
+ if [ -e ${LOGDIR} ]; then
+ echo "You should manually remove the \"${LOGDIR}\" directory."
+ fi
+
+ if [ -e ${PIDDIR} ]; then
+ echo "You should manually remove the \"${PIDDIR}\" directory."
fi
fi
diff -Nbur amavisd-new.orig/files/INSTALL.tmpl amavisd-new/files/INSTALL.tmpl
--- amavisd-new.orig/files/INSTALL.tmpl Sat Jan 4 11:59:25 2003
+++ amavisd-new/files/INSTALL.tmpl Tue Sep 30 02:25:45 2003
@@ -7,6 +7,8 @@
GROUP=%%AMAVISGROUP%%
DIR=%%AMAVISDIR%%
QUARANTINE=%%AMAVISQUARANTINE%%
+LOGDIR=%%AMAVISLOGDIR%%
+PIDDIR=%%AMAVISPIDDIR%%
if [ "$2" = "PRE-INSTALL" ]; then
@@ -43,4 +45,8 @@
echo "Created \"${DIR}\" directory."
/usr/bin/install -o ${USER} -g ${GROUP} -m 750 -d ${QUARANTINE}
echo "Created \"${QUARANTINE}\" directory."
+ /usr/bin/install -o ${USER} -g ${GROUP} -m 750 -d ${LOGDIR}
+ echo "Created \"${LOGDIR}\" directory."
+ /usr/bin/install -o ${USER} -g ${GROUP} -m 750 -d ${PIDDIR}
+ echo "Created \"${PIDDIR}\" directory."
fi
diff -Nbur amavisd-new.orig/files/MESSAGE.tmpl amavisd-new/files/MESSAGE.tmpl
--- amavisd-new.orig/files/MESSAGE.tmpl Sat Jan 4 11:59:25 2003
+++ amavisd-new/files/MESSAGE.tmpl Tue Sep 30 02:25:45 2003
@@ -2,14 +2,19 @@
*******************************************************************
To use amavisd-new, you need to install at least one virus scanner.
For example McAfee VirusScan is available as a FreeBSD port
- in /usr/ports/security/vscan. If you want to use the amavis sendmail
- milter interface, you need to type the following command:
+ in /usr/ports/security/vscan.
- touch %%AMAVISDIR%%/use.milter
+ Enable amavisd-new in /etc/rc.conf with the following line:
+
+ amavisd_enable="YES"
+
+ If you want to use the amavis sendmail milter interface,
+ you need the following additional line in /etc/rc.conf
+
+ amavis_milter_enable="YES"
A configuration template is available in %%PREFIX%%/etc
as amavisd.conf-dist. Copy it to amavisd.conf and edit it to
suit your needs. Documentation is available in
%%DOCSDIR%%.
*******************************************************************
-
diff -Nbur amavisd-new.orig/files/amavis-milter.sh.tmpl amavisd-new/files/amavis-milter.sh.tmpl
--- amavisd-new.orig/files/amavis-milter.sh.tmpl Thu Jan 1 01:00:00 1970
+++ amavisd-new/files/amavis-milter.sh.tmpl Tue Sep 30 02:25:45 2003
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: amavis_milter
+# REQUIRE: amavisd
+# BEFORE: amavisd
+# KEYWORD: FreeBSD shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable amavis-milter:
+#
+#amavis_milter_enable="YES"
+#
+
+. %%RC_SUBR%%
+
+name=amavis_milter
+rcvar=`set_rcvar`
+
+command=%%PREFIX%%/sbin/amavis-milter
+
+amavis_milter_user=%%AMAVISUSER%%
+
+required_files=%%PREFIX%%/etc/amavisd.conf
+
+# set defaults
+
+amavis_milter_enable=${amavis_milter_enable:-"NO"}
+amavis_milter_flags=${amavis_milter_flags:-"-D -p %%AMAVISDIR%%/amavis-milter.sock"}
+
+load_rc_config $name
+run_rc_command "$1"
diff -Nbur amavisd-new.orig/files/amavisd.sh.tmpl amavisd-new/files/amavisd.sh.tmpl
--- amavisd-new.orig/files/amavisd.sh.tmpl Fri May 16 04:54:14 2003
+++ amavisd-new/files/amavisd.sh.tmpl Tue Sep 30 02:25:45 2003
@@ -1,36 +1,42 @@
#!/bin/sh
+#
+# $FreeBSD: ports/security/clamav/files/amavisd.sh,v 1.1 2003/09/28 13:29:28 dinoex Exp $
+#
-if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
- echo "$0: Cannot determine the PREFIX" >&2
- exit 1
-fi
-
-DIR=%%AMAVISDIR%%
-PIDFILE=$DIR/amavisd.pid
-SOCKFILES=$DIR/amavis*.sock
-MILTERFLAG=$DIR/use.milter
-
-case "$1" in
-start)
- if [ -e ${PREFIX}/etc/amavisd.conf ]; then
- rm -rf ${SOCKFILES}
- if [ -e $MILTERFLAG ]; then
- su %%AMAVISUSER%% -c "${PREFIX}/sbin/amavis-milter -D -p $DIR/amavis-milter.sock"
- fi
- su %%AMAVISUSER%% -c "${PREFIX}/sbin/amavisd > /dev/null 2>&1" && echo -n ' amavisd'
- fi
- ;;
-stop)
- if [ -e $MILTERFLAG ]; then
- killall -u %%AMAVISUSER%% amavis-milter >/dev/null 2>&1
- fi
- if [ -e $PIDFILE ]; then
- su %%AMAVISUSER%% -c "kill `cat $PIDFILE`" && echo -n ' amavisd'
- fi
- ;;
-*)
- echo "Usage: `basename $0` {start|stop}" >&2
- ;;
-esac
+# PROVIDE: amavisd
+# REQUIRE: LOGIN
+# BEFORE: mail
+# KEYWORD: FreeBSD shutdown
-exit 0
+#
+# Add the following lines to /etc/rc.conf to enable amavisd:
+#
+#amavisd_enable="YES"
+#
+
+. %%RC_SUBR%%
+
+name=amavisd
+rcvar=`set_rcvar`
+
+command=%%PREFIX%%/sbin/amavisd > /dev/null 2>&1
+
+amavisd_user=%%AMAVISUSER%%
+
+pidfile=%%AMAVISPIDDIR%%/amavisd.pid
+required_files=%%PREFIX%%/etc/amavisd.conf
+
+stop_postcmd=stop_postcmd
+
+stop_postcmd()
+{
+ rm -f $pidfile
+}
+
+# set defaults
+
+amavisd_enable=${amavisd_enable:-"NO"}
+amavisd_flags=${amavisd_flags:-""}
+
+load_rc_config $name
+run_rc_command "$1"
diff -Nbur amavisd-new.orig/files/patch-amavisd.conf amavisd-new/files/patch-amavisd.conf
--- amavisd-new.orig/files/patch-amavisd.conf Tue Jul 1 11:41:37 2003
+++ amavisd-new/files/patch-amavisd.conf Tue Sep 30 02:25:45 2003
@@ -1,5 +1,5 @@
---- amavisd.conf.orig Wed Jun 25 17:22:46 2003
-+++ amavisd.conf Wed Jun 25 17:26:42 2003
+--- amavisd.conf.orig Mon Aug 25 14:59:16 2003
++++ amavisd.conf Tue Sep 30 01:37:47 2003
@@ -51,7 +51,7 @@
# $MYHOME serves as a quick default for some other configuration settings.
# More refined control is available with each individual setting further down.
@@ -20,6 +20,24 @@
# Runtime working directory (cwd), and a place where
# temporary directories for unpacking mail are created.
+@@ -76,7 +76,7 @@
+
+ #$daemon_chroot_dir = $MYHOME; # (default is undef, meaning: do not chroot)
+
+-#$pid_file = "$MYHOME/amavisd.pid"; # (default is "$MYHOME/amavisd.pid")
++$pid_file = "%%AMAVISPIDDIR%%/amavisd.pid"; # (default is "$MYHOME/amavisd.pid")
+ #$lock_file = "$MYHOME/amavisd.lock"; # (default is "$MYHOME/amavisd.lock")
+
+ # set environment variables if you want (no defaults):
+@@ -262,7 +262,7 @@
+ #$SYSLOG_LEVEL = 'user.info'; # (defaults to 'mail.info')
+
+ # Log file (if not using syslog)
+-$LOGFILE = "$MYHOME/amavis.log"; # (defaults to empty, no log)
++$LOGFILE = "%%AMAVISLOGDIR%%/amavis.log"; # (defaults to empty, no log)
+
+ #NOTE: levels are not strictly observed and are somewhat arbitrary
+ # 0: startup/exit/failure messages, viruses detected
@@ -271,7 +271,7 @@
# 3: server, client
# 4: decompose parts
@@ -27,9 +45,9 @@
-$log_level = 2; # (defaults to 0)
+$log_level = 0; # (defaults to 0)
- # Customizeable template for the most interesting log file entry (e.g. with
+ # Customizable template for the most interesting log file entry (e.g. with
# $log_level=0) (take care to properly quote Perl special characters like '\')
-@@ -496,7 +496,7 @@
+@@ -498,7 +498,7 @@
# or a directory (no trailing slash)
# (the default value is undef, meaning no quarantine)
#
diff -Nbur amavisd-new.orig/pkg-plist amavisd-new/pkg-plist
--- amavisd-new.orig/pkg-plist Wed Aug 27 10:30:05 2003
+++ amavisd-new/pkg-plist Tue Sep 30 02:25:45 2003
@@ -19,7 +19,8 @@
%%PORTDOCS%%%%DOCSDIR%%/RELEASE_NOTES
%%PORTDOCS%%@dirrm %%DOCSDIR%%
etc/amavisd.conf-dist
-etc/rc.d/amavisd.sh
+etc/rc.d/amavis-milter%%RC_SUFX%%
+etc/rc.d/amavisd%%RC_SUFX%%
%%AMAVIS_NOMILTER%%sbin/amavis
%%AMAVIS_NOMILTER%%sbin/amavis-milter
sbin/amavisd
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list