ports/114106: mail/postgrey does not properly shut down via rc.d script

Jeremy Chadwick koitsu at FreeBSD.org
Thu Jun 28 19:26:53 UTC 2007


Okay, I spent a little bit of time and managed to track down the cause
of this pain.  As like most of my PRs, I seem to have a knack for
opening cans of worms...

The issue caused here is based upon /proc being mounted or not.

Without /proc mounted:

eos# ps -auxw | grep 61665
postgrey 61665  0.0  0.3  8692  7932  ??  Is   10:52AM   0:00.06 [perl5.8.8]

With /proc mounted:

eos# mount -t procfs proc /proc
eos# ps -auxw | grep 61665
postgrey 61665  0.0  0.3  8692  7932  ??  Is   10:52AM   0:00.06 /usr/local/sbin/postgrey --pidfile=/var/run/postgrey.pid --inet=10

The rc.subr framework attempts to match a process ID number taken from
the associated pidfile and match it with the procname (which I believe
defaults to $name, which is in this case "postgrey").  Without /proc
mounted, the pidfile is read, and pid 61665 is found: but the process
name "[perl5.8.8]" does not match "postgrey".  With /proc mounted,
everything works as it should.

Maintainer, I don't know if there's much you can do about this, because
it's safe to say that this problem is going to affect other ports that
use perl and spawn perl scripts as daemons which set the process name.
This is why I say it opens a can of worms; it bleeds over into both the
methodology behind procname + pidfile use in rc.subr, and whether or not
perl is doing the right thing functionally when it comes to overwriting
argv[0] (I do not know if it's using setproctitle or what.  I would have
to write some test programs to see what's going on here...)

The only workaround available at this time (that is easy to do) is to
mount /proc.  But as of FreeBSD 5.x, this isn't recommended behaviour
due to historic security problems with procfs.

Worse, I don't know where to go with this problem.  Is this a ports
problem?  Is it an rc.subr problem?  Is it a perl problem?  Is it a
FreeBSD (per se) problem?  Where exactly do we address this?

-- 
| Jeremy Chadwick                                    jdc at parodius.com |
| Parodius Networking                           http://www.parodius.com/ |
| UNIX Systems Administrator                      Mountain View, CA, USA |
| Making life hard for others since 1977.                  PGP: 4BD6C0CB |




More information about the freebsd-ports-bugs mailing list