Subject: Re: pkg/19002: rc.d/cyrus slightly broken
To: Chris Gilbert <chris@dokein.co.uk>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 11/10/2002 18:04:11
[ On Sunday, November 10, 2002 at 22:35:01 (+0000), Chris Gilbert wrote: ]
> Subject: Re: pkg/19002: rc.d/cyrus slightly broken
>
> Which Cyrus is this btw?  I'm assuming it's 2.1.9...

I'm not so sure -- there are two cyrus-imapd variants in pkgsrc, and
Frank doesn't exactly say in the original PR, and both use that
contstruct.

> Certainly cyrus 2.1.9 does this already, from main() in master/master.c:
>     if (close_std) {
>       /* close stdin/out/err */
>       for (fd = 0; fd < 3; fd++) {
> 	close(fd);
> 	if (open("/dev/null", O_RDWR, 0) != fd)
> 	  fatal("couldn't open /dev/null: %m", 2);
>       }
>     }
> 
> where close_std is based on the option -D (with it set close_std == 0)

Yes, I saw that too, but really it should be patched to call daemon()
and pidfile() instead....

(having just done a lot of work on inetd I'm not so sure I really want
to take my chances on using something new instead (or rather in
addition), but that's a different issue...  :-)

> I'd suspect the sleep is there to give the system time to start up
> cyrus, without being overloaded by other things.

That rational would seem to be rather silly and pointless.  Besides,
it's the other way around -- the "& sleep2" construct gives the daemon
time to start up without being overloaded by other system things
happening since it starts the daemon in the background and then delays
/etc/rc from proceding!  However since other system daemons will no
doubt already be running when this one is started it doesn't seem very
useful to delay even more stuff from starting -- unix systems are pretty
good at multitasking after all!  ;-)

>  The & sleep 2 is a
> standard trick, see rc.d/xfs.

One lone and relatively poor example hardly makes it a "standard"!   :-)

hmmmm, I'm pretty sure that one is there for a different reason too.

Traditionally xfs was also a very mis-behaved daemon -- i.e. until
"recently" it wasn't really implemented properly to run as a daemon on a
*BSD system.  The version in xsrc however does more or less the right
things to become a proper daemon process and to write its own pidfile.

I believe the "& sleep 2" is actually a hold-over from the days before
xfs was updated to "Do The Right Thing".  The "&" is certainly no longer
necessary.

I actually took that whole thing out of my rc.d/xfs a long while ago.

> > At first glance it looks like this particular daemon is not designed
> > to run stand-alone from /etc/rc on a *BSD system.  If so then it needs
> > some(relatively minor) patches to correct this deficiency before it is
> > truly viable for use on NetBSD.
> 
> It what way does it not fit with rc.d?  I've had it happily running from
> rc.d for months on my mail server.

Did I say "rc.d"?  No, I said "*BSD".  I'm talking about issues like
using the system supplied daemon() and pidfile() subroutines, or at
least trying to do what they do so that the ultimate daemon process runs
in the correct context and environment.

> I don't claim it's the perfect package (far from it looking at PR's 8)
> but it works (for a limited definition of works 8)  I created the
> package so those without time to figure out lots of the package systems
> infrastructure but have a requirement for the latest cyrus could stand a
> chance of getting it working.

Yes, and very much appreciated it is!

(it's a lot better than many other packages, even recently added ones!)

Are you interested in adding patches to fix lmtpd (and thus deliver) so
that it'll automatically create mailboxes when mail is first delivered
if "autocreatequota" is non-zero?  I've submitted them yet again to the
maintainers, but I have no more hope that they'll be incorporated in the
official version than they where when I first submitted them way back
before 1.5.19....

I'm going to do daemon() and pidfile() patches for 2.1.9 very soon now
too (perhaps tonight), so I can submit them, either separately or as an
attachement to this PR if you'd like.....

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>