]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: in bus_init_system() make sure we setup the system bus even if we inherit the...
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Feb 2018 21:47:26 +0000 (22:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 12 Feb 2018 10:34:00 +0000 (11:34 +0100)
This corrects the control flow: when we reuse the API bus as system bus,
let's definitely invoke bus_init_system() too, so that it is called
regardless how we acquired the bus object.

(Note that this doesn't actually change anything, as we only inherit the
bus like this in system mode, and bus_init_system() doesn't do anything
in system bus, besides writing a log message)

src/core/dbus.c

index 04bed73b65322f201ebf61f8e45c81bebe5d4a19..305824da9b073722b7bb1f7a49d7ac471edb62a3 100644 (file)
@@ -958,22 +958,21 @@ int bus_init_system(Manager *m) {
                 return 0;
 
         /* The API and system bus is the same if we are running in system mode */
-        if (MANAGER_IS_SYSTEM(m) && m->api_bus) {
-                m->system_bus = sd_bus_ref(m->api_bus);
-                return 0;
-        }
-
-        r = sd_bus_open_system(&bus);
-        if (r < 0)
-                return log_error_errno(r, "Failed to connect to system bus: %m");
+        if (MANAGER_IS_SYSTEM(m) && m->api_bus)
+                bus = sd_bus_ref(m->api_bus);
+        else {
+                r = sd_bus_open_system(&bus);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to connect to system bus: %m");
 
-        r = bus_setup_disconnected_match(m, bus);
-        if (r < 0)
-                return r;
+                r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to attach system bus to event loop: %m");
 
-        r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
-        if (r < 0)
-                return log_error_errno(r, "Failed to attach system bus to event loop: %m");
+                r = bus_setup_disconnected_match(m, bus);
+                if (r < 0)
+                        return r;
+        }
 
         r = bus_setup_system(m, bus);
         if (r < 0)