Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 119109 - Enhancements to init script and configuration for postgrey
Summary: Enhancements to init script and configuration for postgrey
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All All
: Lowest enhancement (vote)
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
: 177443 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-01-15 11:40 UTC by Jeremy Clifton
Modified: 2007-09-08 10:03 UTC (History)
9 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Updated init file (postgrey.rc.new,2.23 KB, text/plain)
2006-08-29 21:53 UTC, Philip White
Details
Updated init file (postgrey.rc.new,2.23 KB, text/plain)
2006-09-09 22:05 UTC, Philip White
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Clifton 2006-01-15 11:40:29 UTC
I have postgrey 1.21 installed on my box.

I modified the init script and conf.d file such that it was possible to configure the greylist delay period and greylist response text from the conf.d/postgrey file.

The modified init script checks to make sure that the POSTGREY_DELAY var has been set, and will issue an error if it has not. It also will append the value of POSTGREY_RESPONSE (with the appropriate flag) to the options passed to start-stop-daemon only if the POSTGREY_RESPONSE var is set or not an empty string.

I believe that this will be of use to other Gentoo users ... especially the addition of the info for the --greylist-text option, as simply adding this flag and the message to the POSTGREY_OPTIONS var in the conf.d file won't work (see the following links to information about the Debian implementation for more details)

http://lists.ee.ethz.ch/postgrey/msg00584.html
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=298832
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=309515

diff for /etc/init.d/postgrey:
----------

--- postgrey.old	2006-01-15 14:23:45.000000000 -0500
+++ postgrey	2006-01-15 13:14:18.000000000 -0500
@@ -49,6 +49,15 @@
 		[ -z "${POSTGREY_PID}" ] && einfo "  - POSTGREY_PID"
 		conf_error
 	fi
+	
+	# Make sure the greylisting delay time period is set.
+	if [ -z "${POSTGREY_DELAY}" ]
+		then
+			einfo "The following entries are missing in ${conf}:"
+			[ -z "${POSTGREY_DELAY}" ] && einfo "  - POSTGREY_DELAY"
+			conf_error
+	fi
+
 }
 
 start() {
@@ -61,12 +70,19 @@
 	while ! test -S ${POSTGREY_SOCKET}; do sleep 1; done;
 	chmod a+rw,a-x ${POSTGREY_SOCKET}; fi ) &
 
+	# Check for a greylist message.
+	if [ "$POSTGREY_RESPONSE" != "" ]
+		then
+			POSTGREY_RESPONSE_OPT="--greylist-text=$POSTGREY_RESPONSE"
+	fi
+
 	start-stop-daemon --start --quiet --background \
 		--exec /usr/sbin/postgrey -- \
 		--${POSTGREY_ADDR} \
 		--daemonize \
 		--pidfile=${POSTGREY_PID} \
-		${POSTGREY_OPTS}
+		${POSTGREY_OPTS} \
+		"${POSTGREY_RESPONSE_OPT}"
 	eend ${?}
 }
 
----------

diff for /etc/conf.d/postgrey:
----------

--- postgrey.old	2006-01-15 14:23:31.000000000 -0500
+++ postgrey	2006-01-15 13:15:03.000000000 -0500
@@ -1,5 +1,11 @@
 # Config file for /etc/init.d/postgrey
 
+# How long to delay mail that is greylisted in seconds.
+POSTGREY_DELAY=900
+
+# The response we'll send back with delayed mail.
+POSTGREY_RESPONSE='This account is temporarily disabled. Please try again in %s seconds.'
+
 # LISTEN TYPE
 #  Set to 'inet' if you want to use a TCP socket.
 #  Set to 'unix' if you want to use an UNIX socket.
@@ -48,4 +54,4 @@
 # per default /etc/postfix/postgrey_whitelist_clients.local is also read, so
 # that you can put there local entries.
 #
-POSTGREY_OPTS=""
+POSTGREY_OPTS="--delay=$POSTGREY_DELAY"

----------
Comment 1 Andrej Kacian (RETIRED) gentoo-dev 2006-02-20 00:05:58 UTC
I'll have a look at this today. Looks good.
Comment 2 Andrej Kacian (RETIRED) gentoo-dev 2006-02-25 10:04:19 UTC
In portage now, for newly added postgrey-1.24. I added some sanity checks for when new options are commented in the .conf file (and thus empty).

Thanks for your contribution!
Comment 3 Gokdeniz Karadag 2006-04-05 07:46:06 UTC
I recently upgraded to this ebuild, but there is a problem with postgrey response text. The problem is, only the first word of the POSTGREY_TEXT is sent to the remote server.

There is a thread about this at: http://lists.ee.ethz.ch/postgrey/msg01062.html it mentions quotes, but when I look at /etc/init.d/postgrey, quotes are all in place. 

Here is an example log line from a spam being rejected;
Apr  5 17:32:56 thostname postfix/smtpd[2393]: NOQUEUE: reject: RCPT from WLL-23-pppoe081.t-net.net.ve[200.31.137.81]: 450 <xxxx@tttt.yy>: Recipient address rejected: "Temporariliy; from=<georgiy_b05@list.ru> to=<xxxx@tttt.yy> proto=ESMTP helo=<r95di.ohuby5.comcast.net>
Comment 4 Andrej Kacian (RETIRED) gentoo-dev 2006-04-07 15:23:10 UTC
You're right, I can experience this too, despite it looking alright in ps:

18182 ?        Ss     0:00 /usr/sbin/postgrey --unix=/var/spool/postfix/private/postgrey --daemonize --pidfile=/var/run/postgrey.pid --delay=300 --greylist-text "Greylisted for %s seconds"
Comment 5 Arnaud Launay 2006-04-09 05:51:05 UTC
I have this problem, too -- and worse: postgrey just die after delaying the first mail... Works fine when I comment the greylist text option in the conf file.
Comment 6 Alexander Skwar 2006-04-19 10:42:18 UTC
Same problem here. Another thread on the postgrey list: http://lists.ee.ethz.ch/postgrey/msg01105.html

> 18182 ?        Ss     0:00 /usr/sbin/postgrey
> --unix=/var/spool/postfix/private/postgrey --daemonize
> --pidfile=/var/run/postgrey.pid --delay=300 --greylist-text "Greylisted for %s
> seconds"

Interestingly (?) my PS output looks a bit different:

askwar@hetzner ~ $ ps axwww|grep postgrey
26719 ?        Ss     0:00 /usr/sbin/postgrey --unix=/var/spool/postfix/private/postgrey --daemonize --pidfile=/var/run/postgrey.pid --delay=300 --greylist-text="Greylisted 
for %s seconds"

The difference is, that I've got a = before the "Greylisted.
Comment 7 Vadim Berezniker 2006-06-20 17:13:59 UTC
I changed 
    start-stop-daemon --start --quiet --background \
        --exec /usr/sbin/postgrey -- \
        --${POSTGREY_ADDR} \
        --daemonize \
        --pidfile=${POSTGREY_PID} \
        ${POSTGREY_DELAY_ARG} \
        ${POSTGREY_TEXT_ARG} \
        ${POSTGREY_OPTS}
to
    start-stop-daemon --start --quiet --background \
        --exec /usr/sbin/postgrey -- \
        --${POSTGREY_ADDR} \
        --daemonize \
        --pidfile=${POSTGREY_PID} \
        ${POSTGREY_DELAY_ARG} \
        "${POSTGREY_TEXT_ARG}" \
        ${POSTGREY_OPTS}

and it magically works =)

Also, how come --background is being passed to start-stop-daemon? 
Comment 8 Philip White 2006-08-29 21:38:25 UTC
Comment #7 fixes this problem for me as well.
Comment 9 Philip White 2006-08-29 21:53:44 UTC
Created attachment 95431 [details]
Updated init file

As per comment #7, this updated init file puts the POSTGREY_TEXT_ARG into double quotes to prevent the parameter from being cut off at the first whitespace character.
Comment 10 Philip White 2006-09-09 22:02:28 UTC
Comment on attachment 95431 [details]
Updated init file

>#!/sbin/runscript
># Copyright 1999-2004 Gentoo Foundation
># Distributed under the terms of the GNU General Public License v2
># $Header: /var/cvsroot/gentoo-x86/mail-filter/postgrey/files/postgrey.rc.new,v 1.3 2006/02/25 17:59:13 ticho Exp $
>
>conf="/etc/conf.d/postgrey"
>
>depend() {
>	need net
>	before postfix
>	provide postfix_greylist
>}
>
>conf_error() {
>	eerror "You need to setup ${conf} first"
>	return 1
>}
>
>checkconfig() {
>if [ -z "${POSTGREY_TYPE}" ]
>	then
>		einfo "You need to choose the server type you want"
>		einfo "by setting the POSTGREY_TYPE variable in ${conf}."
>	else
>	if [ "x${POSTGREY_TYPE}" = "xinet" ]
>		then
>			if [ -z "${POSTGREY_PORT}" ] || [ -z "${POSTGREY_HOST}" ]
>				then
>					einfo "The following entries are missing in ${conf}:"
>					[ -z "${POSTGREY_HOST}" ] && einfo "  - POSTGREY_HOST"
>					[ -z "${POSTGREY_PORT}" ] && einfo "  - POSTGREY_PORT"
>					conf_error
>			fi
>			POSTGREY_ADDR="${POSTGREY_TYPE}=${POSTGREY_HOST}:${POSTGREY_PORT}"
>		else
>			if [ -z "${POSTGREY_SOCKET}" ]
>			then
>				einfo "The following entries are missing in ${conf}:"
>				[ -z "${POSTGREY_SOCKET}" ] && einfo "  - POSTGREY_SOCKET"
>				conf_error
>			fi
>			POSTGREY_ADDR="${POSTGREY_TYPE}=${POSTGREY_SOCKET}"
>	fi
>fi
>
>	if [ -z "${POSTGREY_PID}" ]
>		then
>		einfo "The following entries are missing in ${conf}:"
>		[ -z "${POSTGREY_PID}" ] && einfo "  - POSTGREY_PID"
>		conf_error
>	fi
>}
>
>start() {
>	checkconfig || return 1
>	ebegin "Starting Postgrey"
>	
>	# HACK -- start a subshell and corrects perms on the socket...
>	( if [ "x${POSTGREY_TYPE}" = "xunix" ]; then
>	rm -f ${POSTGREY_SOCKET};
>	while ! test -S ${POSTGREY_SOCKET}; do sleep 1; done;
>	chmod a+rw,a-x ${POSTGREY_SOCKET}; fi ) &
>
>	if [ -z ${POSTGREY_DELAY} ] ; then
>		POSTGREY_DELAY_ARG=""
>	else
>		POSTGREY_DELAY_ARG="--delay=${POSTGREY_DELAY}"
>	fi
>
>	if [ -z "${POSTGREY_TEXT}" ] ; then
>		POSTGREY_TEXT_ARG=""
>	else
>		POSTGREY_TEXT_ARG="--greylist-text="${POSTGREY_TEXT}
>	fi
>
>	start-stop-daemon --start --quiet --background \
>		--exec /usr/sbin/postgrey -- \
>		--${POSTGREY_ADDR} \
>		--daemonize \
>		--pidfile=${POSTGREY_PID} \
>		${POSTGREY_DELAY_ARG} \
>		"${POSTGREY_TEXT_ARG}" \
>		${POSTGREY_OPTS}
>	eend ${?}
>}
>
>stop() {
>	ebegin "Stopping Postgrey"
>	start-stop-daemon --stop --quiet --pidfile ${POSTGREY_PID}
>	eend ${?}
>}
Comment 11 Philip White 2006-09-09 22:05:52 UTC
Created attachment 96552 [details]
Updated init file

The change is that it prevents nested quotes.  The previous patch would include the quotation marks in the server reply, like so:
Recipient address rejected: "Greylisted for 60 seconds"; to=

Now it says:
Recipient address rejected: Greylisted for 60 seconds; to=

It uses direct concatenation of quoted text with a shell variable.

And apologies for the previous comment spam: I did not realize what my action would cause.
Comment 12 Marc St-Pierre 2006-11-09 17:38:16 UTC
I have the same issue.  This is my quick fix (without starting to edit perl scripts):

/etc/conf.d/postgrey:
POSTGREY_TEXT="Cyberlogic_Greylisted_for_%s_seconds_(http://postmaster.cyberlogic.net/greylist.php)"


 8830 ?        Ss     0:02 /usr/sbin/postgrey --inet=127.0.0.1:10030 --daemonize --pidfile=/var/run/postgrey.pid --delay=300 --greylist-text="Cyberlogic_Greylisted_for_%s_seconds_(http://postmaster.cyberlogic.net/greylist.php)" -v --whitelist-clients=/etc/postfix/postgrey_whitelist_clients
Comment 13 Reuben Farrelly 2007-02-04 12:56:29 UTC
Still seeing this problem with only the word "Greylisted;" in the URL as of 04-Feb-07.
Comment 14 Alexander Skwar 2007-06-21 08:23:31 UTC
(In reply to comment #13)
> Still seeing this problem with only the word "Greylisted;" in the URL as of
> 04-Feb-07.
> 

Still not fixed, as of 2007-06-21.
Comment 15 Tobias Scherbaum (RETIRED) gentoo-dev 2007-06-26 18:33:36 UTC
*** Bug 177443 has been marked as a duplicate of this bug. ***
Comment 16 Tobias Scherbaum (RETIRED) gentoo-dev 2007-09-08 08:53:00 UTC
This one is supposed to be fixed in 1.30-r2.
Comment 17 Tobias Scherbaum (RETIRED) gentoo-dev 2007-09-08 10:03:03 UTC
(In reply to comment #16)
> This one is supposed to be fixed in 1.30-r2.
> 

s/1.30-r2/1.31