Bug 77149

Summary: postgrey startup script bug
Product: Ports & Packages Reporter: jonny <jonny>
Component: Individual Port(s)Assignee: Volker Stolz <vs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
postgrey-fix.patch none

Description jonny 2005-02-05 20:20:14 UTC
    The rc script does not find the real pid, and some functions do not behave
well, like stop or restart.

    See this command output example:

----8<--------8<--------8<--------8<--------8<--------8<--------8<----
# typeset -f psg
psg () 
{ 
    ps -ax | grep $1 | grep -v grep
}
# /usr/local/etc/rc.d/postgrey.sh start
Starting postgrey.
# psg perl
25098  ??  Ss     0:00.04 [perl5.8.6]
# /usr/local/etc/rc.d/postgrey.sh stop 
postgrey not running? (check /var/run/postgrey.pid).
# cat /var/run/postgrey.pid 
25098
# psg perl
25098  ??  Is     0:00.04 [perl5.8.6]
# 
----8<--------8<--------8<--------8<--------8<--------8<--------8<----

    I don't know why ps(8) does not show the script name, like other perl
scripts.  Maybe its a side effect of using Net::Server

Fix: 

I could workaround the bug by putting the following lines in /etc/rc.conf:

----8<--------8<--------8<--------8<--------8<--------8<--------8<----
postgrey_enable="YES"
if [ "${pidfile}" = "${postgrey_pidfile}" ] ; then
  stop_cmd='test -f ${pidfile} && kill `cat ${pidfile} && rm ${pidfile}`'
  stop_postcmd=
  status_cmd='test -f ${pidfile} && if kill -0 `cat ${pidfile}` 2> /dev/null ; then echo "${name} is running." ; else echo "${name} is not running." ; return 1 ; fi'
fi
----8<--------8<--------8<--------8<--------8<--------8<--------8<----

    But a probable better fix is to adjust /etc/rc.subr or postgrey startup
script.
Comment 1 Volker Stolz freebsd_committer freebsd_triage 2005-02-09 15:37:45 UTC
Dear maintainer, is this the same issue as in ports/76253?

Volker
Comment 2 Volker Stolz freebsd_committer freebsd_triage 2005-02-09 15:38:14 UTC
State Changed
From-To: open->feedback

Forwarded PR to maintainer 


Comment 3 Volker Stolz freebsd_committer freebsd_triage 2005-02-09 15:38:14 UTC
Responsible Changed
From-To: freebsd-ports-bugs->vs

Handle
Comment 4 jonny 2005-02-09 15:55:07 UTC
Volker Stolz wrote:
> Dear maintainer, is this the same issue as in ports/76253?

     Note: "One problem is that the pidfile /var/run/postgrey.pid isn't 
created."

     I don´t think so, because the pidfile is created on my setup.



$ ps -aux | grep perl
postgrey 18732  0.0  0.8  9968 8616  ??  Is   Sat09PM   0:03.88 [perl5.8.6]
jonny    18238  0.0  0.1  1488  568  ph  R+    1:49PM   0:00.00 grep perl
$ ls -l /var/run/postgrey.pid
-rw-r--r--  1 postgrey  postgrey  6 Feb  5 21:30 /var/run/postgrey.pid
$ cat /var/run/postgrey.pid
18732
$


     Other than that, it is very similar.

     Also: "This seems to only be a problem if you can't access 
/dev/kmem" is wrong, because other perl files work perfectly, and I am 
not using jail nor chroot in this setup.

     I think the problem is with the Net::Daemon perl library removing 
the ARGV components, which is incompatible with rc.subr procedures. 
Maybe the maintainer cannot do anything other than the same workaround 
as I did, which is not Good(TM).

     Cheers,

		Jonny
Comment 5 Harold Paulson 2005-04-08 18:37:12 UTC
The root problem here was that because of Postgrey's very long argument 
list, FreeBSD 5.x was displaying, '[perl]' in ps instead of the full 
application and args.

The max length is dictated by kern.ps_arg_cache_limit and set to 256 by 
default.

The attached patch changes the defaults in the postgrey application from 
/etc/ to ${PREFIX}/etc/, and trims down the argument list in the startup 
script to use defaults for the whitelist locations.

 	- H
Comment 6 Harold Paulson 2005-04-13 05:54:31 UTC
Stupid mailer.  Here's that patch again, and a URL in case is fails again:

 	http://taurus.internal.org/~haroldp/postgrey-fix.patch

Patch:


diff -ruN postgrey.bak/Makefile postgrey/Makefile
--- postgrey.bak/Makefile	Sun Mar 27 21:19:01 2005
+++ postgrey/Makefile	Thu Apr  7 15:53:48 2005
@@ -7,6 +7,7 @@

  PORTNAME=	postgrey
  PORTVERSION=	1.18
+PORTREVISION=	1
  CATEGORIES=	mail
  MASTER_SITES=	http://isg.ee.ethz.ch/tools/postgrey/pub/

@@ -19,6 +20,7 @@

  USE_PERL5=	yes
  USE_RC_SUBR=	yes
+USE_REINPLACE=	yes
  NO_BUILD=	yes

  ETCFILES=	whitelist_clients whitelist_recipients
@@ -51,6 +53,9 @@
  .if ${PERL_LEVEL} < 500600
  IGNORE=	Needs perl 5.6.1 or higher, install lang/perl5.8 and try again
  .endif
+
+post-patch:
+	${REINPLACE_CMD} -e "s#/etc/#${PREFIX}/etc/#" ${WRKSRC}/postgrey

  pre-install:
  	${SED}	-e 's#%%PREFIX%%#${PREFIX}#g' -e 's#%%RC_SUBR%%#${RC_SUBR}#g' \
diff -ruN postgrey.bak/files/postgrey.sh postgrey/files/postgrey.sh
--- postgrey.bak/files/postgrey.sh	Wed Jan 26 16:03:28 2005
+++ postgrey/files/postgrey.sh	Thu Apr  7 13:31:12 2005
@@ -36,10 +36,7 @@
  postgrey_enable=${postgrey_enable:-"NO"}
  postgrey_pidfile=${postgrey_pidfile:-"/var/run/postgrey.pid"}
  postgrey_flags=${postgrey_flags:-"--pidfile=${postgrey_pidfile} \
-	--inet=10023 -d --user=postgrey --group=postgrey --dbdir=/var/db/postgrey \
-	--whitelist-clients=%%PREFIX%%/etc/postfix/postgrey_whitelist_clients \
-	--whitelist-clients=%%PREFIX%%/etc/postfix/postgrey_whitelist_clients.local \
-	--whitelist-recipients=%%PREFIX%%/etc/postfix/postgrey_whitelist_recipients"}
+	--inet=10023 -d --user=postgrey --group=postgrey --dbdir=/var/db/postgrey"}

  pidfile="${postgrey_pidfile}"
Comment 7 dd freebsd_committer freebsd_triage 2005-04-15 07:31:34 UTC
State Changed
From-To: feedback->closed

Fixed in the upgrade to 1.21