Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates-src > by-pkgid > ab4b662b9827b6375ffd451bf4abd615 > files > 227

systemd-44-24.fc17.src.rpm

From 6d4821fb8574cf737422ebc8290eb5dc069ae47b Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 25 Apr 2012 16:49:02 +0200
Subject: [PATCH] timedated: introduce systemd-timedated-ntp.target which is
 controlled by timedated's NTP setting

We shouldn't hardcode the name of the NTP implementation in the
timedated mechanism, especially since Fedora currently switched from NTP
to chrony.

This patch introduces a new target that is enabled/disabled instead of
the actual NTP implementation. The various NTP implementations should
then add .wants/ symlinks to their services and BindTo back to the
target, so that their implementations are started/stopped jointly with
the target.

https://bugzilla.redhat.com/show_bug.cgi?id=815748
(cherry picked from commit e2875c46936a16efc0f58f9e6e2570cdda8d6d98)

Conflicts:

	Makefile.am
---
 Makefile.am                        |    3 ++-
 src/timedate/timedated.c           |    6 +++---
 units/systemd-timedated-ntp.target |   17 +++++++++++++++++
 3 files changed, 22 insertions(+), 4 deletions(-)
 create mode 100644 units/systemd-timedated-ntp.target

diff --git a/Makefile.am b/Makefile.am
index aad5757..2730006 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -283,7 +283,8 @@ dist_systemunit_DATA = \
 	units/quotaon.service \
 	units/systemd-ask-password-wall.path \
 	units/systemd-ask-password-console.path \
-	units/syslog.target
+	units/syslog.target \
+	units/systemd-timedated-ntp.target
 
 nodist_systemunit_DATA = \
 	units/getty@.service \
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 6a7d980..75a8536 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -304,7 +304,7 @@ static int write_data_local_rtc(void) {
 
 static int read_ntp(DBusConnection *bus) {
         DBusMessage *m = NULL, *reply = NULL;
-        const char *name = "ntpd.service", *s;
+        const char *name = "systemd-timedated-ntp.target", *s;
         DBusError error;
         int r;
 
@@ -374,7 +374,7 @@ finish:
 
 static int start_ntp(DBusConnection *bus, DBusError *error) {
         DBusMessage *m = NULL, *reply = NULL;
-        const char *name = "ntpd.service", *mode = "replace";
+        const char *name = "systemd-timedated-ntp.target", *mode = "replace";
         int r;
 
         assert(bus);
@@ -421,7 +421,7 @@ finish:
 
 static int enable_ntp(DBusConnection *bus, DBusError *error) {
         DBusMessage *m = NULL, *reply = NULL;
-        const char * const names[] = { "ntpd.service", NULL };
+        const char * const names[] = { "systemd-timedated-ntp.target", NULL };
         int r;
         DBusMessageIter iter;
         dbus_bool_t f = FALSE, t = TRUE;
diff --git a/units/systemd-timedated-ntp.target b/units/systemd-timedated-ntp.target
new file mode 100644
index 0000000..1284248
--- /dev/null
+++ b/units/systemd-timedated-ntp.target
@@ -0,0 +1,17 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+# This target is enabled/disabled via the timedated mechanism when the
+# user asks for it via the UI. NTP implementations should hook
+# themselves into this target via .wants/ symlinks, and then add
+# BindTo= on this target so that they are stopped when it goes away.
+
+[Unit]
+Description=Network Time Protocol
+
+[Install]
+WantedBy=multi-user.target