SHA256
1
0
forked from pool/systemd
systemd/0185-core-only-attempt-to-connect-to-a-session-bus-if-one.patch

35 lines
1.2 KiB
Diff
Raw Normal View History

From ed002560a1945fb8765c5559c293a19bc9e132d8 Mon Sep 17 00:00:00 2001
From: Auke Kok <auke-jan.h.kok@intel.com>
Date: Thu, 20 Jun 2013 13:36:33 -0700
Subject: [PATCH 185/197] core: only attempt to connect to a session bus if one
likely exists.
---
src/core/manager.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/core/manager.c b/src/core/manager.c
index 5c3a2c7..2416dd0 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -509,9 +509,13 @@ int manager_new(SystemdRunningAs running_as, Manager **_m) {
goto fail;
/* Try to connect to the busses, if possible. */
- r = bus_init(m, running_as != SYSTEMD_SYSTEM);
- if (r < 0)
- goto fail;
+ if ((running_as == SYSTEMD_USER && getenv("DBUS_SESSION_BUS_ADDRESS")) ||
+ running_as == SYSTEMD_SYSTEM) {
+ r = bus_init(m, running_as != SYSTEMD_SYSTEM);
+ if (r < 0)
+ goto fail;
+ } else
+ log_debug("Skipping DBus session bus connection attempt - no DBUS_SESSION_BUS_ADDRESS set...");
m->taint_usr = dir_is_empty("/usr") > 0;
--
1.8.3.1