[pkg-ntp-maintainers] Bug#711548: Bug#711548: Fragile handling of pidfile by /etc/init.d/ntp

Kurt Roeckx kurt at roeckx.be
Fri Jun 7 20:11:30 UTC 2013


On Fri, Jun 07, 2013 at 09:53:38PM +0200, Sergio Gelato wrote:
> Package: ntp
> Version: 1:4.2.6.p5+dfsg-2
> 
> The current /etc/init.d/ntp cannot recover from a situation in which
> /var/run/ntpd.pid exists but does not contain the correct PID for the
> running daemon.
> 
> How to reproduce:
> 
> # pgrep -f ntpd
> 9219
> # ps -f -p 9404
> UID        PID  PPID  C STIME TTY          TIME CMD
> root      9404  9395  0 20:38 pts/2    00:00:00 /bin/bash
> # printf 9404 > /var/run/ntpd.pid

Why do you do this?

> # invoke-rc.d ntp status
> NTP server is running.
> # echo $?
> 0
> # invoke-rc.d ntp restart
> Stopping NTP server: ntpd.
> Starting NTP server: ntpd.
> # echo $?
> 0
> # pgrep -f ntpd
> 9219

Did you expect something else, if you break the pid file?

It's running as 9219, but you decided to write 9404 to the file.
So of course it didn't kill it.

> # cat /var/run/ntpd.pid
> 9485

But you started a new one, which wrote a PID file, and then it
died because it detected that an other ntpd was still running,
and you really one want 1 running.  It probably shouldn't have
written the pid file in that case.  But it should never have
gotton in the situation if you didn't manually write something
to that pid file.

# ps -f -p 9404
> UID        PID  PPID  C STIME TTY          TIME CMD
> root      9404  9395  0 20:38 pts/2    00:00:00 /bin/bash

So the script did the right thing and did not kill some
random process that happens to be written in the pid file.


Kurt



More information about the pkg-ntp-maintainers mailing list