Need to know client/caller pid on the server side
masala north
masalanorth at yahoo.com
Thu Oct 25 16:15:27 PDT 2007
I did try it. But the pid returned is -1. I want in the daemon side, the client's pid. There are certain services I want to allow for a limited set of clients serviced by this daemon. unix_user allows returning 0 (since I have the intialized variable passed in).
Here is the daemon code snippet
install_err security_service_allow_install (
SecurityObject *obj,
gchar *deb_path,
gerror **error)
{
unsigned long pid;
DBusConnection *conn;
conn = dbus_g_connection_get_connection(obj->connection);
rv = dbus_connection_get_unix_process_id(conn, &pid);
if (client_allowed_to_install(pid)) {
install();
}
Thanks
John.
Havoc Pennington <hp at redhat.com> wrote: 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
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20071025/470db729/attachment.html
More information about the dbus
mailing list