How to interact with existing dbus session through sudo?
Thiago Macieira
thiago at kde.org
Tue Mar 18 15:48:07 PDT 2014
Em ter 18 mar 2014, às 17:32:25, Louise Baldwin escreveu:
> I really do appreciate your reply, but please note that, through additional
> trial and error, I have determined that it is in fact possible to interact
> with an existing dbus session through sudo ...
>
> I was previously attempting to do this by exporting the
> DBUS_SESSION_BUS_ADDRESS value stored in the file located within
> /home/Louise/.dbus/session-bus/
>
> This didn't work, and I have just now figured out why ... the
> DBUS_SESSION_BUS_ADDRESS value stored in this file does not match the one
> reported by /usr/bin/env for user Louise.
You're describing using sudo to change to a given user and access THAT user's
session bus. I was answering what happens if you use sudo and try to access
the original user's session bus. That's the part that is not allowed by the
bus daemon.
In any case, as you've seen, acquiring the socket address is not a trivial
task. That's because you have to answer "which user" and "which session of
that user" before you can connect. Only programs started inside a given
session should have access to that session's bus. Programs outside the session
should not have access (by design, but technically possible).
> So my new question is: why doesn't the value for DBUS_SESSION_BUS_ADDRESS in
> /home/Louise/.dbus/session-bus/ match the value reported for Louise by env?
It should. It does here:
$ echo $DBUS_SESSION_BUS_ADDRESS
unix:abstract=/tmp/dbus-hFsTnS7Y8i,guid=d783fb0894a158ec60671a8153279a74
$ dbus-launch --autolaunch=`dbus-uuidgen --get`
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-
hFsTnS7Y8i,guid=d783fb0894a158ec60671a8153279a74
DBUS_SESSION_BUS_PID=1304
DBUS_SESSION_BUS_WINDOWID=8388609
$ cat ~/.dbus/session-bus/`dbus-uuidgen --get`-0
# This file allows processes on the machine with id
64bdb0d35d814699b433e438527a615a using
# display :0 to find the D-Bus session bus with the below address.
# If the DBUS_SESSION_BUS_ADDRESS environment variable is set, it will
# be used rather than this file.
# See "man dbus-launch" for more details.
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-
hFsTnS7Y8i,guid=d783fb0894a158ec60671a8153279a74
DBUS_SESSION_BUS_PID=1304
DBUS_SESSION_BUS_WINDOWID=8388609
There's something wrong with the way that your session bus was started. I've
seen some incorrect configurations in Linux distributions that start two busses
by accident and no one realises the mistake.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
More information about the dbus
mailing list