Get the client PID in a server request

Colin Walters walters at verbum.org
Mon Oct 20 07:09:36 PDT 2008


On Mon, Oct 20, 2008 at 9:05 AM, Luca Ferrari <luka4e at gmail.com> wrote:
> Hello guys!
>
> I searched for a while but I didn't find any solutions to this problem:
>
> I've got a server (called SERVER) that exposed via DBUS a method
> (called METHOD) and a client (called CLIENT) that would like to invoke
> SERVER's METHOD method.
>
> SERVER must first check the pid of CLIENT and then invoke METHOD if
> the CLIENT's pid is in a list of known pids...

If this is a direct connection, there's dbus_connection_get_unix_user.

If you're receiving this message through the bus, call the
org.freedesktop.DBus.GetConnectionUnixUser on the bus.  Example Python:

python -c "import dbus;
bus=dbus.SystemBus().get_object('org.freedesktop.DBus',
'/org/freedesktop/DBus'); print dbus.Interface(bus,
'org.freedesktop.DBus').GetConnectionUnixUser(':1.11')"


More information about the dbus mailing list