Skip site navigation (1)Skip section navigation (2)
Date:      Tue,  7 May 2013 14:30:18 +0000 (UTC)
From:      Nikolai Lifanov <lifanov@mail.lifanov.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/178400: [patch] mail/postgrey shebangfix
Message-ID:  <20130507143018.B10A31A1F64@mail.lifanov.com>
Resent-Message-ID: <201305071440.r47Ee0om054488@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         178400
>Category:       ports
>Synopsis:       [patch] mail/postgrey shebangfix
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 07 14:40:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Nikolai Lifanov
>Release:        FreeBSD 9.1-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD mail.lifanov.com 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec 4 09:23:10 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
	postgrey hardcodes perl location as "/usr/bin/perl".
	This doesn't account for situations where perl package is compiled
	without the symlink OPTION, which is necessary when /usr is read-only.

	The user, after every package installation has to replace the shebang
	with the appropriate location before restarting the service, or
	otherwise the MTA that uses postgrey might end up rejecting all mail.

	Until now, there was no easy way to stop users that install the package
	from shooting themselves in the foot.
>How-To-Repeat:
	* compile perl without USE_PERL option
	* compile postgrey
	* install postgrey
	* use postgrey with an MTA
>Fix:
	See the patch attached. It makes use of USES=shebangfix to solve the
	problem. Also, I converted the Makefile header.

--- postgrey.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	postgrey
#	postgrey/files
#	postgrey/files/postgrey.in
#	postgrey/files/pkg-install.in
#	postgrey/pkg-plist
#	postgrey/distinfo
#	postgrey/Makefile
#	postgrey/pkg-descr
#
echo c - postgrey
mkdir -p postgrey > /dev/null 2>&1
echo c - postgrey/files
mkdir -p postgrey/files > /dev/null 2>&1
echo x - postgrey/files/postgrey.in
sed 's/^X//' >postgrey/files/postgrey.in << 'b9ac248ee4d3f60fd038188546836856'
X#!/bin/sh
X# $FreeBSD: head/mail/postgrey/files/postgrey.in 300896 2012-07-14 13:54:48Z beat $
X#
X
X# PROVIDE: postgrey
X# REQUIRE: LOGIN
X# BEFORE: mail
X# KEYWORD: shutdown
X
X#
X# Add the following lines to /etc/rc.conf to enable postgrey:
X#
X# postgrey_enable="YES"
X#
X# See perldoc postgrey for flags
X#
X
X. /etc/rc.subr
X
Xname=postgrey
Xrcvar=postgrey_enable
X
Xcommand=%%PREFIX%%/sbin/postgrey
Xrequired_dirs=/var/db/postgrey
Xextra_commands=reload
X
Xstop_postcmd=stop_postcmd
X
Xstop_postcmd()
X{
X  rm -f $pidfile
X}
X
X# set defaults
X
Xload_rc_config $name
X
Xpostgrey_enable=${postgrey_enable:-"NO"}
Xpostgrey_greylist_header=${postgrey_greylist_header:-"X-Greylist: delayed %t seconds by postgrey-%v at %h\; %d"}
Xpostgrey_pidfile=${postgrey_pidfile:-"/var/run/postgrey.pid"}
Xpostgrey_flags=${postgrey_flags:-"--pidfile=${postgrey_pidfile} \
X	--inet=10023 -d --user=%%USER%% --group=%%GROUP%% --dbdir=/var/db/postgrey \
X	--x-greylist-header=${postgrey_greylist_header}"}
X
Xpidfile="${postgrey_pidfile}"
X
Xrun_rc_command "$1"
b9ac248ee4d3f60fd038188546836856
echo x - postgrey/files/pkg-install.in
sed 's/^X//' >postgrey/files/pkg-install.in << 'd450ee948617a016209f77dcb37cb116'
X#! /bin/sh
X#
X# $FreeBSD: /tmp/pcvs/ports/mail/postgrey/files/pkg-install.in,v 1.6 2012-04-18 07:54:30 crees Exp $
X
XPATH=/bin:/usr/bin:/usr/sbin
X
Xcase $2 in
X
XPRE-INSTALL)
X  echo "---> Starting install script:"
X
X  if [ -z "%%POSTGREYDIR%%" -o \
X       -z "%%USER%%" -o -z "%%GROUP%%" -o \
X       -z "%%UID%%" -o -z "%%GID%%" ]; then
X    echo "ERROR: A required pragma was empty"
X    exit 1
X  fi
X
X  ;;
X
XPOST-INSTALL)
X  echo "---> Starting post-install script:"
X
X  # Create home directory if required
X  if [ -d "%%POSTGREYDIR%%" ]; then
X    echo "---> Using existing Postgrey database directory (%%POSTGREYDIR%%)"
X    echo "     (There may be existing active postgrey databases - this installation"
X    echo "     will attempt to preserve them.)"
X  else
X    echo "---> Creating Postgrey database directory (%%POSTGREYDIR%%)"
X    (umask 002 && /bin/mkdir -p "%%POSTGREYDIR%%") || exit 1
X    /usr/sbin/chown -R "%%USER%%:%%GROUP%%" "%%POSTGREYDIR%%" || exit 1
X    /bin/chmod g+s "%%POSTGREYDIR%%" || exit 1
X  fi
X
X  for i in %%ETCFILES%%; do
X    if [ ! -f "%%PREFIX%%/etc/postfix/postgrey_${i}" ]; then
X	echo "---> Installing new config file %%PREFIX%%/etc/postfix/postgrey_${i}"
X	cp -p	%%PREFIX%%/etc/postfix/dist-postgrey_${i} \
X		%%PREFIX%%/etc/postfix/postgrey_${i}
X    else
X	echo "---> Keeping existing config file %%PREFIX%%/etc/postfix/postgrey_${i}"
X    fi
X  done
X  ;;
X
Xesac
d450ee948617a016209f77dcb37cb116
echo x - postgrey/pkg-plist
sed 's/^X//' >postgrey/pkg-plist << 'deb1067e69ea21e4e981c3454d6f91aa'
X@unexec if cmp -s %D/etc/postfix/dist-postgrey_whitelist_recipients %D/etc/postfix/postgrey_whitelist_recipients; then rm -f %D/etc/postfix/postgrey_whitelist_recipients; fi
X@unexec if cmp -s %D/etc/postfix/dist-postgrey_whitelist_clients %D/etc/postfix/postgrey_whitelist_clients; then rm -f %D/etc/postfix/postgrey_whitelist_clients; fi
Xsbin/postgrey
Xsbin/policy-test
Xsbin/postgreyreport
Xetc/postfix/dist-postgrey_whitelist_recipients
Xetc/postfix/dist-postgrey_whitelist_clients
X@dirrmtry etc/postfix
X@unexec rmdir /var/db/postgrey 2>/dev/null || true
deb1067e69ea21e4e981c3454d6f91aa
echo x - postgrey/distinfo
sed 's/^X//' >postgrey/distinfo << '9b67ee39cd06d0bcc401f341edb9eb9c'
XSHA256 (postgrey-1.34.tar.gz) = 9a9ee2f4e3cbbf15642e47802407c810ac5c54f0ad1572ebec3f0f645eb35707
XSIZE (postgrey-1.34.tar.gz) = 36399
9b67ee39cd06d0bcc401f341edb9eb9c
echo x - postgrey/Makefile
sed 's/^X//' >postgrey/Makefile << '854c7eae4c26d2f798e6d679b8c6b91f'
X# Created by: Will Andrews <will@FreeBSD.org>
X# $FreeBSD$
X
XPORTNAME=	postgrey
XPORTVERSION=	1.34
XPORTREVISION=	5
XCATEGORIES=	mail
XMASTER_SITES=	http://postgrey.schweikert.ch/pub/ \
X		http://postgrey.schweikert.ch/pub/old/
X
XMAINTAINER=	ports.maintainer@evilphi.com
XCOMMENT=	Greylisting policy server for Postfix
X
XRUN_DEPENDS=	p5-Net-Server>=0:${PORTSDIR}/net/p5-Net-Server \
X		p5-IO-Multiplex>=0:${PORTSDIR}/devel/p5-IO-Multiplex \
X		p5-Parse-Syslog>=0:${PORTSDIR}/textproc/p5-Parse-Syslog \
X		p5-BerkeleyDB>=0:${PORTSDIR}/databases/p5-BerkeleyDB \
X		p5-Net-DNS>=0:${PORTSDIR}/dns/p5-Net-DNS
X
XUSE_PERL5_RUN=	yes
XUSE_RC_SUBR=	${PORTNAME}
XNO_BUILD=	yes
XPOD2MAN?=	pod2man
XPORTDOCS=	README Changes README.exim
XSUB_FILES=	pkg-install
XSUB_LIST=	USER=${PGY_USERNAME} UID=${PGY_USERID} GROUP=${PGY_GROUPNAME} \
X		GID=${PGY_GROUPID} ETCFILES="${ETCFILES}" \
X		POSTGREYDIR=${PGY_DIR}
XETCFILES=	whitelist_clients whitelist_recipients
XPGY_USERNAME?=	postgrey
XPGY_USERID?=	225
XPGY_GROUPNAME?=	${PGY_USERNAME}
XPGY_GROUPID?=	${PGY_USERID}
XPGY_DIR?=	/var/db/postgrey
X
XUSERS=		${PGY_USERNAME}
XGROUPS=		${PGY_GROUPNAME}
XMAN1=		${PORTNAME}.1 policy-test.1 postgreyreport.1
X
XUSES=shebangfix
XSHEBANG_FILES=	${WRKSRC}/postgrey
X
Xpost-patch:
X	@${REINPLACE_CMD} -e 's#/etc/main.cf#/etc/postfix/main.cf#' ${WRKSRC}/postgrey
X	@${REINPLACE_CMD} -e 's#/etc/postfix#${PREFIX}&#' ${WRKSRC}/postgrey ${WRKSRC}/postgrey_whitelist_*
X	@${REINPLACE_CMD} -e 's#/var/spool/postfix/postgrey#${PGY_DIR}#' ${WRKSRC}/postgrey ${WRKSRC}/contrib/postgreyreport
X
Xpre-install:
X	@${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
X
Xdo-install:
X	@${POD2MAN} ${WRKSRC}/${PORTNAME} ${WRKSRC}/${PORTNAME}.1
X	@${POD2MAN} ${WRKSRC}/policy-test ${WRKSRC}/policy-test.1
X	@${POD2MAN} ${WRKSRC}/contrib/postgreyreport ${WRKSRC}/postgreyreport.1
X	@${INSTALL_SCRIPT} ${WRKSRC}/postgrey ${PREFIX}/sbin
X	@${INSTALL_SCRIPT} ${WRKSRC}/policy-test ${PREFIX}/sbin
X	@${INSTALL_SCRIPT} ${WRKSRC}/contrib/postgreyreport ${PREFIX}/sbin
X	@${INSTALL} -d ${PREFIX}/etc/postfix
X.for i in ${ETCFILES}
X	${INSTALL_DATA} ${WRKSRC}/postgrey_${i} ${PREFIX}/etc/postfix/dist-postgrey_${i}
X.endfor
X
X.if !defined(NOPORTDOCS)
X	@${INSTALL} -d ${DOCSDIR}
X	@cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${DOCSDIR}
X.endif
X	@cd ${WRKSRC} && ${INSTALL_MAN} ${MAN1} ${MANPREFIX}/man/man1
X
Xpost-install:
X	@${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
X
X.include <bsd.port.mk>
854c7eae4c26d2f798e6d679b8c6b91f
echo x - postgrey/pkg-descr
sed 's/^X//' >postgrey/pkg-descr << '0639cc31e9cc6580040970d7c849495e'
XPostgrey is a program which implements greylisting and is
Xdesigned to work with the Postfix MTA.
X
XWWW:  http://postgrey.schweikert.ch/
0639cc31e9cc6580040970d7c849495e
exit
--- postgrey.shar ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130507143018.B10A31A1F64>