Seeing the session bus as another user

Stuart Langridge sil at kryogenix.org
Tue Mar 6 18:44:25 PST 2007


I'd like PHP scripts on my machine, running as www-data, to be able to
display notifications on my desktop (since someone mentioned that they
do a similar trick with Growl on OS X:
http://www.aquarionics.com/article/name/Debugging_Ajax and it sounded
useful).

I've allowed www-data to send messages to my session bus by writing
this into /etc/dbus-1/session-local.conf:

<busconfig>
  <policy context="default">
    <!-- Allow www-data to send notifications to the notification daemon -->
    <allow user="www-data" />
  </policy>
</busconfig>

I'd like to lock that down further to say that www-data can send
messages specifically to the org.freedesktop.Notifications interface
only, so I tried this:

<busconfig>
  <policy context="default">
    <!-- Allow www-data to send notifications to the notification daemon -->
    <allow user="www-data" receive_interface="org.freedesktop.Notifications" />
  </policy>
</busconfig>

However, this throws an error on launching the D-Bus daemon, "Failed
to start message bus: Invalid combination of attributes on element
<allow>".

That aside, however, (I'd like to fix it, but the problem below is a
more serious one) I can now send messages to services on my session
bus as www-data: for example, I can pop up a notification with
something like:

www-data $ DBUS_SESSION_BUS_ADDRESS='unix:blahblah'
DBUS_SESSION_BUS_PID=21393 notify-send test

That works fine, but I need to know the values for
DBUS_SESSION_BUS_ADDRESS and DBUS_SESSION_BUS_PID, and I don't know
how to find them out as www-data. Obviously www-data doesn't have the
rights to look in /proc/PID/environ for a process that's running as
me. Is there any way I can find these values for my session bus as
another user, so I can make notifications work from PHP the way I'd
like to?

sil

-- 
I had a black 1gb old Nano too, and that scratched like Grandmaster
Flash
   -- colly


More information about the dbus mailing list