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"
21 #include "path-util.h"
22 #include "selinux-util.h"
23 #include "signal-util.h"
24 #include "string-util.h"
27 #include "unit-name.h"
28 #include "user-util.h"
31 #define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
32 #define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
34 typedef struct UnitStatusInfo
{
37 char *unit_file_state
;
41 LIST_FIELDS(struct UnitStatusInfo
, units
);
44 typedef struct Context
{
47 Hashmap
*polkit_registry
;
48 sd_bus_message
*cache
;
50 sd_bus_slot
*slot_job_removed
;
52 LIST_HEAD(UnitStatusInfo
, units
);
55 static void unit_status_info_clear(UnitStatusInfo
*p
) {
58 p
->load_state
= mfree(p
->load_state
);
59 p
->unit_file_state
= mfree(p
->unit_file_state
);
60 p
->active_state
= mfree(p
->active_state
);
63 static void unit_status_info_free(UnitStatusInfo
*p
) {
66 unit_status_info_clear(p
);
72 static void context_free(Context
*c
) {
78 bus_verify_polkit_async_registry_free(c
->polkit_registry
);
79 sd_bus_message_unref(c
->cache
);
81 sd_bus_slot_unref(c
->slot_job_removed
);
83 while ((p
= c
->units
)) {
84 LIST_REMOVE(units
, c
->units
, p
);
85 unit_status_info_free(p
);
89 static int context_add_ntp_service(Context
*c
, const char *s
) {
92 if (!unit_name_is_valid(s
, UNIT_NAME_PLAIN
))
95 /* Do not add this if it is already listed */
96 LIST_FOREACH(units
, u
, c
->units
)
97 if (streq(u
->name
, s
))
100 u
= new0(UnitStatusInfo
, 1);
110 LIST_APPEND(units
, c
->units
, u
);
115 static int context_parse_ntp_services(Context
*c
) {
121 env
= getenv("SYSTEMD_TIMEDATED_NTP_SERVICES");
123 r
= context_add_ntp_service(c
, "systemd-timesyncd.service");
125 log_warning_errno(r
, "Failed to add NTP service \"systemd-timesyncd.service\", ignoring: %m");
131 _cleanup_free_
char *word
= NULL
;
133 r
= extract_first_word(&p
, &word
, ":", 0);
139 log_error("Invalid syntax, ignoring: %s", env
);
143 r
= context_add_ntp_service(c
, word
);
145 log_warning_errno(r
, "Failed to add NTP service \"%s\", ignoring: %m", word
);
151 static int context_ntp_service_is_active(Context
*c
) {
152 UnitStatusInfo
*info
;
157 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
159 LIST_FOREACH(units
, info
, c
->units
)
160 count
+= streq_ptr(info
->active_state
, "active");
165 static int context_ntp_service_is_enabled(Context
*c
) {
166 UnitStatusInfo
*info
;
171 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
173 LIST_FOREACH(units
, info
, c
->units
)
174 count
+= STRPTR_IN_SET(info
->unit_file_state
, "enabled", "enabled-runtime");
179 static int context_ntp_service_exists(Context
*c
) {
180 UnitStatusInfo
*info
;
185 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
187 LIST_FOREACH(units
, info
, c
->units
)
188 count
+= streq_ptr(info
->load_state
, "loaded");
193 static int context_read_data(Context
*c
) {
194 _cleanup_free_
char *t
= NULL
;
199 r
= get_timezone(&t
);
201 log_warning_errno(r
, "/etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.");
203 log_warning_errno(r
, "Failed to get target of /etc/localtime: %m");
205 free_and_replace(c
->zone
, t
);
207 c
->local_rtc
= clock_is_localtime(NULL
) > 0;
212 static int context_write_data_timezone(Context
*c
) {
213 _cleanup_free_
char *p
= NULL
;
218 if (isempty(c
->zone
)) {
219 if (unlink("/etc/localtime") < 0 && errno
!= ENOENT
)
225 p
= strappend("../usr/share/zoneinfo/", c
->zone
);
229 r
= symlink_atomic(p
, "/etc/localtime");
236 static int context_write_data_local_rtc(Context
*c
) {
238 _cleanup_free_
char *s
= NULL
, *w
= NULL
;
242 r
= read_full_file("/etc/adjtime", &s
, NULL
);
250 w
= strdup(NULL_ADJTIME_LOCAL
);
255 const char *e
= "\n"; /* default if there is less than 3 lines */
256 const char *prepend
= "";
259 p
= strchrnul(s
, '\n');
261 /* only one line, no \n terminator */
263 else if (p
[1] == '\0') {
264 /* only one line, with \n terminator */
268 p
= strchr(p
+1, '\n');
270 /* only two lines, no \n terminator */
275 /* third line might have a \n terminator or not */
277 end
= strchr(p
, '\n');
278 /* if we actually have a fourth line, use that as suffix "e", otherwise the default \n */
287 w
= new(char, a
+ (c
->local_rtc
? 5 : 3) + strlen(prepend
) + b
+ 1);
291 *(char*) mempcpy(stpcpy(stpcpy(mempcpy(w
, s
, a
), prepend
), c
->local_rtc
? "LOCAL" : "UTC"), e
, b
) = 0;
293 if (streq(w
, NULL_ADJTIME_UTC
)) {
294 if (unlink("/etc/adjtime") < 0)
303 return write_string_file_atomic_label("/etc/adjtime", w
);
306 static int context_update_ntp_status(Context
*c
, sd_bus
*bus
, sd_bus_message
*m
) {
307 static const struct bus_properties_map map
[] = {
308 { "LoadState", "s", NULL
, offsetof(UnitStatusInfo
, load_state
) },
309 { "ActiveState", "s", NULL
, offsetof(UnitStatusInfo
, active_state
) },
310 { "UnitFileState", "s", NULL
, offsetof(UnitStatusInfo
, unit_file_state
) },
319 /* Suppress calling context_update_ntp_status() multiple times within single DBus transaction. */
324 sd_bus_message_unref(c
->cache
);
325 c
->cache
= sd_bus_message_ref(m
);
328 LIST_FOREACH(units
, u
, c
->units
) {
329 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
330 _cleanup_free_
char *path
= NULL
;
332 unit_status_info_clear(u
);
334 path
= unit_dbus_path_from_name(u
->name
);
338 r
= bus_map_all_properties(
340 "org.freedesktop.systemd1",
348 return log_error_errno(r
, "Failed to get properties: %s", bus_error_message(&error
, r
));
354 static int match_job_removed(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
355 Context
*c
= userdata
;
364 r
= sd_bus_message_read(m
, "uoss", NULL
, &path
, NULL
, NULL
);
366 bus_log_parse_error(r
);
370 LIST_FOREACH(units
, u
, c
->units
)
371 if (streq_ptr(path
, u
->path
))
372 u
->path
= mfree(u
->path
);
377 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL
);
379 c
->slot_job_removed
= sd_bus_slot_unref(c
->slot_job_removed
);
385 static int unit_start_or_stop(UnitStatusInfo
*u
, sd_bus
*bus
, sd_bus_error
*error
, bool start
) {
386 _cleanup_(sd_bus_message_unrefp
) sd_bus_message
*reply
= NULL
;
394 r
= sd_bus_call_method(
396 "org.freedesktop.systemd1",
397 "/org/freedesktop/systemd1",
398 "org.freedesktop.systemd1.Manager",
399 start
? "StartUnit" : "StopUnit",
408 r
= sd_bus_message_read(reply
, "o", &path
);
410 return bus_log_parse_error(r
);
412 r
= free_and_strdup(&u
->path
, path
);
419 static int unit_enable_or_disable(UnitStatusInfo
*u
, sd_bus
*bus
, sd_bus_error
*error
, bool enable
) {
426 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
428 if (streq(u
->unit_file_state
, "enabled") == enable
)
432 r
= sd_bus_call_method(
434 "org.freedesktop.systemd1",
435 "/org/freedesktop/systemd1",
436 "org.freedesktop.systemd1.Manager",
444 r
= sd_bus_call_method(
446 "org.freedesktop.systemd1",
447 "/org/freedesktop/systemd1",
448 "org.freedesktop.systemd1.Manager",
458 r
= sd_bus_call_method(
460 "org.freedesktop.systemd1",
461 "/org/freedesktop/systemd1",
462 "org.freedesktop.systemd1.Manager",
473 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_time
, "t", now(CLOCK_REALTIME
));
474 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_ntp_sync
, "b", ntp_synced());
476 static int property_get_rtc_time(
479 const char *interface
,
480 const char *property
,
481 sd_bus_message
*reply
,
483 sd_bus_error
*error
) {
490 r
= clock_get_hwclock(&tm
);
492 log_warning("/dev/rtc is busy. Is somebody keeping it open continuously? That's not a good idea... Returning a bogus RTC timestamp.");
494 } else if (r
== -ENOENT
) {
495 log_debug("/dev/rtc not found.");
496 t
= 0; /* no RTC found */
498 return sd_bus_error_set_errnof(error
, r
, "Failed to read RTC: %m");
500 t
= (usec_t
) timegm(&tm
) * USEC_PER_SEC
;
502 return sd_bus_message_append(reply
, "t", t
);
505 static int property_get_can_ntp(
508 const char *interface
,
509 const char *property
,
510 sd_bus_message
*reply
,
512 sd_bus_error
*error
) {
514 Context
*c
= userdata
;
523 r
= context_update_ntp_status(c
, bus
, reply
);
527 return sd_bus_message_append(reply
, "b", context_ntp_service_exists(c
) > 0);
530 static int property_get_ntp(
533 const char *interface
,
534 const char *property
,
535 sd_bus_message
*reply
,
537 sd_bus_error
*error
) {
539 Context
*c
= userdata
;
548 r
= context_update_ntp_status(c
, bus
, reply
);
552 return sd_bus_message_append(reply
, "b", context_ntp_service_is_active(c
) > 0);
555 static int method_set_timezone(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
556 Context
*c
= userdata
;
563 r
= sd_bus_message_read(m
, "sb", &z
, &interactive
);
567 if (!timezone_is_valid(z
, LOG_DEBUG
))
568 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid time zone '%s'", z
);
570 if (streq_ptr(z
, c
->zone
))
571 return sd_bus_reply_method_return(m
, NULL
);
573 r
= bus_verify_polkit_async(
576 "org.freedesktop.timedate1.set-timezone",
585 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
587 r
= free_and_strdup(&c
->zone
, z
);
591 /* 1. Write new configuration file */
592 r
= context_write_data_timezone(c
);
594 log_error_errno(r
, "Failed to set time zone: %m");
595 return sd_bus_error_set_errnof(error
, r
, "Failed to set time zone: %m");
598 /* 2. Make glibc notice the new timezone */
601 /* 3. Tell the kernel our timezone */
602 r
= clock_set_timezone(NULL
);
604 log_debug_errno(r
, "Failed to tell kernel about timezone, ignoring: %m");
610 /* 4. Sync RTC from system clock, with the new delta */
611 assert_se(clock_gettime(CLOCK_REALTIME
, &ts
) == 0);
612 assert_se(localtime_r(&ts
.tv_sec
, &tm
));
614 r
= clock_set_hwclock(&tm
);
616 log_debug_errno(r
, "Failed to sync time to hardware clock, ignoring: %m");
620 "MESSAGE_ID=" SD_MESSAGE_TIMEZONE_CHANGE_STR
,
621 "TIMEZONE=%s", c
->zone
,
622 "TIMEZONE_SHORTNAME=%s", tzname
[daylight
],
623 "DAYLIGHT=%i", daylight
,
624 LOG_MESSAGE("Changed time zone to '%s' (%s).", c
->zone
, tzname
[daylight
]));
626 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL
);
628 return sd_bus_reply_method_return(m
, NULL
);
631 static int method_set_local_rtc(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
632 int lrtc
, fix_system
, interactive
;
633 Context
*c
= userdata
;
640 r
= sd_bus_message_read(m
, "bbb", &lrtc
, &fix_system
, &interactive
);
644 if (lrtc
== c
->local_rtc
)
645 return sd_bus_reply_method_return(m
, NULL
);
647 r
= bus_verify_polkit_async(
650 "org.freedesktop.timedate1.set-local-rtc",
663 /* 1. Write new configuration file */
664 r
= context_write_data_local_rtc(c
);
666 log_error_errno(r
, "Failed to set RTC to local/UTC: %m");
667 return sd_bus_error_set_errnof(error
, r
, "Failed to set RTC to local/UTC: %m");
670 /* 2. Tell the kernel our timezone */
671 r
= clock_set_timezone(NULL
);
673 log_debug_errno(r
, "Failed to tell kernel about timezone, ignoring: %m");
675 /* 3. Synchronize clocks */
676 assert_se(clock_gettime(CLOCK_REALTIME
, &ts
) == 0);
681 /* Sync system clock from RTC; first, initialize the timezone fields of struct tm. */
683 localtime_r(&ts
.tv_sec
, &tm
);
685 gmtime_r(&ts
.tv_sec
, &tm
);
687 /* Override the main fields of struct tm, but not the timezone fields */
688 r
= clock_get_hwclock(&tm
);
690 log_debug_errno(r
, "Failed to get hardware clock, ignoring: %m");
692 /* And set the system clock with this */
694 ts
.tv_sec
= mktime(&tm
);
696 ts
.tv_sec
= timegm(&tm
);
698 if (clock_settime(CLOCK_REALTIME
, &ts
) < 0)
699 log_debug_errno(errno
, "Failed to update system clock, ignoring: %m");
705 /* Sync RTC from system clock */
707 localtime_r(&ts
.tv_sec
, &tm
);
709 gmtime_r(&ts
.tv_sec
, &tm
);
711 r
= clock_set_hwclock(&tm
);
713 log_debug_errno(r
, "Failed to sync time to hardware clock, ignoring: %m");
716 log_info("RTC configured to %s time.", c
->local_rtc
? "local" : "UTC");
718 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "LocalRTC", NULL
);
720 return sd_bus_reply_method_return(m
, NULL
);
723 static int method_set_time(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
724 sd_bus
*bus
= sd_bus_message_get_bus(m
);
725 int relative
, interactive
, r
;
726 Context
*c
= userdata
;
735 r
= context_update_ntp_status(c
, bus
, m
);
737 return sd_bus_error_set_errnof(error
, r
, "Failed to update context: %m");
739 if (context_ntp_service_is_active(c
) > 0)
740 return sd_bus_error_set(error
, BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED
, "Automatic time synchronization is enabled");
742 /* this only gets used if dbus does not provide a timestamp */
743 start
= now(CLOCK_MONOTONIC
);
745 r
= sd_bus_message_read(m
, "xbb", &utc
, &relative
, &interactive
);
749 if (!relative
&& utc
<= 0)
750 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid absolute time");
752 if (relative
&& utc
== 0)
753 return sd_bus_reply_method_return(m
, NULL
);
758 n
= now(CLOCK_REALTIME
);
761 if ((utc
> 0 && x
< n
) ||
763 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Time value overflow");
765 timespec_store(&ts
, x
);
767 timespec_store(&ts
, (usec_t
) utc
);
769 r
= bus_verify_polkit_async(
772 "org.freedesktop.timedate1.set-time",
783 /* adjust ts for time spent in program */
784 r
= sd_bus_message_get_monotonic_usec(m
, &start
);
785 /* when sd_bus_message_get_monotonic_usec() returns -ENODATA it does not modify &start */
786 if (r
< 0 && r
!= -ENODATA
)
789 timespec_store(&ts
, timespec_load(&ts
) + (now(CLOCK_MONOTONIC
) - start
));
791 /* Set system clock */
792 if (clock_settime(CLOCK_REALTIME
, &ts
) < 0) {
793 log_error_errno(errno
, "Failed to set local time: %m");
794 return sd_bus_error_set_errnof(error
, errno
, "Failed to set local time: %m");
797 /* Sync down to RTC */
799 localtime_r(&ts
.tv_sec
, &tm
);
801 gmtime_r(&ts
.tv_sec
, &tm
);
803 r
= clock_set_hwclock(&tm
);
805 log_debug_errno(r
, "Failed to update hardware clock, ignoring: %m");
808 "MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR
,
809 "REALTIME="USEC_FMT
, timespec_load(&ts
),
810 LOG_MESSAGE("Changed local time to %s", ctime(&ts
.tv_sec
)));
812 return sd_bus_reply_method_return(m
, NULL
);
815 static int method_set_ntp(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
816 _cleanup_(sd_bus_slot_unrefp
) sd_bus_slot
*slot
= NULL
;
817 sd_bus
*bus
= sd_bus_message_get_bus(m
);
818 Context
*c
= userdata
;
820 int enable
, interactive
, q
, r
;
826 r
= sd_bus_message_read(m
, "bb", &enable
, &interactive
);
830 r
= context_update_ntp_status(c
, bus
, m
);
834 if (context_ntp_service_exists(c
) <= 0)
835 return sd_bus_error_set(error
, BUS_ERROR_NO_NTP_SUPPORT
, "NTP not supported");
837 r
= bus_verify_polkit_async(
840 "org.freedesktop.timedate1.set-ntp",
851 /* This method may be called frequently. Forget the previous job if it has not completed yet. */
852 LIST_FOREACH(units
, u
, c
->units
)
853 u
->path
= mfree(u
->path
);
855 if (!c
->slot_job_removed
) {
856 r
= sd_bus_match_signal_async(
859 "org.freedesktop.systemd1",
860 "/org/freedesktop/systemd1",
861 "org.freedesktop.systemd1.Manager",
863 match_job_removed
, NULL
, c
);
869 LIST_FOREACH(units
, u
, c
->units
) {
870 if (!streq(u
->load_state
, "loaded"))
873 q
= unit_enable_or_disable(u
, bus
, error
, enable
);
877 q
= unit_start_or_stop(u
, bus
, error
, enable
);
882 else if (context_ntp_service_is_enabled(c
) <= 0)
883 LIST_FOREACH(units
, u
, c
->units
) {
884 if (!streq(u
->load_state
, "loaded"))
887 r
= unit_enable_or_disable(u
, bus
, error
, enable
);
891 r
= unit_start_or_stop(u
, bus
, error
, enable
);
896 LIST_FOREACH(units
, u
, c
->units
) {
897 if (!streq(u
->load_state
, "loaded") ||
898 !streq(u
->unit_file_state
, "enabled"))
901 r
= unit_start_or_stop(u
, bus
, error
, enable
);
909 c
->slot_job_removed
= TAKE_PTR(slot
);
911 log_info("Set NTP to %sd", enable_disable(enable
));
913 return sd_bus_reply_method_return(m
, NULL
);
916 static const sd_bus_vtable timedate_vtable
[] = {
917 SD_BUS_VTABLE_START(0),
918 SD_BUS_PROPERTY("Timezone", "s", NULL
, offsetof(Context
, zone
), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
919 SD_BUS_PROPERTY("LocalRTC", "b", bus_property_get_bool
, offsetof(Context
, local_rtc
), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
920 SD_BUS_PROPERTY("CanNTP", "b", property_get_can_ntp
, 0, 0),
921 SD_BUS_PROPERTY("NTP", "b", property_get_ntp
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
922 SD_BUS_PROPERTY("NTPSynchronized", "b", property_get_ntp_sync
, 0, 0),
923 SD_BUS_PROPERTY("TimeUSec", "t", property_get_time
, 0, 0),
924 SD_BUS_PROPERTY("RTCTimeUSec", "t", property_get_rtc_time
, 0, 0),
925 SD_BUS_METHOD("SetTime", "xbb", NULL
, method_set_time
, SD_BUS_VTABLE_UNPRIVILEGED
),
926 SD_BUS_METHOD("SetTimezone", "sb", NULL
, method_set_timezone
, SD_BUS_VTABLE_UNPRIVILEGED
),
927 SD_BUS_METHOD("SetLocalRTC", "bbb", NULL
, method_set_local_rtc
, SD_BUS_VTABLE_UNPRIVILEGED
),
928 SD_BUS_METHOD("SetNTP", "bb", NULL
, method_set_ntp
, SD_BUS_VTABLE_UNPRIVILEGED
),
932 static int connect_bus(Context
*c
, sd_event
*event
, sd_bus
**_bus
) {
933 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
940 r
= sd_bus_default_system(&bus
);
942 return log_error_errno(r
, "Failed to get system bus connection: %m");
944 r
= sd_bus_add_object_vtable(bus
, NULL
, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", timedate_vtable
, c
);
946 return log_error_errno(r
, "Failed to register object: %m");
948 r
= sd_bus_request_name_async(bus
, NULL
, "org.freedesktop.timedate1", 0, NULL
, NULL
);
950 return log_error_errno(r
, "Failed to request name: %m");
952 r
= sd_bus_attach_event(bus
, event
, 0);
954 return log_error_errno(r
, "Failed to attach bus to event loop: %m");
956 *_bus
= TAKE_PTR(bus
);
961 int main(int argc
, char *argv
[]) {
962 Context context
= {};
963 _cleanup_(sd_event_unrefp
) sd_event
*event
= NULL
;
964 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
972 log_error("This program takes no arguments.");
977 assert_se(sigprocmask_many(SIG_BLOCK
, NULL
, SIGTERM
, SIGINT
, -1) >= 0);
979 r
= sd_event_default(&event
);
981 log_error_errno(r
, "Failed to allocate event loop: %m");
985 (void) sd_event_set_watchdog(event
, true);
987 r
= sd_event_add_signal(event
, NULL
, SIGINT
, NULL
, NULL
);
989 log_error_errno(r
, "Failed to install SIGINT handler: %m");
993 r
= sd_event_add_signal(event
, NULL
, SIGTERM
, NULL
, NULL
);
995 log_error_errno(r
, "Failed to install SIGTERM handler: %m");
999 r
= connect_bus(&context
, event
, &bus
);
1003 (void) sd_bus_negotiate_timestamp(bus
, true);
1005 r
= context_read_data(&context
);
1007 log_error_errno(r
, "Failed to read time zone data: %m");
1011 r
= context_parse_ntp_services(&context
);
1015 r
= bus_event_loop_with_idle(event
, bus
, "org.freedesktop.timedate1", DEFAULT_EXIT_USEC
, NULL
, NULL
);
1017 log_error_errno(r
, "Failed to run event loop: %m");
1022 context_free(&context
);
1024 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;