core: only attempt to connect to a session bus if one likely exists.

This commit is contained in:
Auke Kok 2013-06-20 13:36:33 -07:00 committed by Lennart Poettering
parent 3d3ee759e6
commit ed002560a1
1 changed files with 7 additions and 3 deletions

View File

@ -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;