summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@canonical.com>2010-12-06 13:15:23 +0000
committerMilan Bouchet-Valat <nalimilan@club.fr>2010-12-06 18:33:05 +0100
commit3a6c2f9d5b024bab6ac9e6b6ef5e41d9197286a6 (patch)
treefc625da2e05632fcf52cc1810791705d719e24c3
parent85765df620a01a49ef7bcd6634c75750e9d394ae (diff)
bgo#449267 - Don't create empty NTP configuration files
If /etc/ntp.conf (or the platform equivalent) doesn't exist, then merely synchronising the clock in time-admin would create it as an empty file. This caused other time syncing problems later (see e.g. https://bugs.launchpad.net/bugs/83604).
-rw-r--r--Time/NTP.pm5
1 files changed, 5 insertions, 0 deletions
diff --git a/Time/NTP.pm b/Time/NTP.pm
index e7be3a9..026ba3e 100644
--- a/Time/NTP.pm
+++ b/Time/NTP.pm
@@ -75,6 +75,11 @@ sub ntp_conf_replace
my ($line_key, $val, $rest);
my ($n, $ret);
+ # If config file does not exist, and no server has to be written,
+ # don't create and empty file that will confuse package managers.
+ # Notably, this avoids creating an empty file when simply running ntpdate.
+ return if (!&Utils::File::exists ($file) && !@$value);
+
&Utils::Report::enter ();
&Utils::Report::do_report ("replace_split", $key, $file);