anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0502-manager-when-reexecuting-try-to-connect-to-bus-only-.patch

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