From dc2973ac8a948a7ea3db86b5bfeeb2889f9928cf Mon Sep 17 00:00:00 2001 From: Sergey Matveychuk Date: Fri, 6 May 2005 20:05:57 +0000 Subject: [PATCH] - Update to 3.0.3 (1) - Don't run spamd from root anymore. Use spamd user instead. Put PID file in /var/run/spamd/ as result. - A patch for fixing spamd that did not drop privileges for children (2) - Rename SQL variable to more clean SQL_FLAG. PR: ports/80556 (1) Submitted by: Linh Pham (1) Brandon Kuczenski (perl@) (2) Obtained from: http://bugzilla.spamassassin.org/show_bug.cgi?id=3897 (2) --- mail/p5-Mail-SpamAssassin/Makefile | 10 +++-- mail/p5-Mail-SpamAssassin/distinfo | 4 +- .../files/patch-spamd_spamd.raw | 22 +++++++++++ mail/p5-Mail-SpamAssassin/files/spamd.sh | 4 +- mail/p5-Mail-SpamAssassin/pkg-deinstall | 13 +++++++ mail/p5-Mail-SpamAssassin/pkg-install | 38 +++++++++++++++++++ mail/p5-Mail-SpamAssassin/pkg-plist | 2 + 7 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 mail/p5-Mail-SpamAssassin/files/patch-spamd_spamd.raw create mode 100644 mail/p5-Mail-SpamAssassin/pkg-deinstall create mode 100644 mail/p5-Mail-SpamAssassin/pkg-install diff --git a/mail/p5-Mail-SpamAssassin/Makefile b/mail/p5-Mail-SpamAssassin/Makefile index bae8937363a0..7b904da3a726 100644 --- a/mail/p5-Mail-SpamAssassin/Makefile +++ b/mail/p5-Mail-SpamAssassin/Makefile @@ -6,8 +6,7 @@ # PORTNAME= Mail-SpamAssassin -PORTVERSION= 3.0.2 -PORTREVISION= 1 +PORTVERSION= 3.0.3 CATEGORIES= mail perl5 MASTER_SITES= ${MASTER_SITE_APACHE:S/$/:apache/} ${MASTER_SITE_PERL_CPAN:S/$/:cpan/} MASTER_SITE_SUBDIR= spamassassin/:apache Mail/:cpan @@ -89,9 +88,9 @@ USE_RC_SUBR= yes SED_SCRIPT= -e 's|%%PREFIX%%|${PREFIX}|g' \ -e 's|%%RC_SUBR%%|${RC_SUBR}|g' .if defined(USE_SQLDB) -SED_SCRIPT+= -e 's|%%SQL%%|-Q|g' +SED_SCRIPT+= -e 's|%%SQL_FLAG%%|-Q|g' .else -SED_SCRIPT+= -e 's|%%SQL%%||g' +SED_SCRIPT+= -e 's|%%SQL_FLAG%%||g' .endif pre-patch: @@ -118,6 +117,9 @@ post-patch: post-build: @${SED} ${SED_SCRIPT} ${FILESDIR}/spamd.sh > ${WRKDIR}/sa-spamd.sh +pre-install: + @${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL + post-install: @${STRIP_CMD} ${PREFIX}/bin/spamc @${INSTALL_SCRIPT} ${WRKDIR}/sa-spamd.sh ${PREFIX}/etc/rc.d/sa-spamd.sh diff --git a/mail/p5-Mail-SpamAssassin/distinfo b/mail/p5-Mail-SpamAssassin/distinfo index 7aed82644a31..76f1a55e2a74 100644 --- a/mail/p5-Mail-SpamAssassin/distinfo +++ b/mail/p5-Mail-SpamAssassin/distinfo @@ -1,2 +1,2 @@ -MD5 (Mail-SpamAssassin-3.0.2.tar.gz) = 2a654d0819a730aab3fbbba83da62bc0 -SIZE (Mail-SpamAssassin-3.0.2.tar.gz) = 996164 +MD5 (Mail-SpamAssassin-3.0.3.tar.gz) = ca96f23cd1eb7d663ab55db98ef8090c +SIZE (Mail-SpamAssassin-3.0.3.tar.gz) = 999558 diff --git a/mail/p5-Mail-SpamAssassin/files/patch-spamd_spamd.raw b/mail/p5-Mail-SpamAssassin/files/patch-spamd_spamd.raw new file mode 100644 index 000000000000..db6f4a60ecda --- /dev/null +++ b/mail/p5-Mail-SpamAssassin/files/patch-spamd_spamd.raw @@ -0,0 +1,22 @@ +--- spamd/spamd.raw.orig Fri May 6 20:16:50 2005 ++++ spamd/spamd.raw Fri May 6 20:17:30 2005 +@@ -881,12 +881,14 @@ + } + + # if we changed UID during processing, change back! +- if ( $> != $< and $> != ( $< - 2**32 ) ) { +- $) = "$( $("; # change eGID +- $> = $<; # change eUID ++ if($setuid_to_user) { + if ( $> != $< and $> != ( $< - 2**32 ) ) { +- logmsg("fatal: return setuid failed"); +- die; # make it fatal to avoid security breaches ++ $) = "$( $("; # change eGID ++ $> = $<; # change eUID ++ if ( $> != $< and $> != ( $< - 2**32 ) ) { ++ logmsg("fatal: return setuid failed"); ++ die; # make it fatal to avoid security breaches ++ } + } + } + diff --git a/mail/p5-Mail-SpamAssassin/files/spamd.sh b/mail/p5-Mail-SpamAssassin/files/spamd.sh index ba814c492a90..40150d36ac27 100644 --- a/mail/p5-Mail-SpamAssassin/files/spamd.sh +++ b/mail/p5-Mail-SpamAssassin/files/spamd.sh @@ -34,8 +34,8 @@ stop_postcmd() # set defaults spamd_enable=${spamd_enable:-"NO"} -spamd_pidfile=${spamd_pidfile:-"/var/run/spamd.pid"} -spamd_flags=${spamd_flags:-"-c -d %%SQL%% -r ${spamd_pidfile}"} +spamd_pidfile=${spamd_pidfile:-"/var/run/spamd/spamd.pid"} +spamd_flags=${spamd_flags:-"-c -d %%SQL_FLAG%% -r ${spamd_pidfile} -u spamd -H /var/spool/spamd"} load_rc_config $name run_rc_command "$1" diff --git a/mail/p5-Mail-SpamAssassin/pkg-deinstall b/mail/p5-Mail-SpamAssassin/pkg-deinstall new file mode 100644 index 000000000000..494e9402eb30 --- /dev/null +++ b/mail/p5-Mail-SpamAssassin/pkg-deinstall @@ -0,0 +1,13 @@ +#!/bin/sh + +if [ "$2" != "POST-DEINSTALL" ]; then + exit 0 +fi + +USER=spamd + +if pw usershow "${USER}" 2>/dev/null 1>&2; then + echo "To delete ${USER} user permanently, use 'rmuser ${USER}'" +fi + +exit 0 diff --git a/mail/p5-Mail-SpamAssassin/pkg-install b/mail/p5-Mail-SpamAssassin/pkg-install new file mode 100644 index 000000000000..8b7f438d6749 --- /dev/null +++ b/mail/p5-Mail-SpamAssassin/pkg-install @@ -0,0 +1,38 @@ +#!/bin/sh + +if [ "$2" != "PRE-INSTALL" ]; then + exit 0 +fi + +USER=spamd +GROUP=${USER} +UID=58 +GID=${UID} +HOME=/var/spool/${USER} + +if ! pw groupshow "${GROUP}" 2>/dev/null 1>&2; then + if pw groupadd ${GROUP} -g ${GID}; then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + exit 1 + fi +fi + +if ! pw usershow "${USER}" 2>/dev/null 1>&2; then + if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \ + -s "/sbin/nologin" -d "${HOME}" \ + -c "SpamAssassin user"; \ + then + echo "Added user \"${USER}\"." + mkdir ${HOME} && chown ${USER}:${GROUP} ${HOME} + else + echo "Adding user \"${USER}\" failed..." + exit 1 + fi +fi + +# Create pid directory +mkdir /var/run/spamd && chown ${USER}:${GROUP} /var/run/spamd + +exit 0 diff --git a/mail/p5-Mail-SpamAssassin/pkg-plist b/mail/p5-Mail-SpamAssassin/pkg-plist index 94bb833bc716..0b244f395a5d 100644 --- a/mail/p5-Mail-SpamAssassin/pkg-plist +++ b/mail/p5-Mail-SpamAssassin/pkg-plist @@ -1,3 +1,4 @@ +@unexec %D/etc/rc.d/sa-spamd.sh stop > /dev/null 2>&1 || true bin/sa-learn bin/spamassassin bin/spamc @@ -92,3 +93,4 @@ etc/rc.d/sa-spamd.sh @unexec rmdir %D/%%SITE_PERL%%/Mail 2>/dev/null || true @unexec rmdir %D/etc/mail/spamassassin 2>/dev/null || true @unexec rmdir %D/etc/mail 2>/dev/null || true +@unexec rmdir /var/run/spamd 2>/dev/null || true