On Wed, Feb 15, 2006 at 12:09:43AM +1300, Matt Brown wrote:
> Hi, 
> 
> I have prepared a NMU patch to fix this bug as a part of the T & S
> portion of my NM application. 

Thanks for doing this.

> Additionally the running function never succeeded because portreserve
> doesn't create a pid file. This is fairly impolite for a daemon.

Agreed.

> Unfortunately the --make-pidfile option to start-stop-daemon is not able
> to create a pidfile in this situation so I have patched the portreserve
> binary to create a pidfile. 

Why doesn't --make-pidfile work?

In any case, about put_pid():

* /var/run should not be harcoded, it should be #DEFINEd (that way the
  patch is usable for other distros)

* it should return an integer to determine if it is succesful or not (the
  main program could, or could not, care about the pid file
  creation and check the return value)

* there's a buffer overflow if 'fname' is longer than 512 chars. buf should
  *not* be of a static size

* it should refuse to run (or create a pidfile) if the pidfile already
  exists.

Also the program should remove the pidfile on exit. Otherwise the init.d
file will not be able to start it up properly if it gets killed for some
reason.

You also get a conflict if root runs 'portresevere' manually after the system
started and might end up with two copies of the daemon.

Have you reused code from somewhere or is it your own? 

I suggest you reuse a pidfile creation function from some other tested
program, there should be plenty of examples around.  If you don't find any
then I suggest you  change the put_pid() function to just drop in
PIDDIR/PROGNAME where PIDDIR is #DEFINEd to /var/run and PROGNAME is #DEFINEd
to portresever. The funcion should check if the file exists and abort if it does
(maybe through a negative return value that the main program uses to abort
instead of doing it from put_pid())

I don't like the patch to portreserve.c and I object to this NMU. You *can*
NMU, however, to include the changes to the init.d script.

Regards

Javier

Attachment: signature.asc
Description: Digital signature

Reply via email to