Skip to content
Snippets Groups Projects
Commit e562c672 authored by Sjoerd Simons's avatar Sjoerd Simons
Browse files

common: Only use an existing session bus


As soon as there is a dbus user session a session bus should be
available. Only verify that this exists (failling if it doesn't) rather
then trying to workaround things by autolaunching a new bus.

Reviewed-by: default avatarLuis Araujo <luis.araujo@collabora.co.uk>
Signed-off-by: default avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D3663
parent a9b8749f
No related branches found
Tags apertis/1%0.20160928.0
No related merge requests found
......@@ -155,41 +155,16 @@ arch_is_arm() {
[[ $(uname -m) =~ arm.* ]]
}
# Try hard to find an existing dbus session bus that can be used by the current
# user, and if none exists, autolaunch one.
# Also, set XDG_RUNTIME_DIR
# Check if a session bus is running otherwise fail
ensure_dbus_session() {
local dbus_socket dbus_vars
if [[ -z $DBUS_SESSION_BUS_ADDRESS ]]; then
whine "DBUS_SESSION_BUS_ADDRESS is unset!"
# Check if we have a systemd-managed dbus session bus. Here, a user can
# only access its own session bus, so we can only check this path.
dbus_socket="/run/user/$UID/bus"
if [[ -e ${dbus_socket} ]]; then
export DBUS_SESSION_BUS_ADDRESS="unix:path=${dbus_socket}"
say "Set DBUS_SESSION_BUS_ADDRESS='$DBUS_SESSION_BUS_ADDRESS', continuing"
else
# Maybe we're in SDK, and using a traditional dbus-launch session
# bus which can be detected using DISPLAY
if [[ -z $DISPLAY ]]; then
whine "No X DISPLAY found to get dbus user session! Trying :0"
export DISPLAY=":0"
fi
# Use dbus-launch to find an existing session on DISPLAY, and
# if it doesn't exist, autolaunch one connected to DISPLAY.
dbus_vars=($(dbus-launch --autolaunch $(<"/etc/machine-id")))
if echo "${dbus_vars[0]}" | grep -q "DBUS_SESSION_BUS_ADDRESS"; then
export "${dbus_vars[0]}"
say "Set DBUS_SESSION_BUS_ADDRESS='$DBUS_SESSION_BUS_ADDRESS', continuing"
else
cry "Unable to ensure a dbus session! Aborting ..."
return 1
fi
fi
local dbus_socket
dbus_socket="/run/user/$UID/bus"
if [[ ! -e {dbus_socket} ]]; then
cry "Could not find session bus..."
return 1
fi
# This doesn't get set properly by su/PAM on a serial console
export XDG_RUNTIME_DIR="/run/user/$UID"
return 0
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment