From: Lennart Poettering Date: Wed, 7 Feb 2018 21:47:26 +0000 (+0100) Subject: core: in bus_init_system() make sure we setup the system bus even if we inherit the... X-Git-Tag: v238~101^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=931e47547d97e2d72e748d8147f9adba6113473b;p=thirdparty%2Fsystemd.git core: in bus_init_system() make sure we setup the system bus even if we inherit the API bus 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) --- diff --git a/src/core/dbus.c b/src/core/dbus.c index 04bed73b653..305824da9b0 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -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)