hostnamectl: properly initialize the two timestamp fields before doing bus call
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Mar 2024 12:02:57 +0000 (13:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 4 Mar 2024 12:05:31 +0000 (13:05 +0100)
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

index a70c9572910bf2b6e8052f8b57c2d2944c773acb..5e1cbd373d6de730d4897df311042a53fab7ba0e 100644 (file)
@@ -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[]  = {