[systemd-devel] [PATCH] timedated: add configure option to set name of controlled NTP service

Miroslav Lichvar mlichvar at redhat.com
Thu Aug 21 03:49:49 PDT 2014


This is useful for installations where some other service than
systemd-timesyncd is used to synchronize the system clock.
---
 configure.ac             |  9 +++++++++
 src/timedate/timedated.c | 10 +++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 18b7198..d9f95d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -948,6 +948,15 @@ if test "x$enable_timedated" != "xno"; then
 fi
 AM_CONDITIONAL(ENABLE_TIMEDATED, [test "$have_timedated" = "yes"])
 
+AC_ARG_WITH(ntp-service,
+        AS_HELP_STRING([--with-ntp-service=NTPSERVICE],
+                [NTP service controlled by timedated]),
+        [NTP_SERVICE="$withval"],
+        [NTP_SERVICE="systemd-timesyncd.service"])
+
+AC_DEFINE_UNQUOTED(NTP_SERVICE, ["$NTP_SERVICE"], [NTP service controlled by timedated])
+AC_SUBST(NTP_SERVICE)
+
 # ------------------------------------------------------------------------------
 have_timesyncd=no
 AC_ARG_ENABLE(timesyncd, AS_HELP_STRING([--disable-timesyncd], [disable timesync daemon]))
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index fa3f947..cdd16e6 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -198,7 +198,7 @@ static int context_read_ntp(Context *c, sd_bus *bus) {
                         &error,
                         &reply,
                         "s",
-                        "systemd-timesyncd.service");
+                        NTP_SERVICE);
 
         if (r < 0) {
                 if (sd_bus_error_has_name(&error, SD_BUS_ERROR_FILE_NOT_FOUND) ||
@@ -236,7 +236,7 @@ static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
                                 error,
                                 NULL,
                                 "ss",
-                                "systemd-timesyncd.service",
+                                NTP_SERVICE,
                                 "replace");
         else
                 r = sd_bus_call_method(
@@ -248,7 +248,7 @@ static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
                                 error,
                                 NULL,
                                 "ss",
-                                "systemd-timesyncd.service",
+                                NTP_SERVICE,
                                 "replace");
 
         if (r < 0) {
@@ -282,7 +282,7 @@ static int context_enable_ntp(Context*c, sd_bus *bus, sd_bus_error *error) {
                                 error,
                                 NULL,
                                 "asbb", 1,
-                                "systemd-timesyncd.service",
+                                NTP_SERVICE,
                                 false, true);
         else
                 r = sd_bus_call_method(
@@ -294,7 +294,7 @@ static int context_enable_ntp(Context*c, sd_bus *bus, sd_bus_error *error) {
                                 error,
                                 NULL,
                                 "asb", 1,
-                                "systemd-timesyncd.service",
+                                NTP_SERVICE,
                                 false);
 
         if (r < 0) {
-- 
1.9.3



More information about the systemd-devel mailing list