Need to know client/caller pid on the server side

Havoc Pennington hp at redhat.com
Thu Oct 25 15:42:04 PDT 2007


Hi,

masala north wrote:
> We are developing a security frame work sitting on top of dbus. Is it 
> possible to get the pid of the calling/client process?
> 

If you are talking to another program directly (no bus daemon) you would 
use dbus_connection_get_unix_process_id / dbus_connection_get_unix_user

If you are using the bus daemon, you need to ask the bus daemon to call 
those functions for you.

To see the methods on the bus daemon type this command:
  dbus-send --print-reply --dest=org.freedesktop.DBus 
org.freedesktop.DBus.Introspectable.Introspect

In this case you want GetConnectionUnixUser and GetConnectionUnixProcessID.

There is a convenience function dbus_bus_get_unix_user() that calls 
GetConnectionUnixUser, but the convenience function makes a blocking 
call. There's no convenience function for the process ID one.

To get the name of the client use dbus_message_get_sender()

Havoc




More information about the dbus mailing list