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
;
40 LIST_FIELDS(struct UnitStatusInfo
, units
);
43 typedef struct Context
{
46 Hashmap
*polkit_registry
;
47 sd_bus_message
*cache
;
49 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
);
71 static void context_free(Context
*c
) {
77 bus_verify_polkit_async_registry_free(c
->polkit_registry
);
78 sd_bus_message_unref(c
->cache
);
80 sd_bus_slot_unref(c
->slot_job_removed
);
81 free(c
->path_ntp_unit
);
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
) {
356 Context
*c
= userdata
;
362 r
= sd_bus_message_read(m
, "uoss", NULL
, &path
, NULL
, NULL
);
364 bus_log_parse_error(r
);
368 if (!streq_ptr(path
, c
->path_ntp_unit
))
371 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL
);
373 c
->slot_job_removed
= sd_bus_slot_unref(c
->slot_job_removed
);
374 c
->path_ntp_unit
= mfree(c
->path_ntp_unit
);
379 static int unit_start_or_stop(Context
*c
, UnitStatusInfo
*u
, sd_bus
*bus
, sd_bus_error
*error
, bool start
) {
380 _cleanup_(sd_bus_message_unrefp
) sd_bus_message
*reply
= NULL
;
381 _cleanup_(sd_bus_slot_unrefp
) sd_bus_slot
*slot
= NULL
;
390 /* This method may be called frequently. Forget the previous job if it has not completed yet. */
391 c
->slot_job_removed
= sd_bus_slot_unref(c
->slot_job_removed
);
393 r
= sd_bus_match_signal_async(
396 "org.freedesktop.systemd1",
397 "/org/freedesktop/systemd1",
398 "org.freedesktop.systemd1.Manager",
400 match_job_removed
, NULL
, c
);
404 r
= sd_bus_call_method(
406 "org.freedesktop.systemd1",
407 "/org/freedesktop/systemd1",
408 "org.freedesktop.systemd1.Manager",
409 start
? "StartUnit" : "StopUnit",
418 r
= sd_bus_message_read(reply
, "o", &path
);
420 return bus_log_parse_error(r
);
422 r
= free_and_strdup(&c
->path_ntp_unit
, path
);
426 c
->slot_job_removed
= TAKE_PTR(slot
);
430 static int unit_enable_or_disable(UnitStatusInfo
*u
, sd_bus
*bus
, sd_bus_error
*error
, bool enable
) {
437 /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
439 if (streq(u
->unit_file_state
, "enabled") == enable
)
443 r
= sd_bus_call_method(
445 "org.freedesktop.systemd1",
446 "/org/freedesktop/systemd1",
447 "org.freedesktop.systemd1.Manager",
455 r
= sd_bus_call_method(
457 "org.freedesktop.systemd1",
458 "/org/freedesktop/systemd1",
459 "org.freedesktop.systemd1.Manager",
469 r
= sd_bus_call_method(
471 "org.freedesktop.systemd1",
472 "/org/freedesktop/systemd1",
473 "org.freedesktop.systemd1.Manager",
484 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_time
, "t", now(CLOCK_REALTIME
));
485 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_ntp_sync
, "b", ntp_synced());
487 static int property_get_rtc_time(
490 const char *interface
,
491 const char *property
,
492 sd_bus_message
*reply
,
494 sd_bus_error
*error
) {
501 r
= clock_get_hwclock(&tm
);
503 log_warning("/dev/rtc is busy. Is somebody keeping it open continuously? That's not a good idea... Returning a bogus RTC timestamp.");
505 } else if (r
== -ENOENT
) {
506 log_debug("/dev/rtc not found.");
507 t
= 0; /* no RTC found */
509 return sd_bus_error_set_errnof(error
, r
, "Failed to read RTC: %m");
511 t
= (usec_t
) timegm(&tm
) * USEC_PER_SEC
;
513 return sd_bus_message_append(reply
, "t", t
);
516 static int property_get_can_ntp(
519 const char *interface
,
520 const char *property
,
521 sd_bus_message
*reply
,
523 sd_bus_error
*error
) {
525 Context
*c
= userdata
;
534 r
= context_update_ntp_status(c
, bus
, reply
);
538 return sd_bus_message_append(reply
, "b", context_ntp_service_exists(c
) > 0);
541 static int property_get_ntp(
544 const char *interface
,
545 const char *property
,
546 sd_bus_message
*reply
,
548 sd_bus_error
*error
) {
550 Context
*c
= userdata
;
559 r
= context_update_ntp_status(c
, bus
, reply
);
563 return sd_bus_message_append(reply
, "b", context_ntp_service_is_active(c
) > 0);
566 static int method_set_timezone(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
567 Context
*c
= userdata
;
574 r
= sd_bus_message_read(m
, "sb", &z
, &interactive
);
578 if (!timezone_is_valid(z
, LOG_DEBUG
))
579 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid time zone '%s'", z
);
581 if (streq_ptr(z
, c
->zone
))
582 return sd_bus_reply_method_return(m
, NULL
);
584 r
= bus_verify_polkit_async(
587 "org.freedesktop.timedate1.set-timezone",
596 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
598 r
= free_and_strdup(&c
->zone
, z
);
602 /* 1. Write new configuration file */
603 r
= context_write_data_timezone(c
);
605 log_error_errno(r
, "Failed to set time zone: %m");
606 return sd_bus_error_set_errnof(error
, r
, "Failed to set time zone: %m");
609 /* 2. Make glibc notice the new timezone */
612 /* 3. Tell the kernel our timezone */
613 r
= clock_set_timezone(NULL
);
615 log_debug_errno(r
, "Failed to tell kernel about timezone, ignoring: %m");
621 /* 4. Sync RTC from system clock, with the new delta */
622 assert_se(clock_gettime(CLOCK_REALTIME
, &ts
) == 0);
623 assert_se(localtime_r(&ts
.tv_sec
, &tm
));
625 r
= clock_set_hwclock(&tm
);
627 log_debug_errno(r
, "Failed to sync time to hardware clock, ignoring: %m");
631 "MESSAGE_ID=" SD_MESSAGE_TIMEZONE_CHANGE_STR
,
632 "TIMEZONE=%s", c
->zone
,
633 "TIMEZONE_SHORTNAME=%s", tzname
[daylight
],
634 "DAYLIGHT=%i", daylight
,
635 LOG_MESSAGE("Changed time zone to '%s' (%s).", c
->zone
, tzname
[daylight
]));
637 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL
);
639 return sd_bus_reply_method_return(m
, NULL
);
642 static int method_set_local_rtc(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
643 int lrtc
, fix_system
, interactive
;
644 Context
*c
= userdata
;
651 r
= sd_bus_message_read(m
, "bbb", &lrtc
, &fix_system
, &interactive
);
655 if (lrtc
== c
->local_rtc
)
656 return sd_bus_reply_method_return(m
, NULL
);
658 r
= bus_verify_polkit_async(
661 "org.freedesktop.timedate1.set-local-rtc",
674 /* 1. Write new configuration file */
675 r
= context_write_data_local_rtc(c
);
677 log_error_errno(r
, "Failed to set RTC to local/UTC: %m");
678 return sd_bus_error_set_errnof(error
, r
, "Failed to set RTC to local/UTC: %m");
681 /* 2. Tell the kernel our timezone */
682 r
= clock_set_timezone(NULL
);
684 log_debug_errno(r
, "Failed to tell kernel about timezone, ignoring: %m");
686 /* 3. Synchronize clocks */
687 assert_se(clock_gettime(CLOCK_REALTIME
, &ts
) == 0);
692 /* Sync system clock from RTC; first, initialize the timezone fields of struct tm. */
694 localtime_r(&ts
.tv_sec
, &tm
);
696 gmtime_r(&ts
.tv_sec
, &tm
);
698 /* Override the main fields of struct tm, but not the timezone fields */
699 r
= clock_get_hwclock(&tm
);
701 log_debug_errno(r
, "Failed to get hardware clock, ignoring: %m");
703 /* And set the system clock with this */
705 ts
.tv_sec
= mktime(&tm
);
707 ts
.tv_sec
= timegm(&tm
);
709 if (clock_settime(CLOCK_REALTIME
, &ts
) < 0)
710 log_debug_errno(errno
, "Failed to update system clock, ignoring: %m");
716 /* Sync RTC from system clock */
718 localtime_r(&ts
.tv_sec
, &tm
);
720 gmtime_r(&ts
.tv_sec
, &tm
);
722 r
= clock_set_hwclock(&tm
);
724 log_debug_errno(r
, "Failed to sync time to hardware clock, ignoring: %m");
727 log_info("RTC configured to %s time.", c
->local_rtc
? "local" : "UTC");
729 (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "LocalRTC", NULL
);
731 return sd_bus_reply_method_return(m
, NULL
);
734 static int method_set_time(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
735 sd_bus
*bus
= sd_bus_message_get_bus(m
);
736 int relative
, interactive
, r
;
737 Context
*c
= userdata
;
746 r
= context_update_ntp_status(c
, bus
, m
);
748 return sd_bus_error_set_errnof(error
, r
, "Failed to update context: %m");
750 if (context_ntp_service_is_active(c
) > 0)
751 return sd_bus_error_set(error
, BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED
, "Automatic time synchronization is enabled");
753 /* this only gets used if dbus does not provide a timestamp */
754 start
= now(CLOCK_MONOTONIC
);
756 r
= sd_bus_message_read(m
, "xbb", &utc
, &relative
, &interactive
);
760 if (!relative
&& utc
<= 0)
761 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid absolute time");
763 if (relative
&& utc
== 0)
764 return sd_bus_reply_method_return(m
, NULL
);
769 n
= now(CLOCK_REALTIME
);
772 if ((utc
> 0 && x
< n
) ||
774 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Time value overflow");
776 timespec_store(&ts
, x
);
778 timespec_store(&ts
, (usec_t
) utc
);
780 r
= bus_verify_polkit_async(
783 "org.freedesktop.timedate1.set-time",
794 /* adjust ts for time spent in program */
795 r
= sd_bus_message_get_monotonic_usec(m
, &start
);
796 /* when sd_bus_message_get_monotonic_usec() returns -ENODATA it does not modify &start */
797 if (r
< 0 && r
!= -ENODATA
)
800 timespec_store(&ts
, timespec_load(&ts
) + (now(CLOCK_MONOTONIC
) - start
));
802 /* Set system clock */
803 if (clock_settime(CLOCK_REALTIME
, &ts
) < 0) {
804 log_error_errno(errno
, "Failed to set local time: %m");
805 return sd_bus_error_set_errnof(error
, errno
, "Failed to set local time: %m");
808 /* Sync down to RTC */
810 localtime_r(&ts
.tv_sec
, &tm
);
812 gmtime_r(&ts
.tv_sec
, &tm
);
814 r
= clock_set_hwclock(&tm
);
816 log_debug_errno(r
, "Failed to update hardware clock, ignoring: %m");
819 "MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR
,
820 "REALTIME="USEC_FMT
, timespec_load(&ts
),
821 LOG_MESSAGE("Changed local time to %s", ctime(&ts
.tv_sec
)));
823 return sd_bus_reply_method_return(m
, NULL
);
826 static int method_set_ntp(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
827 sd_bus
*bus
= sd_bus_message_get_bus(m
);
828 Context
*c
= userdata
;
830 int enable
, interactive
, q
, r
;
836 r
= sd_bus_message_read(m
, "bb", &enable
, &interactive
);
840 r
= context_update_ntp_status(c
, bus
, m
);
844 if (context_ntp_service_exists(c
) <= 0)
845 return sd_bus_error_set(error
, BUS_ERROR_NO_NTP_SUPPORT
, "NTP not supported");
847 r
= bus_verify_polkit_async(
850 "org.freedesktop.timedate1.set-ntp",
862 LIST_FOREACH(units
, u
, c
->units
) {
863 if (!streq(u
->load_state
, "loaded"))
866 q
= unit_enable_or_disable(u
, bus
, error
, enable
);
870 q
= unit_start_or_stop(c
, u
, bus
, error
, enable
);
875 else if (context_ntp_service_is_enabled(c
) <= 0)
876 LIST_FOREACH(units
, u
, c
->units
) {
877 if (!streq(u
->load_state
, "loaded"))
880 r
= unit_enable_or_disable(u
, bus
, error
, enable
);
884 r
= unit_start_or_stop(c
, u
, bus
, error
, enable
);
889 LIST_FOREACH(units
, u
, c
->units
) {
890 if (!streq(u
->load_state
, "loaded") ||
891 !streq(u
->unit_file_state
, "enabled"))
894 r
= unit_start_or_stop(c
, u
, bus
, error
, enable
);
901 log_info("Set NTP to %sd", enable_disable(enable
));
903 return sd_bus_reply_method_return(m
, NULL
);
906 static const sd_bus_vtable timedate_vtable
[] = {
907 SD_BUS_VTABLE_START(0),
908 SD_BUS_PROPERTY("Timezone", "s", NULL
, offsetof(Context
, zone
), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
909 SD_BUS_PROPERTY("LocalRTC", "b", bus_property_get_bool
, offsetof(Context
, local_rtc
), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
910 SD_BUS_PROPERTY("CanNTP", "b", property_get_can_ntp
, 0, 0),
911 SD_BUS_PROPERTY("NTP", "b", property_get_ntp
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
912 SD_BUS_PROPERTY("NTPSynchronized", "b", property_get_ntp_sync
, 0, 0),
913 SD_BUS_PROPERTY("TimeUSec", "t", property_get_time
, 0, 0),
914 SD_BUS_PROPERTY("RTCTimeUSec", "t", property_get_rtc_time
, 0, 0),
915 SD_BUS_METHOD("SetTime", "xbb", NULL
, method_set_time
, SD_BUS_VTABLE_UNPRIVILEGED
),
916 SD_BUS_METHOD("SetTimezone", "sb", NULL
, method_set_timezone
, SD_BUS_VTABLE_UNPRIVILEGED
),
917 SD_BUS_METHOD("SetLocalRTC", "bbb", NULL
, method_set_local_rtc
, SD_BUS_VTABLE_UNPRIVILEGED
),
918 SD_BUS_METHOD("SetNTP", "bb", NULL
, method_set_ntp
, SD_BUS_VTABLE_UNPRIVILEGED
),
922 static int connect_bus(Context
*c
, sd_event
*event
, sd_bus
**_bus
) {
923 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
930 r
= sd_bus_default_system(&bus
);
932 return log_error_errno(r
, "Failed to get system bus connection: %m");
934 r
= sd_bus_add_object_vtable(bus
, NULL
, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", timedate_vtable
, c
);
936 return log_error_errno(r
, "Failed to register object: %m");
938 r
= sd_bus_request_name_async(bus
, NULL
, "org.freedesktop.timedate1", 0, NULL
, NULL
);
940 return log_error_errno(r
, "Failed to request name: %m");
942 r
= sd_bus_attach_event(bus
, event
, 0);
944 return log_error_errno(r
, "Failed to attach bus to event loop: %m");
946 *_bus
= TAKE_PTR(bus
);
951 int main(int argc
, char *argv
[]) {
952 Context context
= {};
953 _cleanup_(sd_event_unrefp
) sd_event
*event
= NULL
;
954 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
957 log_set_target(LOG_TARGET_AUTO
);
958 log_parse_environment();
964 log_error("This program takes no arguments.");
969 assert_se(sigprocmask_many(SIG_BLOCK
, NULL
, SIGTERM
, SIGINT
, -1) >= 0);
971 r
= sd_event_default(&event
);
973 log_error_errno(r
, "Failed to allocate event loop: %m");
977 (void) sd_event_set_watchdog(event
, true);
979 r
= sd_event_add_signal(event
, NULL
, SIGINT
, NULL
, NULL
);
983 r
= sd_event_add_signal(event
, NULL
, SIGTERM
, NULL
, NULL
);
987 r
= connect_bus(&context
, event
, &bus
);
991 (void) sd_bus_negotiate_timestamp(bus
, true);
993 r
= context_read_data(&context
);
995 log_error_errno(r
, "Failed to read time zone data: %m");
999 r
= context_parse_ntp_services(&context
);
1003 r
= bus_event_loop_with_idle(event
, bus
, "org.freedesktop.timedate1", DEFAULT_EXIT_USEC
, NULL
, NULL
);
1005 log_error_errno(r
, "Failed to run event loop: %m");
1010 context_free(&context
);
1012 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;