chiark / gitweb /
networkd: don't hard depend on system bus
[elogind.git] / src / network / networkd-link.c
index 7f692d1f9b9323ef9697e7215540d7d321df139b..f1a2695e83f4dccab666900b5acc517738f96f6f 100644 (file)
@@ -325,11 +325,15 @@ static int set_hostname(sd_bus *bus, const char *hostname) {
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         int r = 0;
 
-        assert(bus);
         assert(hostname);
 
         log_debug("Setting transient hostname: '%s'", hostname);
 
+        if (!bus) { /* TODO: replace by assert when we can rely on kdbus */
+                log_info("Not connected to system bus, ignoring transient hostname.");
+                return 0;
+        }
+
         r = sd_bus_message_new_method_call(
                         bus,
                         "org.freedesktop.hostname1",