[pkg-ntp-maintainers] Bug#606107: ntp: handle empty ntp.conf gracefully (working around system-tools-backends bug)

Colin Watson cjwatson at ubuntu.com
Mon Dec 6 12:35:17 UTC 2010


Package: ntp
Version: 1:4.2.6.p2+dfsg-1
Severity: normal
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch natty

(This bug was originally https://bugs.launchpad.net/bugs/83604.)

Bug #397648 means that pressing the "Synchronise now" button (usually
rendered with the stock reload icon, I believe) in time-admin leaves an
empty /etc/ntp.conf if only ntpdate is installed but not the full ntp
package.  This confuses ntpdate-debian into not doing anything useful,
and furthermore means that if you install the ntp package later on then
it probably won't create a useful configuration file because dpkg thinks
you already have a local version.

I entirely agree that this should be fixed in system-tools-backends, and
I've sent a patch upstream (I'll copy this to the Debian bug shortly
too).  However, there are a couple of fairly unintrusive things that
could be changed in ntp to cope with this.  Firstly, Mika Wahlroos sent
a patch to the Launchpad bug referenced above which makes ntpdate-debian
disregard empty files.  Secondly, ntp.preinst could remove an empty
/etc/ntp.conf on fresh installations.

The following patch deals with both of these.

  * 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.

diff -Nru ntp-4.2.6.p2+dfsg/debian/ntp.preinst ntp-4.2.6.p2+dfsg/debian/ntp.preinst
--- ntp-4.2.6.p2+dfsg/debian/ntp.preinst	2010-11-30 15:58:37.000000000 +0000
+++ ntp-4.2.6.p2+dfsg/debian/ntp.preinst	2010-12-06 11:11:26.000000000 +0000
@@ -18,5 +18,11 @@
 		1:4.2.6.p1+dfsg-1 -- "$@"
 fi
 
+if [ "$1" = install ] && [ -e /etc/ntp.conf ] && [ ! -s /etc/ntp.conf ]; then
+	# Work around system-tools-backends bug that left an empty file
+	# (https://bugs.launchpad.net/bugs/83604).
+	rm -f /etc/ntp.conf
+fi
+
 #DEBHELPER#
 
diff -Nru ntp-4.2.6.p2+dfsg/debian/ntpdate-debian ntp-4.2.6.p2+dfsg/debian/ntpdate-debian
--- ntp-4.2.6.p2+dfsg/debian/ntpdate-debian	2010-11-30 15:57:38.000000000 +0000
+++ ntp-4.2.6.p2+dfsg/debian/ntpdate-debian	2010-12-06 11:02:56.000000000 +0000
@@ -8,7 +8,7 @@
 
 if [ "$NTPDATE_USE_NTP_CONF" = yes ]; then
 	for f in /var/lib/ntp/ntp.conf.dhcp /etc/ntp.conf /etc/openntpd/ntpd.conf; do
-		if [ -r "$f" ]; then
+		if [ -r "$f" ] && [ -s "$f" ]; then
 			file=$f
 			break
 		fi

Thanks,

-- 
Colin Watson                                       [cjwatson at ubuntu.com]





More information about the pkg-ntp-maintainers mailing list