1 /* SPDX-License-Identifier: LGPL-2.1+ */
9 #include "sd-messages.h"
11 #include "alloc-util.h"
12 #include "bus-common-errors.h"
13 #include "bus-error.h"
15 #include "clock-util.h"
17 #include "fileio-label.h"
22 #include "main-func.h"
23 #include "path-util.h"
24 #include "selinux-util.h"
25 #include "signal-util.h"
26 #include "string-util.h"
29 #include "unit-name.h"
30 #include "user-util.h"
33 #define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
34 #define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
36 typedef struct UnitStatusInfo
{
39 char *unit_file_state
;
43 LIST_FIELDS(struct UnitStatusInfo
, units
);
46 typedef struct Context
{
49 Hashmap
*polkit_registry
;
50 sd_bus_message
*cache
;
52 sd_bus_slot
*slot_job_removed
;
54 LIST_HEAD(UnitStatusInfo
, units
);
57 static void unit_status_info_clear(UnitStatusInfo
*p
) {
60 p
->load_state
= mfree(p
->load_state
);
61 p
->unit_file_state
= mfree(p
->unit_file_state
);
62 p
->active_state
= mfree(p
->active_state
);
65 static void unit_status_info_free(UnitStatusInfo
*p
) {
68 unit_status_info_clear(p
);
74 static void context_clear(Context
*c
) {
80 bus_verify_polkit_async_registry_free(c
->polkit_registry
);
81 sd_bus_message_unref(c
->cache
);
83 sd_bus_slot_unref(c
->slot_job_removed
);
85 while ((p
= c
->units
)) {
86 LIST_REMOVE(units
, c
->units
, p
);
87 unit_status_info_free(p
);
91 static int context_add_ntp_service(Context
*c
, const char *s
) {
94 if (!unit_name_is_valid(s
, UNIT_NAME_PLAIN
))
97 /* Do not add this if it is already listed */
98 LIST_FOREACH(units
, u
, c
->units
)
99 if (streq(u
->name
, s
))
102 u
= new0(UnitStatusInfo
, 1);
112 LIST_APPEND(units
, c
->units
, u
);
117 static int context_parse_ntp_services(Context
*c
) {
123 env
= getenv("SYSTEMD_TIMEDATED_NTP_SERVICES");
125 r
= context_add_ntp_service(c
, "systemd-timesyncd.service");
127 log_warning_errno(r
, "Failed to add NTP service \"systemd-timesyncd.service\", ignoring: %m");
133 _cleanup_free_
char *word
= NULL
;
135 r
= extract_first_word(&p
, &word
, ":", 0);
141 log_error("Invalid syntax, ignoring: %s", env
);
145 r
= context_add_ntp_service(c
, word
);
147 log_warning_errno(r
, "Failed to add NTP service \"%s\", ignoring: %m", word
);
153 static int context_ntp_service_is_active(Context
*c
) {
154 UnitStatusInfo
*info
;
159 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
161 LIST_FOREACH(units
, info
, c
->units
)
162 count
+= streq_ptr(info
->active_state
, "active");
167 static int context_ntp_service_is_enabled(Context
*c
) {
168 UnitStatusInfo
*info
;
173 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
175 LIST_FOREACH(units
, info
, c
->units
)
176 count
+= STRPTR_IN_SET(info
->unit_file_state
, "enabled", "enabled-runtime");
181 static int context_ntp_service_exists(Context
*c
) {
182 UnitStatusInfo
*info
;
187 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
189 LIST_FOREACH(units
, info
, c
->units
)
190 count
+= streq_ptr(info
->load_state
, "loaded");
195 static int context_read_data(Context
*c
) {
196 _cleanup_free_
char *t
= NULL
;
201 r
= get_timezone(&t
);
203 log_warning_errno(r
, "/etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.");
205 log_warning_errno(r
, "Failed to get target of /etc/localtime: %m");
207 free_and_replace(c
->zone
, t
);
209 c
->local_rtc
= clock_is_localtime(NULL
) > 0;
214 static int context_write_data_timezone(Context
*c
) {
215 _cleanup_free_
char *p
= NULL
;
220 if (isempty(c
->zone
)) {
221 if (unlink("/etc/localtime") < 0 && errno
!= ENOENT
)
227 p
= strappend("../usr/share/zoneinfo/", c
->zone
);
231 r
= symlink_atomic(p
, "/etc/localtime");
238 static int context_write_data_local_rtc(Context
*c
) {
240 _cleanup_free_
char *s
= NULL
, *w
= NULL
;
244 r
= read_full_file("/etc/adjtime", &s
, NULL
);
252 w
= strdup(NULL_ADJTIME_LOCAL
);
257 const char *e
= "\n"; /* default if there is less than 3 lines */
258 const char *prepend
= "";
261 p
= strchrnul(s
, '\n');
263 /* only one line, no \n terminator */
265 else if (p
[1] == '\0') {
266 /* only one line, with \n terminator */
270 p
= strchr(p
+1, '\n');
272 /* only two lines, no \n terminator */
277 /* third line might have a \n terminator or not */
279 end
= strchr(p
, '\n');
280 /* if we actually have a fourth line, use that as suffix "e", otherwise the default \n */
289 w
= new(char, a
+ (c
->local_rtc
? 5 : 3) + strlen(prepend
) + b
+ 1);
293 *(char*) mempcpy(stpcpy(stpcpy(mempcpy(w
, s
, a
), prepend
), c
->local_rtc
? "LOCAL" : "UTC"), e
, b
) = 0;
295 if (streq(w
, NULL_ADJTIME_UTC
)) {
296 if (unlink("/etc/adjtime") < 0)
305 return write_string_file_atomic_label("/etc/adjtime", w
);
308 static int context_update_ntp_status(Context
*c
, sd_bus
*bus
, sd_bus_message
*m
) {
309 static const struct bus_properties_map map
[] = {
310 { "LoadState", "s", NULL
, offsetof(UnitStatusInfo
, load_state
) },
311 { "ActiveState", "s", NULL
, offsetof(UnitStatusInfo
, active_state
) },
312 { "UnitFileState", "s", NULL
, offsetof(UnitStatusInfo
, unit_file_state
) },
321 /* Suppress calling context_update_ntp_status() multiple times within single DBus transaction. */
326 sd_bus_message_unref(c
->cache
);
327 c
->cache
= sd_bus_message_ref(m
);
330 LIST_FOREACH(units
, u
, c
->units
) {
331 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
332 _cleanup_free_
char *path
= NULL
;
334 unit_status_info_clear(u
);
336 path
= unit_dbus_path_from_name(u
->name
);
340 r
= bus_map_all_properties(
342 "org.freedesktop.systemd1",
350 return log_error_errno(r
, "Failed to get properties: %s", bus_error_message(&error
, r
));
356 static int match_job_removed(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
357 Context
*c
= userdata
;
366 r
= sd_bus_message_read(m
, "uoss", NULL
, &path
, NULL
, NULL
);
368 bus_log_parse_error(r
);
372 LIST_FOREACH(units
, u
, c
->units
)
373 if (streq_ptr(path
, u
->path
))
374 u
->path
= mfree(u
->path
);
379 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL
);
381 c
->slot_job_removed
= sd_bus_slot_unref(c
->slot_job_removed
);
387 static int unit_start_or_stop(UnitStatusInfo
*u
, sd_bus
*bus
, sd_bus_error
*error
, bool start
) {
388 _cleanup_(sd_bus_message_unrefp
) sd_bus_message
*reply
= NULL
;
396 r
= sd_bus_call_method(
398 "org.freedesktop.systemd1",
399 "/org/freedesktop/systemd1",
400 "org.freedesktop.systemd1.Manager",
401 start
? "StartUnit" : "StopUnit",
410 r
= sd_bus_message_read(reply
, "o", &path
);
412 return bus_log_parse_error(r
);
414 r
= free_and_strdup(&u
->path
, path
);
421 static int unit_enable_or_disable(UnitStatusInfo
*u
, sd_bus
*bus
, sd_bus_error
*error
, bool enable
) {
428 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
430 if (streq(u
->unit_file_state
, "enabled") == enable
)
434 r
= sd_bus_call_method(
436 "org.freedesktop.systemd1",
437 "/org/freedesktop/systemd1",
438 "org.freedesktop.systemd1.Manager",
446 r
= sd_bus_call_method(
448 "org.freedesktop.systemd1",
449 "/org/freedesktop/systemd1",
450 "org.freedesktop.systemd1.Manager",
460 r
= sd_bus_call_method(
462 "org.freedesktop.systemd1",
463 "/org/freedesktop/systemd1",
464 "org.freedesktop.systemd1.Manager",
475 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_time
, "t", now(CLOCK_REALTIME
));
476 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_ntp_sync
, "b", ntp_synced());
478 static int property_get_rtc_time(
481 const char *interface
,
482 const char *property
,
483 sd_bus_message
*reply
,
485 sd_bus_error
*error
) {
492 r
= clock_get_hwclock(&tm
);
494 log_warning("/dev/rtc is busy. Is somebody keeping it open continuously? That's not a good idea... Returning a bogus RTC timestamp.");
496 } else if (r
== -ENOENT
) {
497 log_debug("/dev/rtc not found.");
498 t
= 0; /* no RTC found */
500 return sd_bus_error_set_errnof(error
, r
, "Failed to read RTC: %m");
502 t
= (usec_t
) timegm(&tm
) * USEC_PER_SEC
;
504 return sd_bus_message_append(reply
, "t", t
);
507 static int property_get_can_ntp(
510 const char *interface
,
511 const char *property
,
512 sd_bus_message
*reply
,
514 sd_bus_error
*error
) {
516 Context
*c
= userdata
;
525 r
= context_update_ntp_status(c
, bus
, reply
);
529 return sd_bus_message_append(reply
, "b", context_ntp_service_exists(c
) > 0);
532 static int property_get_ntp(
535 const char *interface
,
536 const char *property
,
537 sd_bus_message
*reply
,
539 sd_bus_error
*error
) {
541 Context
*c
= userdata
;
550 r
= context_update_ntp_status(c
, bus
, reply
);
554 return sd_bus_message_append(reply
, "b", context_ntp_service_is_active(c
) > 0);
557 static int method_set_timezone(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
558 Context
*c
= userdata
;
565 r
= sd_bus_message_read(m
, "sb", &z
, &interactive
);
569 if (!timezone_is_valid(z
, LOG_DEBUG
))
570 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid time zone '%s'", z
);
572 if (streq_ptr(z
, c
->zone
))
573 return sd_bus_reply_method_return(m
, NULL
);
575 r
= bus_verify_polkit_async(
578 "org.freedesktop.timedate1.set-timezone",
587 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
589 r
= free_and_strdup(&c
->zone
, z
);
593 /* 1. Write new configuration file */
594 r
= context_write_data_timezone(c
);
596 log_error_errno(r
, "Failed to set time zone: %m");
597 return sd_bus_error_set_errnof(error
, r
, "Failed to set time zone: %m");
600 /* 2. Make glibc notice the new timezone */
603 /* 3. Tell the kernel our timezone */
604 r
= clock_set_timezone(NULL
);
606 log_debug_errno(r
, "Failed to tell kernel about timezone, ignoring: %m");
612 /* 4. Sync RTC from system clock, with the new delta */
613 assert_se(clock_gettime(CLOCK_REALTIME
, &ts
) == 0);
614 assert_se(localtime_r(&ts
.tv_sec
, &tm
));
616 r
= clock_set_hwclock(&tm
);
618 log_debug_errno(r
, "Failed to sync time to hardware clock, ignoring: %m");
622 "MESSAGE_ID=" SD_MESSAGE_TIMEZONE_CHANGE_STR
,
623 "TIMEZONE=%s", c
->zone
,
624 "TIMEZONE_SHORTNAME=%s", tzname
[daylight
],
625 "DAYLIGHT=%i", daylight
,
626 LOG_MESSAGE("Changed time zone to '%s' (%s).", c
->zone
, tzname
[daylight
]));
628 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL
);
630 return sd_bus_reply_method_return(m
, NULL
);
633 static int method_set_local_rtc(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
634 int lrtc
, fix_system
, interactive
;
635 Context
*c
= userdata
;
642 r
= sd_bus_message_read(m
, "bbb", &lrtc
, &fix_system
, &interactive
);
646 if (lrtc
== c
->local_rtc
)
647 return sd_bus_reply_method_return(m
, NULL
);
649 r
= bus_verify_polkit_async(
652 "org.freedesktop.timedate1.set-local-rtc",
665 /* 1. Write new configuration file */
666 r
= context_write_data_local_rtc(c
);
668 log_error_errno(r
, "Failed to set RTC to local/UTC: %m");
669 return sd_bus_error_set_errnof(error
, r
, "Failed to set RTC to local/UTC: %m");
672 /* 2. Tell the kernel our timezone */
673 r
= clock_set_timezone(NULL
);
675 log_debug_errno(r
, "Failed to tell kernel about timezone, ignoring: %m");
677 /* 3. Synchronize clocks */
678 assert_se(clock_gettime(CLOCK_REALTIME
, &ts
) == 0);
683 /* Sync system clock from RTC; first, initialize the timezone fields of struct tm. */
685 localtime_r(&ts
.tv_sec
, &tm
);
687 gmtime_r(&ts
.tv_sec
, &tm
);
689 /* Override the main fields of struct tm, but not the timezone fields */
690 r
= clock_get_hwclock(&tm
);
692 log_debug_errno(r
, "Failed to get hardware clock, ignoring: %m");
694 /* And set the system clock with this */
696 ts
.tv_sec
= mktime(&tm
);
698 ts
.tv_sec
= timegm(&tm
);
700 if (clock_settime(CLOCK_REALTIME
, &ts
) < 0)
701 log_debug_errno(errno
, "Failed to update system clock, ignoring: %m");
707 /* Sync RTC from system clock */
709 localtime_r(&ts
.tv_sec
, &tm
);
711 gmtime_r(&ts
.tv_sec
, &tm
);
713 r
= clock_set_hwclock(&tm
);
715 log_debug_errno(r
, "Failed to sync time to hardware clock, ignoring: %m");
718 log_info("RTC configured to %s time.", c
->local_rtc
? "local" : "UTC");
720 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "LocalRTC", NULL
);
722 return sd_bus_reply_method_return(m
, NULL
);
725 static int method_set_time(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
726 sd_bus
*bus
= sd_bus_message_get_bus(m
);
727 int relative
, interactive
, r
;
728 Context
*c
= userdata
;
737 r
= context_update_ntp_status(c
, bus
, m
);
739 return sd_bus_error_set_errnof(error
, r
, "Failed to update context: %m");
741 if (context_ntp_service_is_active(c
) > 0)
742 return sd_bus_error_set(error
, BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED
, "Automatic time synchronization is enabled");
744 /* this only gets used if dbus does not provide a timestamp */
745 start
= now(CLOCK_MONOTONIC
);
747 r
= sd_bus_message_read(m
, "xbb", &utc
, &relative
, &interactive
);
751 if (!relative
&& utc
<= 0)
752 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid absolute time");
754 if (relative
&& utc
== 0)
755 return sd_bus_reply_method_return(m
, NULL
);
760 n
= now(CLOCK_REALTIME
);
763 if ((utc
> 0 && x
< n
) ||
765 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Time value overflow");
767 timespec_store(&ts
, x
);
769 timespec_store(&ts
, (usec_t
) utc
);
771 r
= bus_verify_polkit_async(
774 "org.freedesktop.timedate1.set-time",
785 /* adjust ts for time spent in program */
786 r
= sd_bus_message_get_monotonic_usec(m
, &start
);
787 /* when sd_bus_message_get_monotonic_usec() returns -ENODATA it does not modify &start */
788 if (r
< 0 && r
!= -ENODATA
)
791 timespec_store(&ts
, timespec_load(&ts
) + (now(CLOCK_MONOTONIC
) - start
));
793 /* Set system clock */
794 if (clock_settime(CLOCK_REALTIME
, &ts
) < 0) {
795 log_error_errno(errno
, "Failed to set local time: %m");
796 return sd_bus_error_set_errnof(error
, errno
, "Failed to set local time: %m");
799 /* Sync down to RTC */
801 localtime_r(&ts
.tv_sec
, &tm
);
803 gmtime_r(&ts
.tv_sec
, &tm
);
805 r
= clock_set_hwclock(&tm
);
807 log_debug_errno(r
, "Failed to update hardware clock, ignoring: %m");
810 "MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR
,
811 "REALTIME="USEC_FMT
, timespec_load(&ts
),
812 LOG_MESSAGE("Changed local time to %s", ctime(&ts
.tv_sec
)));
814 return sd_bus_reply_method_return(m
, NULL
);
817 static int method_set_ntp(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
818 _cleanup_(sd_bus_slot_unrefp
) sd_bus_slot
*slot
= NULL
;
819 sd_bus
*bus
= sd_bus_message_get_bus(m
);
820 Context
*c
= userdata
;
822 int enable
, interactive
, q
, r
;
828 r
= sd_bus_message_read(m
, "bb", &enable
, &interactive
);
832 r
= context_update_ntp_status(c
, bus
, m
);
836 if (context_ntp_service_exists(c
) <= 0)
837 return sd_bus_error_set(error
, BUS_ERROR_NO_NTP_SUPPORT
, "NTP not supported");
839 r
= bus_verify_polkit_async(
842 "org.freedesktop.timedate1.set-ntp",
853 /* This method may be called frequently. Forget the previous job if it has not completed yet. */
854 LIST_FOREACH(units
, u
, c
->units
)
855 u
->path
= mfree(u
->path
);
857 if (!c
->slot_job_removed
) {
858 r
= sd_bus_match_signal_async(
861 "org.freedesktop.systemd1",
862 "/org/freedesktop/systemd1",
863 "org.freedesktop.systemd1.Manager",
865 match_job_removed
, NULL
, c
);
871 LIST_FOREACH(units
, u
, c
->units
) {
872 if (!streq(u
->load_state
, "loaded"))
875 q
= unit_enable_or_disable(u
, bus
, error
, enable
);
879 q
= unit_start_or_stop(u
, bus
, error
, enable
);
884 else if (context_ntp_service_is_enabled(c
) <= 0)
885 LIST_FOREACH(units
, u
, c
->units
) {
886 if (!streq(u
->load_state
, "loaded"))
889 r
= unit_enable_or_disable(u
, bus
, error
, enable
);
893 r
= unit_start_or_stop(u
, bus
, error
, enable
);
898 LIST_FOREACH(units
, u
, c
->units
) {
899 if (!streq(u
->load_state
, "loaded") ||
900 !streq(u
->unit_file_state
, "enabled"))
903 r
= unit_start_or_stop(u
, bus
, error
, enable
);
911 c
->slot_job_removed
= TAKE_PTR(slot
);
913 log_info("Set NTP to %sd", enable_disable(enable
));
915 return sd_bus_reply_method_return(m
, NULL
);
918 static const sd_bus_vtable timedate_vtable
[] = {
919 SD_BUS_VTABLE_START(0),
920 SD_BUS_PROPERTY("Timezone", "s", NULL
, offsetof(Context
, zone
), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
921 SD_BUS_PROPERTY("LocalRTC", "b", bus_property_get_bool
, offsetof(Context
, local_rtc
), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
922 SD_BUS_PROPERTY("CanNTP", "b", property_get_can_ntp
, 0, 0),
923 SD_BUS_PROPERTY("NTP", "b", property_get_ntp
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
924 SD_BUS_PROPERTY("NTPSynchronized", "b", property_get_ntp_sync
, 0, 0),
925 SD_BUS_PROPERTY("TimeUSec", "t", property_get_time
, 0, 0),
926 SD_BUS_PROPERTY("RTCTimeUSec", "t", property_get_rtc_time
, 0, 0),
927 SD_BUS_METHOD("SetTime", "xbb", NULL
, method_set_time
, SD_BUS_VTABLE_UNPRIVILEGED
),
928 SD_BUS_METHOD("SetTimezone", "sb", NULL
, method_set_timezone
, SD_BUS_VTABLE_UNPRIVILEGED
),
929 SD_BUS_METHOD("SetLocalRTC", "bbb", NULL
, method_set_local_rtc
, SD_BUS_VTABLE_UNPRIVILEGED
),
930 SD_BUS_METHOD("SetNTP", "bb", NULL
, method_set_ntp
, SD_BUS_VTABLE_UNPRIVILEGED
),
934 static int connect_bus(Context
*c
, sd_event
*event
, sd_bus
**_bus
) {
935 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
942 r
= sd_bus_default_system(&bus
);
944 return log_error_errno(r
, "Failed to get system bus connection: %m");
946 r
= sd_bus_add_object_vtable(bus
, NULL
, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", timedate_vtable
, c
);
948 return log_error_errno(r
, "Failed to register object: %m");
950 r
= sd_bus_request_name_async(bus
, NULL
, "org.freedesktop.timedate1", 0, NULL
, NULL
);
952 return log_error_errno(r
, "Failed to request name: %m");
954 r
= sd_bus_attach_event(bus
, event
, 0);
956 return log_error_errno(r
, "Failed to attach bus to event loop: %m");
958 *_bus
= TAKE_PTR(bus
);
963 static int run(int argc
, char *argv
[]) {
964 _cleanup_(context_clear
) Context context
= {};
965 _cleanup_(sd_event_unrefp
) sd_event
*event
= NULL
;
966 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
974 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
), "This program takes no arguments.");
976 assert_se(sigprocmask_many(SIG_BLOCK
, NULL
, SIGTERM
, SIGINT
, -1) >= 0);
978 r
= sd_event_default(&event
);
980 return log_error_errno(r
, "Failed to allocate event loop: %m");
982 (void) sd_event_set_watchdog(event
, true);
984 r
= sd_event_add_signal(event
, NULL
, SIGINT
, NULL
, NULL
);
986 return log_error_errno(r
, "Failed to install SIGINT handler: %m");
988 r
= sd_event_add_signal(event
, NULL
, SIGTERM
, NULL
, NULL
);
990 return log_error_errno(r
, "Failed to install SIGTERM handler: %m");
992 r
= connect_bus(&context
, event
, &bus
);
996 (void) sd_bus_negotiate_timestamp(bus
, true);
998 r
= context_read_data(&context
);
1000 return log_error_errno(r
, "Failed to read time zone data: %m");
1002 r
= context_parse_ntp_services(&context
);
1006 r
= bus_event_loop_with_idle(event
, bus
, "org.freedesktop.timedate1", DEFAULT_EXIT_USEC
, NULL
, NULL
);
1008 return log_error_errno(r
, "Failed to run event loop: %m");
1013 DEFINE_MAIN_FUNCTION(run
);