From 67648678b0dafd09db09c12918e52a5fb745180f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 4 Mar 2024 13:02:57 +0100 Subject: [PATCH] hostnamectl: properly initialize the two timestamp fields before doing bus call Otherwise if talking to an old hostnamed (which doesn't have these fields) we'd assume the timestamp is valid even though it isn't and show garbage. --- src/hostname/hostnamectl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index a70c957291..5e1cbd373d 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -236,7 +236,7 @@ static int print_status_info(StatusInfo *i) { return table_log_add_error(r); } - if (i->os_support_end != USEC_INFINITY) { + if (timestamp_is_set(i->os_support_end)) { usec_t n = now(CLOCK_REALTIME); r = table_add_many(table, @@ -362,6 +362,8 @@ static int get_one_name(sd_bus *bus, const char* attr, char **ret) { static int show_all_names(sd_bus *bus) { StatusInfo info = { .vsock_cid = VMADDR_CID_ANY, + .os_support_end = USEC_INFINITY, + .firmware_date = USEC_INFINITY, }; static const struct bus_properties_map hostname_map[] = { -- 2.25.1