[systemd-devel] [PATCH] Only attempt to connect to a session bus if one likely exists.

Auke Kok auke-jan.h.kok at intel.com
Thu Jun 20 13:36:33 PDT 2013


Cc: chengwei.yang at intel.com
Cc: lennart at poettering.net
---
 src/core/manager.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/core/manager.c b/src/core/manager.c
index f16621a..592f332 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -509,9 +509,14 @@ 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.7.11.2



More information about the systemd-devel mailing list