Bug 213709 - postgrey: init.d script "${POSTGREY_TEXT_ARG}" breaks the remaining command line options
Bug#: 213709 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: net-mail@gentoo.org Reported By: falco@gentoo.org
Component: Ebuilds
URL: 
Summary: postgrey: init.d script "${POSTGREY_TEXT_ARG}" breaks the remaining command line options
Keywords:  
Status Whiteboard: 
Opened: 2008-03-17 15:30 0000
Description:   Opened: 2008-03-17 15:30 0000
mail-filter/postgrey 1.31

/etc/conf.d/postgrey:
  POSTGREY_TEXT is commented (so it's not assigned in the init.d script)

And i have in conf.d/postgrey:
POSTGREY_OPTS="--verbose --greylist-text=Greylisted --greylist-action=421"

$ cat /proc/xxx/cmdline
/usr/sbin/postgrey --inet=127.0.0.1:10030 --daemonize
--pidfile=/var/run/postgrey.pid --delay=1010  --verbose
--greylist-text=Greylisted --greylist-action=REJECT#      

(note the 2 spaces between delay and verbose, which is, in fact, "")

I get:
rcpt to:<schmurtz>
450 4.2.0 <schmurtz>: Recipient address rejected: Greylisted, see
http://postgrey.schweikert.ch/help/schmurtz.html

and nothing verbose.

If i add something in POSTGREY_TEXT, it's OK:

POSTGREY_TEXT="azeertyuipmqlfkjlkhgaaa bbb" 
(what a nice example config file :) )

$ cat cmdline
/usr/sbin/postgrey --inet=127.0.0.1:10030 --daemonize
--pidfile=/var/run/postgrey.pid --delay=1010 --verbose
--greylist-text=Greylisted --greylist-action=REJECT#       

rcpt to:<schmurtz>
421 4.2.0 <schmurtz>: Recipient address rejected: Greylisted
Connection closed by foreign host.

and it's now verbose (TCP connections in syslog)

I added debug code in /usr/sbin/postgrey line 501, and it confirmed that
GetOptions() does not take into account --verbose, --greylist-text, nor
--greylist-action.


Fix: the init.d script should NOT add "" as argument to start-stop-daemon

                 ${POSTGREY_DELAY_ARG} \ 
-                "${POSTGREY_TEXT_ARG}" \ 
+                ${POSTGREY_TEXT_ARG} \ 
                 ${POSTGREY_OPTS}

------- Comment #1 From Raphael Marichez 2008-03-18 12:10:36 0000 -------
hum, that fails if POSTGREY_TEXT contains more that one word. (i tried with
"Greylisted.")

Then here is another fix: invert the two args, exactly as in bug 119109

                 ${POSTGREY_DELAY_ARG} \ 
-                "${POSTGREY_TEXT_ARG}" \ 
-                ${POSTGREY_OPTS}
+                ${POSTGREY_OPTS} \
+                "${POSTGREY_TEXT_ARG}"

And warn users to not put options with spaces in $POSTGREY_OPTS in
/etc/conf.d/postgrey. Instead, put your text in ${POSTGREY_TEXT_ARG} *only*.

------- Comment #2 From Tobias Scherbaum 2008-03-18 16:47:24 0000 -------
(In reply to comment #1)
> hum, that fails if POSTGREY_TEXT contains more that one word. (i tried with
> "Greylisted.")

yeah, that was a fix from #119109, too. 

> Then here is another fix: invert the two args, exactly as in bug 119109
> 
>                  ${POSTGREY_DELAY_ARG} \ 
> -                "${POSTGREY_TEXT_ARG}" \ 
> -                ${POSTGREY_OPTS}
> +                ${POSTGREY_OPTS} \
> +                "${POSTGREY_TEXT_ARG}"
> 
> And warn users to not put options with spaces in $POSTGREY_OPTS in
> /etc/conf.d/postgrey. Instead, put your text in ${POSTGREY_TEXT_ARG} *only*.

I'll do some further testing on that during the weekend and get this committet
then. Thanks for providing the fix :)

------- Comment #3 From Raphael Marichez 2008-04-01 13:35:27 0000 -------
(In reply to comment #2)
> 
> I'll do some further testing on that during the weekend and get this committet
> then. Thanks for providing the fix :)
> 

ping

------- Comment #4 From Tobias Scherbaum 2008-04-06 15:43:27 0000 -------
pong - and fixed in CVS.