1 /* SPDX-License-Identifier: LGPL-2.1+ */
11 #include "bus-error.h"
13 #include "in-addr-util.h"
14 #include "main-func.h"
16 #include "parse-util.h"
17 #include "pretty-print.h"
18 #include "spawn-polkit-agent.h"
19 #include "sparse-endian.h"
20 #include "string-table.h"
22 #include "terminal-util.h"
26 static PagerFlags arg_pager_flags
= 0;
27 static bool arg_ask_password
= true;
28 static BusTransport arg_transport
= BUS_TRANSPORT_LOCAL
;
29 static char *arg_host
= NULL
;
30 static bool arg_adjust_system_clock
= false;
31 static bool arg_monitor
= false;
32 static char **arg_property
= NULL
;
33 static bool arg_value
= false;
34 static bool arg_all
= false;
36 typedef struct StatusInfo
{
48 static void print_status_info(const StatusInfo
*i
) {
49 const char *old_tz
= NULL
, *tz
;
50 bool have_time
= false;
59 /* Save the old $TZ */
65 if (setenv("TZ", isempty(i
->timezone
) ? "UTC" : i
->timezone
, true) < 0)
66 log_warning_errno(errno
, "Failed to set TZ environment variable, ignoring: %m");
71 sec
= (time_t) (i
->time
/ USEC_PER_SEC
);
73 } else if (IN_SET(arg_transport
, BUS_TRANSPORT_LOCAL
, BUS_TRANSPORT_MACHINE
)) {
77 log_warning("Could not get time from timedated and not operating locally, ignoring.");
80 n
= strftime(a
, sizeof a
, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec
, &tm
));
81 printf(" Local time: %s\n", n
> 0 ? a
: "n/a");
83 n
= strftime(a
, sizeof a
, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec
, &tm
));
84 printf(" Universal time: %s\n", n
> 0 ? a
: "n/a");
86 printf(" Local time: %s\n", "n/a");
87 printf(" Universal time: %s\n", "n/a");
90 if (i
->rtc_time
> 0) {
93 rtc_sec
= (time_t) (i
->rtc_time
/ USEC_PER_SEC
);
94 n
= strftime(a
, sizeof a
, "%a %Y-%m-%d %H:%M:%S", gmtime_r(&rtc_sec
, &tm
));
95 printf(" RTC time: %s\n", n
> 0 ? a
: "n/a");
97 printf(" RTC time: %s\n", "n/a");
100 n
= strftime(a
, sizeof a
, "%Z, %z", localtime_r(&sec
, &tm
));
102 /* Restore the $TZ */
104 r
= setenv("TZ", old_tz
, true);
108 log_warning_errno(errno
, "Failed to set TZ environment variable, ignoring: %m");
112 printf(" Time zone: %s (%s)\n"
113 "System clock synchronized: %s\n"
115 " RTC in local TZ: %s\n",
116 strna(i
->timezone
), have_time
&& n
> 0 ? a
: "n/a",
117 yes_no(i
->ntp_synced
),
118 i
->ntp_capable
? (i
->ntp_active
? "active" : "inactive") : "n/a",
119 yes_no(i
->rtc_local
));
123 "Warning: The system is configured to read the RTC time in the local time zone.\n"
124 " This mode cannot be fully supported. It will create various problems\n"
125 " with time zone changes and daylight saving time adjustments. The RTC\n"
126 " time is never updated, it relies on external facilities to maintain it.\n"
127 " If at all possible, use RTC in UTC by calling\n"
128 " 'timedatectl set-local-rtc 0'.%s\n", ansi_highlight(), ansi_normal());
131 static int show_status(int argc
, char **argv
, void *userdata
) {
132 StatusInfo info
= {};
133 static const struct bus_properties_map map
[] = {
134 { "Timezone", "s", NULL
, offsetof(StatusInfo
, timezone
) },
135 { "LocalRTC", "b", NULL
, offsetof(StatusInfo
, rtc_local
) },
136 { "NTP", "b", NULL
, offsetof(StatusInfo
, ntp_active
) },
137 { "CanNTP", "b", NULL
, offsetof(StatusInfo
, ntp_capable
) },
138 { "NTPSynchronized", "b", NULL
, offsetof(StatusInfo
, ntp_synced
) },
139 { "TimeUSec", "t", NULL
, offsetof(StatusInfo
, time
) },
140 { "RTCTimeUSec", "t", NULL
, offsetof(StatusInfo
, rtc_time
) },
144 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
145 _cleanup_(sd_bus_message_unrefp
) sd_bus_message
*m
= NULL
;
146 sd_bus
*bus
= userdata
;
151 r
= bus_map_all_properties(bus
,
152 "org.freedesktop.timedate1",
153 "/org/freedesktop/timedate1",
155 BUS_MAP_BOOLEAN_AS_BOOL
,
160 return log_error_errno(r
, "Failed to query server: %s", bus_error_message(&error
, r
));
162 print_status_info(&info
);
167 static int show_properties(int argc
, char **argv
, void *userdata
) {
168 sd_bus
*bus
= userdata
;
173 r
= bus_print_all_properties(bus
,
174 "org.freedesktop.timedate1",
175 "/org/freedesktop/timedate1",
182 return bus_log_parse_error(r
);
187 static int set_time(int argc
, char **argv
, void *userdata
) {
188 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
189 bool relative
= false, interactive
= arg_ask_password
;
190 sd_bus
*bus
= userdata
;
194 polkit_agent_open_if_enabled(arg_transport
, arg_ask_password
);
196 r
= parse_timestamp(argv
[1], &t
);
198 return log_error_errno(r
, "Failed to parse time specification '%s': %m", argv
[1]);
200 r
= sd_bus_call_method(bus
,
201 "org.freedesktop.timedate1",
202 "/org/freedesktop/timedate1",
203 "org.freedesktop.timedate1",
207 "xbb", (int64_t) t
, relative
, interactive
);
209 return log_error_errno(r
, "Failed to set time: %s", bus_error_message(&error
, r
));
214 static int set_timezone(int argc
, char **argv
, void *userdata
) {
215 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
216 sd_bus
*bus
= userdata
;
219 polkit_agent_open_if_enabled(arg_transport
, arg_ask_password
);
221 r
= sd_bus_call_method(bus
,
222 "org.freedesktop.timedate1",
223 "/org/freedesktop/timedate1",
224 "org.freedesktop.timedate1",
228 "sb", argv
[1], arg_ask_password
);
230 return log_error_errno(r
, "Failed to set time zone: %s", bus_error_message(&error
, r
));
235 static int set_local_rtc(int argc
, char **argv
, void *userdata
) {
236 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
237 sd_bus
*bus
= userdata
;
240 polkit_agent_open_if_enabled(arg_transport
, arg_ask_password
);
242 b
= parse_boolean(argv
[1]);
244 return log_error_errno(b
, "Failed to parse local RTC setting '%s': %m", argv
[1]);
246 r
= sd_bus_call_method(bus
,
247 "org.freedesktop.timedate1",
248 "/org/freedesktop/timedate1",
249 "org.freedesktop.timedate1",
253 "bbb", b
, arg_adjust_system_clock
, arg_ask_password
);
255 return log_error_errno(r
, "Failed to set local RTC: %s", bus_error_message(&error
, r
));
260 static int set_ntp(int argc
, char **argv
, void *userdata
) {
261 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
262 sd_bus
*bus
= userdata
;
265 polkit_agent_open_if_enabled(arg_transport
, arg_ask_password
);
267 b
= parse_boolean(argv
[1]);
269 return log_error_errno(b
, "Failed to parse NTP setting '%s': %m", argv
[1]);
271 r
= sd_bus_call_method(bus
,
272 "org.freedesktop.timedate1",
273 "/org/freedesktop/timedate1",
274 "org.freedesktop.timedate1",
278 "bb", b
, arg_ask_password
);
280 return log_error_errno(r
, "Failed to set ntp: %s", bus_error_message(&error
, r
));
285 static int list_timezones(int argc
, char **argv
, void *userdata
) {
286 _cleanup_strv_free_
char **zones
= NULL
;
289 r
= get_timezones(&zones
);
291 return log_error_errno(r
, "Failed to read list of time zones: %m");
293 (void) pager_open(arg_pager_flags
);
299 typedef struct NTPStatusInfo
{
300 const char *server_name
;
301 char *server_address
;
302 usec_t poll_interval
, poll_max
, poll_min
;
303 usec_t root_distance_max
;
305 uint32_t leap
, version
, mode
, stratum
;
307 usec_t root_delay
, root_dispersion
;
312 usec_t origin
, recv
, trans
, dest
;
315 uint64_t packet_count
;
321 static void ntp_status_info_clear(NTPStatusInfo
*p
) {
322 p
->server_address
= mfree(p
->server_address
);
325 static const char * const ntp_leap_table
[4] = {
327 [1] = "last minute of the day has 61 seconds",
328 [2] = "last minute of the day has 59 seconds",
329 [3] = "not synchronized",
332 #pragma GCC diagnostic push
333 #pragma GCC diagnostic ignored "-Wtype-limits"
334 DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(ntp_leap
, uint32_t);
335 #pragma GCC diagnostic pop
337 static void print_ntp_status_info(NTPStatusInfo
*i
) {
338 char ts
[FORMAT_TIMESPAN_MAX
], tmin
[FORMAT_TIMESPAN_MAX
], tmax
[FORMAT_TIMESPAN_MAX
];
339 usec_t delay
, t14
, t23
, offset
, root_distance
;
345 * "Timestamp Name ID When Generated
346 * ------------------------------------------------------------
347 * Originate Timestamp T1 time request sent by client
348 * Receive Timestamp T2 time request received by server
349 * Transmit Timestamp T3 time reply sent by server
350 * Destination Timestamp T4 time reply received by client
352 * The round-trip delay, d, and system clock offset, t, are defined as:
353 * d = (T4 - T1) - (T3 - T2) t = ((T2 - T1) + (T3 - T4)) / 2"
356 printf(" Server: %s (%s)\n",
357 i
->server_address
, i
->server_name
);
358 printf("Poll interval: %s (min: %s; max %s)\n",
359 format_timespan(ts
, sizeof(ts
), i
->poll_interval
, 0),
360 format_timespan(tmin
, sizeof(tmin
), i
->poll_min
, 0),
361 format_timespan(tmax
, sizeof(tmax
), i
->poll_max
, 0));
363 if (i
->packet_count
== 0) {
364 printf(" Packet count: 0\n");
368 if (i
->dest
< i
->origin
|| i
->trans
< i
->recv
|| i
->dest
- i
->origin
< i
->trans
- i
->recv
) {
369 log_error("Invalid NTP response");
373 delay
= (i
->dest
- i
->origin
) - (i
->trans
- i
->recv
);
375 t14
= i
->origin
+ i
->dest
;
376 t23
= i
->recv
+ i
->trans
;
377 offset_sign
= t14
< t23
;
378 offset
= (offset_sign
? t23
- t14
: t14
- t23
) / 2;
380 root_distance
= i
->root_delay
/ 2 + i
->root_dispersion
;
383 " Version: %" PRIu32
"\n"
384 " Stratum: %" PRIu32
"\n",
385 ntp_leap_to_string(i
->leap
),
389 printf(" Reference: %s\n", i
->reference
.str
);
391 printf(" Reference: %" PRIX32
"\n", be32toh(i
->reference
.val
));
392 printf(" Precision: %s (%" PRIi32
")\n",
393 format_timespan(ts
, sizeof(ts
), DIV_ROUND_UP((nsec_t
) (exp2(i
->precision
) * NSEC_PER_SEC
), NSEC_PER_USEC
), 0),
395 printf("Root distance: %s (max: %s)\n",
396 format_timespan(ts
, sizeof(ts
), root_distance
, 0),
397 format_timespan(tmax
, sizeof(tmax
), i
->root_distance_max
, 0));
398 printf(" Offset: %s%s\n",
399 offset_sign
? "+" : "-",
400 format_timespan(ts
, sizeof(ts
), offset
, 0));
401 printf(" Delay: %s\n",
402 format_timespan(ts
, sizeof(ts
), delay
, 0));
403 printf(" Jitter: %s\n",
404 format_timespan(ts
, sizeof(ts
), i
->jitter
, 0));
405 printf(" Packet count: %" PRIu64
"\n", i
->packet_count
);
408 printf(" Frequency: %+.3fppm\n",
409 (double) i
->freq
/ 0x10000);
412 static int map_server_address(sd_bus
*bus
, const char *member
, sd_bus_message
*m
, sd_bus_error
*error
, void *userdata
) {
413 char **p
= (char **) userdata
;
420 r
= sd_bus_message_enter_container(m
, 'r', "iay");
424 r
= sd_bus_message_read(m
, "i", &family
);
428 r
= sd_bus_message_read_array(m
, 'y', &d
, &sz
);
432 r
= sd_bus_message_exit_container(m
);
436 if (sz
== 0 && family
== AF_UNSPEC
) {
441 if (!IN_SET(family
, AF_INET
, AF_INET6
)) {
442 log_error("Unknown address family %i", family
);
446 if (sz
!= FAMILY_ADDRESS_SIZE(family
)) {
447 log_error("Invalid address size");
451 r
= in_addr_to_string(family
, d
, p
);
458 static int map_ntp_message(sd_bus
*bus
, const char *member
, sd_bus_message
*m
, sd_bus_error
*error
, void *userdata
) {
459 NTPStatusInfo
*p
= userdata
;
467 r
= sd_bus_message_enter_container(m
, 'r', "uuuuittayttttbtt");
471 r
= sd_bus_message_read(m
, "uuuuitt",
472 &p
->leap
, &p
->version
, &p
->mode
, &p
->stratum
, &p
->precision
,
473 &p
->root_delay
, &p
->root_dispersion
);
477 r
= sd_bus_message_read_array(m
, 'y', &d
, &sz
);
481 r
= sd_bus_message_read(m
, "ttttbtt",
482 &p
->origin
, &p
->recv
, &p
->trans
, &p
->dest
,
483 &b
, &p
->packet_count
, &p
->jitter
);
487 r
= sd_bus_message_exit_container(m
);
494 memcpy(p
->reference
.str
, d
, sz
);
501 static int show_timesync_status_once(sd_bus
*bus
) {
502 static const struct bus_properties_map map_timesync
[] = {
503 { "ServerName", "s", NULL
, offsetof(NTPStatusInfo
, server_name
) },
504 { "ServerAddress", "(iay)", map_server_address
, offsetof(NTPStatusInfo
, server_address
) },
505 { "PollIntervalUSec", "t", NULL
, offsetof(NTPStatusInfo
, poll_interval
) },
506 { "PollIntervalMinUSec", "t", NULL
, offsetof(NTPStatusInfo
, poll_min
) },
507 { "PollIntervalMaxUSec", "t", NULL
, offsetof(NTPStatusInfo
, poll_max
) },
508 { "RootDistanceMaxUSec", "t", NULL
, offsetof(NTPStatusInfo
, root_distance_max
) },
509 { "NTPMessage", "(uuuuittayttttbtt)", map_ntp_message
, 0 },
510 { "Frequency", "x", NULL
, offsetof(NTPStatusInfo
, freq
) },
513 _cleanup_(ntp_status_info_clear
) NTPStatusInfo info
= {};
514 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
515 _cleanup_(sd_bus_message_unrefp
) sd_bus_message
*m
= NULL
;
520 r
= bus_map_all_properties(bus
,
521 "org.freedesktop.timesync1",
522 "/org/freedesktop/timesync1",
524 BUS_MAP_BOOLEAN_AS_BOOL
,
529 return log_error_errno(r
, "Failed to query server: %s", bus_error_message(&error
, r
));
531 if (arg_monitor
&& !terminal_is_dumb())
532 fputs(ANSI_HOME_CLEAR
, stdout
);
534 print_ntp_status_info(&info
);
539 static int on_properties_changed(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
545 r
= sd_bus_message_read(m
, "s", &name
);
547 return log_error_errno(r
, "Failed to read interface name: %m");
549 if (!streq_ptr(name
, "org.freedesktop.timesync1.Manager"))
552 return show_timesync_status_once(sd_bus_message_get_bus(m
));
555 static int show_timesync_status(int argc
, char **argv
, void *userdata
) {
556 _cleanup_(sd_event_unrefp
) sd_event
*event
= NULL
;
557 sd_bus
*bus
= userdata
;
562 r
= show_timesync_status_once(bus
);
569 r
= sd_event_default(&event
);
571 return log_error_errno(r
, "Failed to get event loop: %m");
573 r
= sd_bus_match_signal(bus
,
575 "org.freedesktop.timesync1",
576 "/org/freedesktop/timesync1",
577 "org.freedesktop.DBus.Properties",
579 on_properties_changed
, NULL
);
581 return log_error_errno(r
, "Failed to request match for PropertiesChanged signal: %m");
583 r
= sd_bus_attach_event(bus
, event
, SD_EVENT_PRIORITY_NORMAL
);
585 return log_error_errno(r
, "Failed to attach bus to event loop: %m");
587 r
= sd_event_loop(event
);
589 return log_error_errno(r
, "Failed to run event loop: %m");
594 static int print_timesync_property(const char *name
, const char *expected_value
, sd_bus_message
*m
, bool value
, bool all
) {
596 const char *contents
;
602 r
= sd_bus_message_peek_type(m
, &type
, &contents
);
608 case SD_BUS_TYPE_STRUCT
:
609 if (streq(name
, "NTPMessage")) {
610 _cleanup_(ntp_status_info_clear
) NTPStatusInfo i
= {};
611 char ts
[FORMAT_TIMESPAN_MAX
], stamp
[FORMAT_TIMESTAMP_MAX
];
613 r
= map_ntp_message(NULL
, NULL
, m
, NULL
, &i
);
617 if (i
.packet_count
== 0)
625 printf("{ Leap=%u, Version=%u, Mode=%u, Stratum=%u, Precision=%i,",
626 i
.leap
, i
.version
, i
.mode
, i
.stratum
, i
.precision
);
627 printf(" RootDelay=%s,",
628 format_timespan(ts
, sizeof(ts
), i
.root_delay
, 0));
629 printf(" RootDispersion=%s,",
630 format_timespan(ts
, sizeof(ts
), i
.root_dispersion
, 0));
633 printf(" Reference=%s,", i
.reference
.str
);
635 printf(" Reference=%" PRIX32
",", be32toh(i
.reference
.val
));
637 printf(" OriginateTimestamp=%s,",
638 format_timestamp(stamp
, sizeof(stamp
), i
.origin
));
639 printf(" ReceiveTimestamp=%s,",
640 format_timestamp(stamp
, sizeof(stamp
), i
.recv
));
641 printf(" TransmitTimestamp=%s,",
642 format_timestamp(stamp
, sizeof(stamp
), i
.trans
));
643 printf(" DestinationTimestamp=%s,",
644 format_timestamp(stamp
, sizeof(stamp
), i
.dest
));
645 printf(" Ignored=%s PacketCount=%" PRIu64
",",
646 yes_no(i
.spike
), i
.packet_count
);
647 printf(" Jitter=%s }\n",
648 format_timespan(ts
, sizeof(ts
), i
.jitter
, 0));
652 } else if (streq(name
, "ServerAddress")) {
653 _cleanup_free_
char *str
= NULL
;
655 r
= map_server_address(NULL
, NULL
, m
, NULL
, &str
);
659 if (arg_all
|| !isempty(str
))
660 bus_print_property_value(name
, expected_value
, value
, "%s", str
);
670 static int show_timesync(int argc
, char **argv
, void *userdata
) {
671 sd_bus
*bus
= userdata
;
676 r
= bus_print_all_properties(bus
,
677 "org.freedesktop.timesync1",
678 "/org/freedesktop/timesync1",
679 print_timesync_property
,
685 return bus_log_parse_error(r
);
690 static int help(void) {
691 _cleanup_free_
char *link
= NULL
;
694 r
= terminal_urlify_man("timedatectl", "1", &link
);
698 printf("%s [OPTIONS...] COMMAND ...\n\n"
699 "Query or change system time and date settings.\n\n"
700 " -h --help Show this help message\n"
701 " --version Show package version\n"
702 " --no-pager Do not pipe output into a pager\n"
703 " --no-ask-password Do not prompt for password\n"
704 " -H --host=[USER@]HOST Operate on remote host\n"
705 " -M --machine=CONTAINER Operate on local container\n"
706 " --adjust-system-clock Adjust system clock when changing local RTC mode\n"
707 " --monitor Monitor status of systemd-timesyncd\n"
708 " -p --property=NAME Show only properties by this name\n"
709 " -a --all Show all properties, including empty ones\n"
710 " --value When showing properties, only print the value\n"
713 " status Show current time settings\n"
714 " show Show properties of systemd-timedated\n"
715 " set-time TIME Set system time\n"
716 " set-timezone ZONE Set system time zone\n"
717 " list-timezones Show known time zones\n"
718 " set-local-rtc BOOL Control whether RTC is in local time\n"
719 " set-ntp BOOL Enable or disable network time synchronization\n"
721 "systemd-timesyncd Commands:\n"
722 " timesync-status Show status of systemd-timesyncd\n"
723 " show-timesync Show properties of systemd-timesyncd\n"
724 "\nSee the %s for details.\n"
725 , program_invocation_short_name
732 static int verb_help(int argc
, char **argv
, void *userdata
) {
736 static int parse_argv(int argc
, char *argv
[]) {
741 ARG_ADJUST_SYSTEM_CLOCK
,
747 static const struct option options
[] = {
748 { "help", no_argument
, NULL
, 'h' },
749 { "version", no_argument
, NULL
, ARG_VERSION
},
750 { "no-pager", no_argument
, NULL
, ARG_NO_PAGER
},
751 { "host", required_argument
, NULL
, 'H' },
752 { "machine", required_argument
, NULL
, 'M' },
753 { "no-ask-password", no_argument
, NULL
, ARG_NO_ASK_PASSWORD
},
754 { "adjust-system-clock", no_argument
, NULL
, ARG_ADJUST_SYSTEM_CLOCK
},
755 { "monitor", no_argument
, NULL
, ARG_MONITOR
},
756 { "property", required_argument
, NULL
, 'p' },
757 { "all", no_argument
, NULL
, 'a' },
758 { "value", no_argument
, NULL
, ARG_VALUE
},
767 while ((c
= getopt_long(argc
, argv
, "hH:M:p:a", options
, NULL
)) >= 0)
778 arg_transport
= BUS_TRANSPORT_REMOTE
;
783 arg_transport
= BUS_TRANSPORT_MACHINE
;
787 case ARG_NO_ASK_PASSWORD
:
788 arg_ask_password
= false;
791 case ARG_ADJUST_SYSTEM_CLOCK
:
792 arg_adjust_system_clock
= true;
796 arg_pager_flags
|= PAGER_DISABLE
;
804 r
= strv_extend(&arg_property
, optarg
);
808 /* If the user asked for a particular
809 * property, show it to him, even if it is
827 assert_not_reached("Unhandled option");
833 static int timedatectl_main(sd_bus
*bus
, int argc
, char *argv
[]) {
834 static const Verb verbs
[] = {
835 { "status", VERB_ANY
, 1, VERB_DEFAULT
, show_status
},
836 { "show", VERB_ANY
, 1, 0, show_properties
},
837 { "set-time", 2, 2, 0, set_time
},
838 { "set-timezone", 2, 2, 0, set_timezone
},
839 { "list-timezones", VERB_ANY
, 1, 0, list_timezones
},
840 { "set-local-rtc", 2, 2, 0, set_local_rtc
},
841 { "set-ntp", 2, 2, 0, set_ntp
},
842 { "timesync-status", VERB_ANY
, 1, 0, show_timesync_status
},
843 { "show-timesync", VERB_ANY
, 1, 0, show_timesync
},
844 { "help", VERB_ANY
, VERB_ANY
, 0, verb_help
}, /* Not documented, but supported since it is created. */
848 return dispatch_verb(argc
, argv
, verbs
, bus
);
851 static int run(int argc
, char *argv
[]) {
852 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
855 setlocale(LC_ALL
, "");
856 log_parse_environment();
859 r
= parse_argv(argc
, argv
);
863 r
= bus_connect_transport(arg_transport
, arg_host
, false, &bus
);
865 return log_error_errno(r
, "Failed to create bus connection: %m");
867 return timedatectl_main(bus
, argc
, argv
);
870 DEFINE_MAIN_FUNCTION(run
);