/etc/dhcp3/dhclient-exit-hooks.d/ntp breaks local NTP server (patch)

Bug #575458 reported by Dave Smith
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ntp (Ubuntu)
Won't Fix
Medium
Unassigned
Nominated for Lucid by Clint Byrum

Bug Description

Binary package hint: ntp

The dhcp exit hook for ntp removes *all* ntp servers from ntp.conf if the dhcp server provides a new ntp host. This is generally good, unless your computer *is* an ntp server. In this case, your ntp server won't work the next time your computer starts without DHCP.

The following patch fixes the problem by *not* replacing ntp servers with an address beginning with "127.":

Patch for /etc/dhcp3/dhclient-exit-hooks.d/ntp:
@@ -40,7 +40,7 @@
   echo "server $server iburst"
    done
    echo
- sed -r -e '/^ *(server|peer).*$/d' $NTP_CONF
+ sed -r -e '/^ *(server *[^1][^2][^7]\.|peer).*$/d' $NTP_CONF
  ) >>$tmp

  mv $tmp $NTP_DHCP_CONF

$ lsb_release -rd
Description: Ubuntu 10.04 LTS
Release: 10.04

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: ntp (not installed)
ProcVersionSignature: Ubuntu 2.6.32-21.32-generic 2.6.32.11+drm33.2
Uname: Linux 2.6.32-21-generic x86_64
NonfreeKernelModules: nvidia
Architecture: amd64
Date: Tue May 4 17:06:40 2010
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release amd64 (20091027)
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.utf8
 SHELL=/bin/bash
SourcePackage: ntp

Related branches

Revision history for this message
Chuck Short (zulcss) wrote :

Thanks this will be fixed in maverick and possibly backported to lucid.

REgards
chuck

Changed in ntp (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Dave Smith (djsmith) wrote :

Great. Thanks!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ntp - 1:4.2.4p8+dfsg-1ubuntu4

---------------
ntp (1:4.2.4p8+dfsg-1ubuntu4) maverick; urgency=low

  * debian/dhcp.ntp: Dont remove *all* ntp server from ntp.conf.
    (LP: #575458)
  * debian/apparmor-profile: Allow access to /dev/ttyS*
    (LP: #596859)
 -- Chuck Short <email address hidden> Tue, 22 Jun 2010 09:24:02 -0400

Changed in ntp (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Jeffrey Hutzelman (jhutz) wrote :

> The following patch fixes the problem by *not* replacing ntp servers with an address beginning with "127."

No, it doesn't. It masks the problem by removing only servers with a name or address that starts with something other than a '1', followed by something other than a '2', followed by something other than a '7', followed by a dot. For example, with your patch, the following entries are no longer removed:

server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org
server 127.1.2.3
server clock-1.cs.cmu.edu

... but this is:

server ntp.ubuntu.com

Unfortunately, this means that several of the server entries in the default /etc/ntp.conf are no longer removed. As a result, an unmodified machine booting on a network where DHCP provides a list of local NTP servers gets the local servers plus four from pool.ntp.org.

A better answer here would be to find a proper solution to #374896, such that locally-added entries can be retained when desired (and only then!), and use that for refclock entries (127.*) as well.

Revision history for this message
Robie Basak (racb) wrote :

We've been reviewing the entire Ubuntu delta for ntp, and came across this sed rule change which is still active. I will drop it for Xenial.

I agree with Jeffrey. The sed rule is incorrect - it does not achieve what it attempts to achieve, and creates surprising behaviour.

Fundamentally we have two things at odds with each other. There are two sources for NTP servers: 1) ntp.conf; and 2) any DHCP response. Clearly there are use cases where the DHCP response should be used over an ntp.conf default, and there are also use cases where the DHCP response should be ignored and ntp.conf's default (or changed) settings used instead.

The only sane thing to do is to pick a default that will work for the majority of users, and instruct users for whom this does not work on what to do instead.

If you have configured your system to use DHCP, I think it is reasonable to expect your system to honor NTP settings received back from DHCP. IMHO, this should by default overrule any setting in ntp.conf, and so Debian's current path is sane, and Ubuntu should follow.

Therefore I am dropping Ubuntu's delta on this point for Xenial.

If you have a special case where you are using DHCP but do not want DHCP's NTP server response to override local settings, then you should configure the DHCP client you are using to ignore any NTP part of the DHCP response to get the behaviour you need. I'd appreciate if someone could comment with exact steps on how to achieve this.

I'll mark this bug Won't Fix now, to reflect the fact that the original reporter's actual behaviour is the expected behaviour for Xenial onwards.

Changed in ntp (Ubuntu):
status: Fix Released → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.