ntp-server: Cannot find user `ntp'

Klaus Alexander Seistrup kseistrup at gmail.com
Tue Dec 21 18:34:41 UTC 2004


Hi,

My pc is part of the pool.ntp.org¹ NTP pool, and for that reason I
want my ntpd to stay in the air.  To accomplish that I have set up
runit² to supervise the ntpd process and to restart ntpd if it exits. 
This used to work on my Debian/unstable box, but it fails on
Ubuntu/hoary for reasons I cannot fathom (I'm using the same "run"
script on Debian and Ubuntu).

The way it happens is this:  When run by runit, ntpd immediately exits
and logs a "Cannot find user `ntp'" error message to syslog.  The
funny thing is that when I run ntpd manually from a root prompt, ntpd
starts as expected and setuid()'s itself to user ntp -- just the way
it's supposed to -- but when run by runsv (heck, even when it's run by
init!), ntp fails to "find user ntp".  First I thought it was a
chroot() problem, but the behaviour persisted even when I specified
"-i /".

My "run" script looks like this:

<snip>
#!/bin/sh

exec 0</dev/null
exec 2>&1

exec /usr/bin/chpst -e ./env -o 250 /bin/posh -c '
  echo "<env>";
  set;
  echo "</env>";
  exec /usr/bin/nice --adjustment="${NICELEVEL}" \
    /usr/sbin/ntpd -n -p /var/run/ntpd.pid -c /etc/ntp.conf
'

# we shouldn't be here
exit 1
# eof
</snip>

I use posh instead of sh/bash because posh starts up faster, and
leaves less garbage in the environment.  It has worked like a charm on
Debian/unstable.

To reiterate:  I can -- and currently do -- start ntpd manually, using
exactly the same method as above, but ntpd fails when the same "run"
script is run by runsv.  Also, ntpd fails in a similar way when init
runs the /etc/init.d/ntp-server script during startup.

Do anyone else experience this?  Or do anyone have comments to this
weird behaviour (or mine, hehe...)?

Cheers,

  // Klaus

P.S.: Ubuntu's ntpd setuid()'s to user ntp.  This is very different
from Debian's ntpd, that runs as root.

¹)  <http://fortytwo.ch/time> / <http://www.pool.ntp.org/>
²)  <http://smarden.org/runit/> / <http://packages.debian.org/runit>
-- 
Klaus Alexander Seistrup
SubZeroNet · Copenhagen · Denmark




More information about the ubuntu-users mailing list