Let root query screensaver status for user

Johannes Bauer dfnsonfsduifb at gmx.de
Fri Nov 9 07:04:14 PST 2012


Hi list,

I'm having trouble here: I have a script that runs as root and needs to
determine the screensaver status of the only user using the system. When
I do the dbus query as the user, it works nicely:

dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call
--print-reply /org/gnome/ScreenSaver org.gnome.ScreenSaver.GetActive

When I do it from within my script as root, the method call succeeds,
but always returns "false". Obviously, since the
DBUS_SESSION_BUS_ADDRESS environment variable isn't set as root. When I
set it as root to the value that it has for my user, it doesn't work
either, however:

Failed to open connection to "session" message bus: Did not receive a
reply. Possible causes include: the remote application did not send a
reply, the message bus security policy blocked the reply, the reply
timeout expired, or the network connection was broken.

How can I enable root to query that information? I tried to add a file
called /etc/dbus-1/session.d/allow_root_screensaver.conf in which I wrote

[...]
  <policy user="root">
    <allow send_destination="org.gnome.ScreenSaver"/>
    <allow send_destination="org.gnome.ScreenSaver"
           send_interface="org.gnome.ScreenSaver.GetActive"/>
  </policy>
[...]

But this didn't change anything (yes, I restarted dbus). How can I do this?

Best regards,
Joe


More information about the dbus mailing list