daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
dd65c9
From 8410dde8d9593c1d96593b17d610d7daf955dab3 Mon Sep 17 00:00:00 2001
48aa7f
From: Michal Sekletar <msekletar@users.noreply.github.com>
48aa7f
Date: Fri, 8 Sep 2017 15:41:44 +0200
48aa7f
Subject: [PATCH] manager: when reexecuting try to connect to bus only when
48aa7f
 dbus.service is around (#6773)
48aa7f
48aa7f
Trying to connect otherwise is pointless, because if socket isn't around
48aa7f
we won't connect. However, when dbus.socket is present we attempt to
48aa7f
connect. That attempt can't succeed because we are then supposed
48aa7f
to activate dbus.service as a response to connection from
48aa7f
us. This results in deadlock.
48aa7f
48aa7f
Fixes #6303
48aa7f
48aa7f
(cherry picked from commit 5463fa0a88f95d2002858592578f9bf4e0d2660a)
48aa7f
48aa7f
Resolves: #1465737
48aa7f
---
48aa7f
 src/core/manager.c | 9 ++++++---
48aa7f
 1 file changed, 6 insertions(+), 3 deletions(-)
48aa7f
48aa7f
diff --git a/src/core/manager.c b/src/core/manager.c
c62b8e
index 287cf6a741..041fac46be 100644
48aa7f
--- a/src/core/manager.c
48aa7f
+++ b/src/core/manager.c
48aa7f
@@ -799,16 +799,19 @@ static int manager_setup_kdbus(Manager *m) {
48aa7f
 
48aa7f
 static int manager_connect_bus(Manager *m, bool reexecuting) {
48aa7f
         bool try_bus_connect;
48aa7f
+        Unit *u = NULL;
48aa7f
 
48aa7f
         assert(m);
48aa7f
 
48aa7f
         if (m->test_run)
48aa7f
                 return 0;
48aa7f
 
48aa7f
+        u = manager_get_unit(m, SPECIAL_DBUS_SERVICE);
48aa7f
+
48aa7f
         try_bus_connect =
48aa7f
-                m->kdbus_fd >= 0 ||
48aa7f
-                reexecuting ||
48aa7f
-                (m->running_as == SYSTEMD_USER && getenv("DBUS_SESSION_BUS_ADDRESS"));
48aa7f
+                (u && UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u))) &&
48aa7f
+                (reexecuting ||
48aa7f
+                (m->running_as == SYSTEMD_USER && getenv("DBUS_SESSION_BUS_ADDRESS")));
48aa7f
 
48aa7f
         /* Try to connect to the busses, if possible. */
48aa7f
         return bus_init(m, try_bus_connect);