]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamectl: show transient hostname before static hostname
authorLennart Poettering <lennart@poettering.net>
Fri, 7 Mar 2025 14:11:58 +0000 (15:11 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 7 Mar 2025 17:12:36 +0000 (17:12 +0000)
The transient one is generally the more relevant one, since it is
typically used to reach this host remotely, and it's what shells show
you. Hence show it first.

src/hostname/hostnamectl.c

index adf3a3296ffb4b8797d9eaef5a5d25458e891dfa..bf03f177d37104874ed2f498de463dba73423c9a 100644 (file)
@@ -121,6 +121,15 @@ static int print_status_info(StatusInfo *i) {
 
         table_set_ersatz_string(table, TABLE_ERSATZ_UNSET);
 
+        if (!isempty(i->hostname) &&
+            !streq_ptr(i->hostname, i->static_hostname)) {
+                r = table_add_many(table,
+                                   TABLE_FIELD, "Transient hostname",
+                                   TABLE_STRING, i->hostname);
+                if (r < 0)
+                        return table_log_add_error(r);
+        }
+
         r = table_add_many(table,
                            TABLE_FIELD, "Static hostname",
                            TABLE_STRING, i->static_hostname);
@@ -136,15 +145,6 @@ static int print_status_info(StatusInfo *i) {
                         return table_log_add_error(r);
         }
 
-        if (!isempty(i->hostname) &&
-            !streq_ptr(i->hostname, i->static_hostname)) {
-                r = table_add_many(table,
-                                   TABLE_FIELD, "Transient hostname",
-                                   TABLE_STRING, i->hostname);
-                if (r < 0)
-                        return table_log_add_error(r);
-        }
-
         if (!isempty(i->icon_name)) {
                 r = table_add_many(table,
                                    TABLE_FIELD, "Icon name",