chiark / gitweb /
networkd: link - only reset transient hostname if it was set by us
authorTom Gundersen <teg@jklm.no>
Wed, 19 Feb 2014 14:59:31 +0000 (15:59 +0100)
committerTom Gundersen <teg@jklm.no>
Wed, 19 Feb 2014 15:46:58 +0000 (16:46 +0100)
src/network/networkd-link.c

index 66bcb6b..aa23bfb 100644 (file)
@@ -507,9 +507,14 @@ static int dhcp_lease_lost(Link *link) {
         }
 
         if (link->network->dhcp_hostname) {
-                r = set_hostname(link->manager->bus, "");
-                if (r < 0)
-                        log_error("Failed to reset transient hostname");
+                const char *hostname = NULL;
+
+                r = sd_dhcp_lease_get_hostname(link->dhcp_lease, &hostname);
+                if (r >= 0 && hostname) {
+                        r = set_hostname(link->manager->bus, "");
+                        if (r < 0)
+                                log_error("Failed to reset transient hostname");
+                }
         }
 
         link->dhcp_lease = sd_dhcp_lease_unref(link->dhcp_lease);