manager: when reexecuting try to connect to bus only when dbus.service is around...
authorMichal Sekletar <msekletar@users.noreply.github.com>
Fri, 8 Sep 2017 13:41:44 +0000 (15:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 8 Sep 2017 13:41:44 +0000 (15:41 +0200)
Trying to connect otherwise is pointless, because if socket isn't around
we won't connect. However, when dbus.socket is present we attempt to
connect. That attempt can't succeed because we are then supposed
to activate dbus.service as a response to connection from
us. This results in deadlock.

Fixes #6303

src/core/manager.c

index 939d117..b4c252a 100644 (file)
@@ -921,15 +921,19 @@ static int manager_setup_user_lookup_fd(Manager *m) {
 
 static int manager_connect_bus(Manager *m, bool reexecuting) {
         bool try_bus_connect;
+        Unit *u = NULL;
 
         assert(m);
 
         if (m->test_run)
                 return 0;
 
+        u = manager_get_unit(m, SPECIAL_DBUS_SERVICE);
+
         try_bus_connect =
-                reexecuting ||
-                (MANAGER_IS_USER(m) && getenv("DBUS_SESSION_BUS_ADDRESS"));
+                (u && UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u))) &&
+                (reexecuting ||
+                 (MANAGER_IS_USER(m) && getenv("DBUS_SESSION_BUS_ADDRESS")));
 
         /* Try to connect to the buses, if possible. */
         return bus_init(m, try_bus_connect);