problem with debconf and start-stop-daemon

2002-01-11 Thread Michael Meskes
I'm currently working on adding debconf to quota. Well in fact Torsten
Lnadschoff did that and send me the patch. However, during my tests I found
a strange problem. 

In quota.postinst rpc.quotad is started using start-stop-daemon. This works
as longs as I know the package. Now it doesn't anymore. That is the daemon
is correctly started but quota.postinst does not return anymore. It remains
defunc until I kill rpc.rquotad. As soon as I comment out the line
. /usr/share/debconf/confmodule
all works well again.

Since I do not know much about debconf I'm not seeing the reason but I
suppose it should be pretty simple or else other packages wouldn't work
either. Any idea?

Michael

-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Mark Brown
On Fri, Jan 11, 2002 at 12:44:39PM +0100, Michael Meskes wrote:

 In quota.postinst rpc.quotad is started using start-stop-daemon. This works
 as longs as I know the package. Now it doesn't anymore. That is the daemon
 is correctly started but quota.postinst does not return anymore. It remains
 defunc until I kill rpc.rquotad. As soon as I comment out the line
 . /usr/share/debconf/confmodule
 all works well again.

You need to explicitly end Debconf processing in the postinst by calling
db_stop.  debconf causes child processes to have an extra file
descriptor open and waits for these to be closed before exiting and the
daemon doesn't know it has this file open so doesn't close it.

-- 
You grabbed my hand and we fell into it, like a daydream - or a fever.


pgpTd7ITXX72V.pgp
Description: PGP signature


Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Petter Reinholdtsen

[Mark Brown]
 You need to explicitly end Debconf processing in the postinst by
 calling db_stop.  debconf causes child processes to have an extra
 file descriptor open and waits for these to be closed before exiting
 and the daemon doesn't know it has this file open so doesn't close
 it.

Is this the case for all postinst scripts?  db_stop is not mentioned
in my /usr/share/doc/debconf-doc/tutorial.html, which I use as my
debconf reference.




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Michael Meskes
On Fri, Jan 11, 2002 at 11:58:47AM +, Mark Brown wrote:
 You need to explicitly end Debconf processing in the postinst by calling

That's it. Thanks a lot.

Michael

-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!


pgpfJMEeIzDdh.pgp
Description: PGP signature


Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Mark Brown
On Fri, Jan 11, 2002 at 01:04:25PM +0100, Petter Reinholdtsen wrote:

 Is this the case for all postinst scripts?  db_stop is not mentioned
 in my /usr/share/doc/debconf-doc/tutorial.html, which I use as my
 debconf reference.

No.  If your postinst does not leave processes running then there won't
be any problem.

-- 
You grabbed my hand and we fell into it, like a daydream - or a fever.


pgpchpcTtjxc7.pgp
Description: PGP signature


Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Colin Watson
On Fri, Jan 11, 2002 at 01:04:25PM +0100, Petter Reinholdtsen wrote:
 [Mark Brown]
  You need to explicitly end Debconf processing in the postinst by
  calling db_stop.  debconf causes child processes to have an extra
  file descriptor open and waits for these to be closed before exiting
  and the daemon doesn't know it has this file open so doesn't close
  it.
 
 Is this the case for all postinst scripts?  db_stop is not mentioned
 in my /usr/share/doc/debconf-doc/tutorial.html, which I use as my
 debconf reference.

See the Troubleshooting section. The debconf documentation often
doesn't use the db_ prefix when discussing commands, since that's only
used by the shell confmodule and not the Perl confmodule.

-- 
Colin Watson  [EMAIL PROTECTED]




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Henrique de Moraes Holschuh
On Fri, 11 Jan 2002, Michael Meskes wrote:
 In quota.postinst rpc.quotad is started using start-stop-daemon. This works

Don't, please. This will be forbidden in the future (right now this is ok),
you should use the /etc/init.d interface. If you need extra functionality,
you should request the maintainer of the package with the /etc/init.d
script to add it, and use that.

 as longs as I know the package. Now it doesn't anymore. That is the daemon
 is correctly started but quota.postinst does not return anymore. It remains
 defunc until I kill rpc.rquotad. As soon as I comment out the line
 . /usr/share/debconf/confmodule
 all works well again.

Ah, it looks like you need to have a db_stop BEFORE you call
start-stop-daemon or the initscript. Looks like the daemon is dumb and does
not close all open descriptors, creates a new session id, etc...

-- 
  One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie. -- The Silicon Valley Tarot
  Henrique Holschuh




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Mark Brown
On Fri, Jan 11, 2002 at 11:40:28AM -0200, Henrique de Moraes Holschuh wrote:

 Ah, it looks like you need to have a db_stop BEFORE you call
 start-stop-daemon or the initscript. Looks like the daemon is dumb and does

No, the ordering is unimportant.  db_stop stops debconf no matter when
you call it.

 not close all open descriptors, creates a new session id, etc...

Or has called the standard daemon() function which doesn't close all the
file descriptors.

-- 
You grabbed my hand and we fell into it, like a daydream - or a fever.


pgpX0u114EEbs.pgp
Description: PGP signature


Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Michael Meskes
On Fri, Jan 11, 2002 at 11:40:28AM -0200, Henrique de Moraes Holschuh wrote:
 Don't, please. This will be forbidden in the future (right now this is ok),
 you should use the /etc/init.d interface. If you need extra functionality,

Sorry, I wasn't precies enough. It does call /etc/init.d/quotarpc which then
calls start-stop-daemon.

 start-stop-daemon or the initscript. Looks like the daemon is dumb and does
 not close all open descriptors, creates a new session id, etc...

Yup.

Michael
-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Stefan Hornburg Racke
Mark Brown [EMAIL PROTECTED] writes:

 On Fri, Jan 11, 2002 at 11:40:28AM -0200, Henrique de Moraes Holschuh wrote:
 
  Ah, it looks like you need to have a db_stop BEFORE you call
  start-stop-daemon or the initscript. Looks like the daemon is dumb and does
 
 No, the ordering is unimportant.  db_stop stops debconf no matter when
 you call it.
 
  not close all open descriptors, creates a new session id, etc...
 
 Or has called the standard daemon() function which doesn't close all the
 file descriptors.

Yeah, but it is really a bug that should be filed. The daemon will
be killed by SAK otherwise (look at #92277 for further enlightenment).

Ciao
Racke

-- 
For projects and other business stuff please refer to COBOLT NetServices
(URL: http://www.cobolt.net; Email: [EMAIL PROTECTED]; Phone: 0041-1-3884400)




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Mark Brown
On Fri, Jan 11, 2002 at 09:45:22AM -0500, Stefan Hornburg (Racke) wrote:
 Mark Brown [EMAIL PROTECTED] writes:

  Or has called the standard daemon() function which doesn't close all the
  file descriptors.

 Yeah, but it is really a bug that should be filed. The daemon will
 be killed by SAK otherwise (look at #92277 for further enlightenment).

It does close the standard file descriptors.  It just doesn't close
anything else (like stuff from debconf, for example).

-- 
You grabbed my hand and we fell into it, like a daydream - or a fever.




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Wichert Akkerman
Previously Henrique de Moraes Holschuh wrote:
 On Fri, 11 Jan 2002, Michael Meskes wrote:
  In quota.postinst rpc.quotad is started using start-stop-daemon. This works
 
 Don't, please. This will be forbidden in the future (right now this is ok),
 you should use the /etc/init.d interface.

Why? That is silly, there are perfectly good reasons to use a different
method for starting/stopping a daemon in the maintainer scripts then
init scripts use.

Wichert.

-- 
  _
 /[EMAIL PROTECTED] This space intentionally left occupied \
| [EMAIL PROTECTED]http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0  2805 3CB8 9250 2FA3 BC2D |




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Henrique de Moraes Holschuh
On Fri, 11 Jan 2002, Wichert Akkerman wrote:
 Previously Henrique de Moraes Holschuh wrote:
  On Fri, 11 Jan 2002, Michael Meskes wrote:
   In quota.postinst rpc.quotad is started using start-stop-daemon. This 
   works
  
  Don't, please. This will be forbidden in the future (right now this is ok),
  you should use the /etc/init.d interface.
 
 Why? That is silly, there are perfectly good reasons to use a different
 method for starting/stopping a daemon in the maintainer scripts then
 init scripts use.

Read the invoke-rc.d stuff, and policy-rc.d stuff in the BTS
(debian-policy). I don't know the bug numbers offhand. It has been approved,
the code is in woody and it works (try running invoke-rc.d sometime), and we
are just waiting woody to go out of the door to start deploying the stuff.

Basically, the idea is to finish once and for all with the mess of daemons
starting and restarting (and stopping) when the admin does not them to, due
to maintainer scripts playing around.  The current default behaviour will
NOT change unless you go out of your way to configure the system otherwise,
btw.  But people that, for example, don't want any daemons running before
they are configured and reviewed will be able to do that.

Please tell me one good reason not to use the init.d script interface to
muck around with daemons _in maintainer scripts_?  I mean, a good one that
justfies bowling over any changes the local administrator might have done to
the initscripts?

-- 
  One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie. -- The Silicon Valley Tarot
  Henrique Holschuh




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Steve Greenland
On 11-Jan-02, 08:45 (CST), Stefan Hornburg (Racke) [EMAIL PROTECTED] wrote: 
 Yeah, but it is really a bug that should be filed. The daemon will
 be killed by SAK otherwise (look at #92277 for further enlightenment).

You can't, in general, close *all* open file descriptors. OPEN_MAX
may not exist (and I would guess that it doesn't on the HURD). It's
completely reasonable for a daemon to that doesn't open any extras to
assume that only stdin, stdout, and stderr are open.

Steve




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Mark Brown
On Fri, Jan 11, 2002 at 10:34:18AM -0600, Steve Greenland wrote:

 You can't, in general, close *all* open file descriptors. OPEN_MAX
 may not exist (and I would guess that it doesn't on the HURD). It's
 completely reasonable for a daemon to that doesn't open any extras to
 assume that only stdin, stdout, and stderr are open.

If OPEN_MAX is undefined you could always use INT_MAX :-) .

-- 
You grabbed my hand and we fell into it, like a daydream - or a fever.


pgp2B5Sy7URvY.pgp
Description: PGP signature


Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Adam Olsen
On Fri, Jan 11, 2002 at 04:49:19PM +, Mark Brown wrote:
 On Fri, Jan 11, 2002 at 10:34:18AM -0600, Steve Greenland wrote:
 
  You can't, in general, close *all* open file descriptors. OPEN_MAX
  may not exist (and I would guess that it doesn't on the HURD). It's
  completely reasonable for a daemon to that doesn't open any extras to
  assume that only stdin, stdout, and stderr are open.
 
 If OPEN_MAX is undefined you could always use INT_MAX :-) .

iirc, there has been a problem with a program closing all descriptors
before, because they were used by libc (?) for something.  So no, you
shouldn't use INT_MAX either :)


-- 
Adam Olsen, aka Rhamphoryncus




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Michael Banck
On Fri, Jan 11, 2002 at 04:49:19PM +, Mark Brown wrote:
  You can't, in general, close *all* open file descriptors. OPEN_MAX
  may not exist (and I would guess that it doesn't on the HURD). 
 
 If OPEN_MAX is undefined you could always use INT_MAX :-) .

I bet INT_MAX does not exist on Hurd, either...

Michael

-- 
-:- aj [EMAIL PROTECTED] has joined #debian-devel
willy oh, crap, 13 RC bugs against base?




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Ben Pfaff
Michael Banck [EMAIL PROTECTED] writes:

 On Fri, Jan 11, 2002 at 04:49:19PM +, Mark Brown wrote:
   You can't, in general, close *all* open file descriptors. OPEN_MAX
   may not exist (and I would guess that it doesn't on the HURD). 
  
  If OPEN_MAX is undefined you could always use INT_MAX :-) .
 
 I bet INT_MAX does not exist on Hurd, either...

I bet it does.  The ANSI C standard requires that INT_MAX be
defined.  POSIX only requires that OPEN_MAX be defined if it has
a fixed, uniform limit.
-- 
While the Melissa license is a bit unclear, Melissa aggressively
 encourages free distribution of its source code.
--Kevin Dalley [EMAIL PROTECTED]




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Wichert Akkerman
Previously Henrique de Moraes Holschuh wrote:
 Please tell me one good reason not to use the init.d script interface to
 muck around with daemons _in maintainer scripts_?

The --exec option for start-stop-daemon. This option is very useful: it
gives start-stop-daemon the ability to verify that it is killing the
right process, and not another one with the same name or with the same
(recycled) pid. This is definitely the preferred way of using
start-stop-daemon.

The only problem with the --exec option is that it does not work if
you use it in the postinst after an upgrade to restart the daemon
since the binary has been replaced and will now have a different inode.

This gives you two options:
1. don't use --exec at all, not even in the init script.
2. don't use --exec in the postinst, or use it with a saved (hardlinked)
   copy of the original file

Option 1 means we loose the advantage of being sure we are killing the
right process. Option 2 is obviously better in that it does not have
that problem at all of you use a saved copy, or only during upgrades
if you only don't use --exec in the maintainer script.

Wichert.

-- 
  _
 /[EMAIL PROTECTED] This space intentionally left occupied \
| [EMAIL PROTECTED]http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0  2805 3CB8 9250 2FA3 BC2D |




Re: problem with debconf and start-stop-daemon

2002-01-11 Thread Henrique de Moraes Holschuh
On Fri, 11 Jan 2002, Wichert Akkerman wrote:
 Previously Henrique de Moraes Holschuh wrote:
  Please tell me one good reason not to use the init.d script interface to
  muck around with daemons _in maintainer scripts_?
 
 The --exec option for start-stop-daemon. This option is very useful: it
[...]
 The only problem with the --exec option is that it does not work if
 you use it in the postinst after an upgrade to restart the daemon
 since the binary has been replaced and will now have a different inode.

Yes. When one both replace the daemon executable AND the initscript uses
start-stop-daemon --exec, one has to stop the daemon in prerm. Lots of
packages do this already. I believe it is the default behaviour for
dh_initscript for example.

Any package that is -replacing- the daemon executable should know very well
what its initscript does, and how. In fact, in just about 99% of the cases,
either the same binary package or source package will provide the initscript
and the executable.  So I will assume we are talking about a maintainer
script maintained by the same person/crew that maintains the initscript.

The prerm solution is a problem for those who need to shorten the downtime
of the service.  e.g, IDS daemons. For those, it is still possible to have a
new target (say, stop-nocheck) in the init.d script that does not use
--exec, exactly the way it would be done in the postinst.

 1. don't use --exec at all, not even in the init script.
 2. don't use --exec in the postinst, or use it with a saved (hardlinked)
copy of the original file

Actually, I was not aware of 2). I like it.  While it would be possible (but
ugly) to have such an stop-alike /usr/sbin/daemon.temp initscript target,
it would look a bit kludgy (but perfectly legal, and supported).

Well, policy will say should, not must for the use of invoke-rc.d and
initscripts. There is no reason why we could not add a sentence to the
effect of maintainer scripts that cannot use the initscript for some reason
to execute an action on the service, must verify (using invoke-rc.d
--query), if they would be allowed to execute a given initscript action
(stop, start, restart, reload) before doing so directly.

i.e., you could either live with a new action in your init.d script (using
either method 1 or 2 to stop the daemon), stop it in prerm, or call
invoke-rc.d to verify if the admin frowns upon what you're going to do and
if it says its ok, do the start-stop-daemon thing directly.

Would that be good enough?

-- 
  One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie. -- The Silicon Valley Tarot
  Henrique Holschuh