ntpdate 1:4.2.2.p4+dfsg-1ubuntu2 has a flawed configuration file.

Bug #83604 reported by PtOLU8zjbZxlgNOiyGyd
28
This bug affects 2 people
Affects Status Importance Assigned to Milestone
GST
Fix Released
Medium
ntp (Ubuntu)
Fix Released
Medium
Unassigned
system-tools-backends (Debian)
Fix Released
Unknown
system-tools-backends (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: ntp

This is in feisty (but it is an explanation for bug #82774 as well, the basic reason is the same for edgy, different configuration flaws).

I just noticed the problem in a feisty up-to-date system. In ntpdate (1:4.2.2.p4+dfsg-1ubuntu2) packaging, /etc/default/ntpdate is set up in such a way that it defaults to the ntp servers defined in /etc/ntp.conf, an empty file; which makes debconf to *not* create a proper /etc/ntp.conf if one decided to install ntpd on a whim. And to add insult to injury, /etc/default/ntpdate does not have the needed config flag to have ntpdate log its success or failure to the syslog ("-s"), thus it defaults to standard output, which upstart diligently makes all efforts to send to /dev/null.

Revision history for this message
didier (did447-deactivatedaccount) wrote :

-s is set in /etc/network/if-up.d/ntpdate, isn't it?

Not sure about 82774 too, AFAIK edgy doesn't use ntpdate-debian, just plain ntpdate.

Changed in ntp:
status: Unconfirmed → Confirmed
Revision history for this message
PtOLU8zjbZxlgNOiyGyd (lkgdx5kefrptmd7ccufa-deactivatedaccount) wrote :

-s is set in /etc/network/if-up.d/ntpdate, isn't it?

Nope

Revision history for this message
PtOLU8zjbZxlgNOiyGyd (lkgdx5kefrptmd7ccufa-deactivatedaccount) wrote :

He! You are right, it does (didn't see it earlier when I wrote the bug report.)

Yet, syslog reporting is not working, because ntpdate-debian checks the settings in /etc/default/ntpdate and acts accordingly. ntpdate should log into /var/log/daemon.log (being exec'd as part the the init/upstart process). I wasn't getting any entries before a put a "-s" in /etc/default/ntpdate. So, you never know if your wallclock date was updated when your networking went up. (BTW, this works OK for desktops, but servers should really have other means of keeping time drift in check).

Revision history for this message
didier (did447-deactivatedaccount) wrote :

I'm not sure for -s

With an empty /etc/ntp.conf ntpdate is not run at all because the set -e in ntpdate-date script.

sh -x /usr/sbin/ntpdate-debian

 set -e
+ [ -r /etc/default/ntpdate ]
+ . /etc/default/ntpdate
+ NTPDATE_USE_NTP_CONF=yes
+ NTPSERVERS=ntp.ubuntu.com
+ NTPOPTIONS=
+ [ yes = yes ]
+ [ -r /etc/ntp.conf.dhcp ]
+ [ -r /etc/ntp.conf ]
+ file=/etc/ntp.conf
+ [ -n /etc/ntp.conf ]
+ sed -rne s/^(server|peer) ([-_.[:alnum:]]+).*$/\2/p /etc/ntp.conf
+ grep -v ^127\.127\.
+ NTPSERVERS=

Now there's no /etc/ntp.conf in ntpdate package... And the culprit is :
system-tools-backends, via gnome update time?

But maybe ntpdate-date should test for -r and -s file?

Revision history for this message
Sebastien Bacher (seb128) wrote :

didier, it's not clear why you opened that system-tools-backend, why do you think that's a bug on that package and not on ntp?

Revision history for this message
didier (did447-deactivatedaccount) wrote : Re: [Bug 83604] Re: ntpdate 1:4.2.2.p4+dfsg-1ubuntu2 has a flawed configuration file.

On 2/7/07, Sebastien Bacher <email address hidden> wrote:
> didier, it's not clear why you opened that system-tools-backend, why do
> you think that's a bug on that package and not on ntp?
How to reproduce this bug:
On feisty
delete the empty /etc/ntp.conf if any
open from the panel or the control center time-admin
click on synchronize now.

a new empty /etc/ntp.conf is created

cf.
/usr/share/system-tools-backends-2.0/scripts/Time/NTP.pm

Didier

Revision history for this message
Michael R. Head (burner) wrote :

Ah. Now I understand why I just missed my bus!

"sudo rm /etc/ntp.conf" and it'll never happen again, hehe.

Revision history for this message
Michael R. Head (burner) wrote :

BTW: as far as I can tell, this prevents the "Synchronize Now" button in time-admin from working.

Revision history for this message
PtOLU8zjbZxlgNOiyGyd (lkgdx5kefrptmd7ccufa-deactivatedaccount) wrote :

Hmm... If erasing /etc/ntp.conf disables the "Synchronize Now" button in time-admin, then the solution I offered in the original bug report seems appropriate: Supply an /etc/default/ntpdate that sets:

NTPDATE_USE_NTP_CONF=yes

That works here.

Revision history for this message
PtOLU8zjbZxlgNOiyGyd (lkgdx5kefrptmd7ccufa-deactivatedaccount) wrote :

Bah! I'm sleep-walking already! I meant

NTPDATE_USE_NTP_CONF=no

of course.

Revision history for this message
Mika Wahlroos (mpw) wrote :

Basically, the problem is that with the default configuration ntpdate only works if the ntp package is also installed (thus providing /etc/ntp.conf), but while ntpdate is installed by default (ubuntu-minimal depends on it), the ntp package is not (because nothing depends on it, and it shouldn't really be needed by default either).

Thus, one of the following should probably be done:
1. Change the configuration to use the settings in /etc/default/ntpdate instead (by setting NTPDATE_USE_NTP_CONF=no in said file as mentioned by Pedro Alejandro López-Valencia)
2. Change ntpdate so that it falls back to using the settings in /etc/default/ntpdate if the ntp configuration in /etc/ntp.conf is empty or fails to provide anything useful
3. Also install ntp by default, or have ntpdate at least suggest it (should really be depends, since currently ntpdate won't work without ntp)

Option 2 seems to the most reasonable to me in the long run, but option 1 would be a defensible quick solution (assuming that we want all requests from ntpdate to go to ntp.ubuntu.com by default since that's what it would use).

Yes, this also breaks time-admin in Gnome, but the actual bug is still in the ntpdate configuration requiring a config file that may not exit.

Revision history for this message
Mika Wahlroos (mpw) wrote :

Now that I look at it, gnome-system-tools has hard depends on neither ntpdate or ntp, but it suggests ntp. However, "suggests" doesn't make it installed by default, and time-admin in gnome-system-tools remains inoperative. It works if ntpdate works, though, even if the gnome-system-tools package doesn't depend on ntpdate in any way.

So, gnome-system-tools may also have a dependency bug, but that's a separate issue.

Revision history for this message
Mika Wahlroos (mpw) wrote :

Looks like it's actually quite easy to take the fallback option.

The attached patch makes ntpdate use /etc/ntp.conf only if it's readable and non-empty. This fixes the breakage in case a tool has created an empty configuration file for ntp.conf. The ntp configuration in /etc/ntp.conf is still used if the ntp package is installed and brings with it a proper configuration file (or if one happens to exist for some other reason).

Revision history for this message
PtOLU8zjbZxlgNOiyGyd (lkgdx5kefrptmd7ccufa-deactivatedaccount) wrote :

As well, it is important to notice that ntpdate is deprecated upstream and scheduled for deletion as stated in ntpd(8) in the entry for the -q option, which is its functional replacement.

Revision history for this message
Mika Wahlroos (mpw) wrote :

Pedro,

That's a good catch. However, I don't suppose that change is going to happen for hardy since ubuntu-minimal still seems to depend on ntpdate in the current development branch. The time-admin package in hardy still seems to generate an empty /etc/ntp.conf when the synchronize button is pressed, causing further synchronization attempts to fail. Since hardy is going to be a LTS release, this functionality may be broken for a long time, and a temporary workaround (not trying to use ntp.conf or its relatives if they're empty) is easy. Getting rid of ntpdate may be the long term solution for upcoming Ubuntu releases, of course.

Even if we fixed time-admin, where the actual bug is (creating the empty configuration file), such a file would still remain in systems where a buggy time-admin has been used before. Thus working around it in the ntpdate configuration is probably the simplest way to get ntpdate working reliably, and it's also pretty much non-destructive (why would you want to have and use an empty ntp configuration file in the first place?).

The patch I attached earlier was for gutsy. I'm now attaching a similar patch for hardy.

Daniel T Chen (crimsun)
Changed in ntp:
importance: Undecided → Medium
status: Confirmed → Triaged
Revision history for this message
Gaetan Nadon (memsize) wrote :

The affected system-tools-backends package flags this bug as New and in need of triage. Reading the comments suggests there is no fix required for this package. I'll mark it as invalid for that reason, not because it is not affected by the bug in ntp.
Should bug reports be raised against backend tools, they should be marked as duplicate.

BugSquad

Changed in system-tools-backends:
status: New → Invalid
Revision history for this message
Rashkae (rashkae) wrote :

This bug still affects a fresh install of Jaunty, and it's left as Invalid??? What am I missing?

Revision history for this message
Gaetan Nadon (memsize) wrote :

The bug report for package "ntp" has been triaged and a priority assigned. Only the package "system-tools-backends" has been marked invalid as it does to appear to be the root cause of the problem requiring a code fix. (https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/83604/comments/15).

Revision history for this message
Milan Bouchet-Valat (nalimilan) wrote :

Is this still buggy in Lucid?

Anyway, I think fixing bug 583994 by replacing ntpdate with ntpd would solve this the right way.

Revision history for this message
Colin Watson (cjwatson) wrote :

Mika's patch is certainly still applicable in Natty. I think I'm going to go ahead and apply that; it seems common to have an empty /etc/ntp.conf due to this (I had one myself) and this is an easy workaround. There's a separate bug 427775 for more general logic problems with /etc/network/if-up.d/ntpdate, and a separate bug 583994 for replacing ntpdate altogether.

I'm also going to reopen the system-tools-backends task on this bug, due to this comment in the original bug report:

  "it defaults to the ntp servers defined in /etc/ntp.conf, an empty file; which makes debconf to *not* create a proper /etc/ntp.conf if one decided to install ntpd on a whim"

(It's actually dpkg, not debconf, but the basic point stands.)

Because of this, system-tools-backends should take care not to create /etc/ntp.conf as an empty file if it does not already exist.

Changed in system-tools-backends (Ubuntu):
status: Invalid → Triaged
importance: Undecided → Medium
Revision history for this message
Colin Watson (cjwatson) wrote :

Mika, I'm dropping the debian/ntpdate.default part of your patch. It's correct, and I agree that all other things being equal this documentation should be brought up to date, but it's going to be very common to have modified the NTPSERVERS line that immediately follows it (or to be upgrading a system where somebody else modified that line), and changing that text would I think result in a lot of dpkg conffile prompts. I'd rather avoid that when it isn't strictly necessary.

While applying this patch, I'm also going to make ntp.preinst check for an empty /etc/ntp.conf on fresh installation and remove it, to work around this system-tools-backends bug.

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

This bug was fixed in the package ntp - 1:4.2.6.p2+dfsg-1ubuntu2

---------------
ntp (1:4.2.6.p2+dfsg-1ubuntu2) natty; urgency=low

  * debian/ntpdate-debian: Disregard empty ntp.conf files (thanks, Mika
    Wahlroos; LP: #83604).
  * debian/ntp.preinst: Remove empty /etc/ntp.conf on fresh installation, to
    work around the system-tools-backends part of LP #83604.
 -- Colin Watson <email address hidden> Mon, 06 Dec 2010 11:13:04 +0000

Changed in ntp (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package system-tools-backends - 2.10.1-0ubuntu2

---------------
system-tools-backends (2.10.1-0ubuntu2) natty; urgency=low

  * 03ubuntu_empty_ntp_conf.patch: Don't create empty NTP configuration
    files (LP: #83604).
 -- Colin Watson <email address hidden> Mon, 06 Dec 2010 11:56:01 +0000

Changed in system-tools-backends (Ubuntu):
status: Triaged → Fix Released
Changed in system-tools-backends (Debian):
status: Unknown → Confirmed
Changed in gst:
importance: Unknown → Medium
status: Unknown → Fix Released
Changed in system-tools-backends (Debian):
status: Confirmed → Fix Released
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.