[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-dbus
Subject: Re: Need to know client/caller pid on the server side
From: masala north <masalanorth () yahoo ! com>
Date: 2007-10-25 23:15:27
Message-ID: 244296.49740.qm () web63404 ! mail ! re1 ! yahoo ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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@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
[Attachment #5 (text/html)]
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).<br> <br> Here is the daemon code snippet<br> <br> \
install_err security_service_allow_install (<br> \
SecurityObject *obj,<br> \
gchar *deb_path,<br> \
gerror **error)<br> {<br> <br> \
unsigned long pid;<br> DBusConnection *conn;<br> <br> conn = \
dbus_g_connection_get_connection(obj->connection);<br> rv = \
dbus_connection_get_unix_process_id(conn, &pid);<br> <br> if \
(client_allowed_to_install(pid)) {<br> install();<br> \
}<br> <br> Thanks<br> John.<br><br> <br><b><i>Havoc Pennington \
<hp@redhat.com></i></b> wrote:<blockquote class="replbq" style="border-left: \
2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> Hi,<br><br>masala \
north wrote:<br>> We are developing a security frame work sitting on top of dbus. \
Is it <br>> possible to get the pid of the calling/client process?<br>> \
<br><br>If you are talking to another program directly (no bus daemon) you would \
<br>use dbus_connection_get_unix_process_id / dbus_connection_get_unix_user<br><br>If \
you are using the bus daemon, you need to ask the bus daemon to call <br>those \
functions for you.<br><br>To see the methods on the bus daemon type this command:<br> \
dbus-send --print-reply --dest=org.freedesktop.DBus \
<br>org.freedesktop.DBus.Introspectable.Introspect<br><br>In this case you want \
GetConnectionUnixUser and GetConnectionUnixProcessID.<br><br>There is a convenience \
function dbus_bus_get_unix_user() that calls <br>GetConnectionUnixUser, but the \
convenience function makes a blocking <br>call. There's no convenience function for \
the process ID one.<br><br>To get the name of the client use \
dbus_message_get_sender()<br><br>Havoc<br><br><br></blockquote><br><p> __________________________________________________<br>Do \
You Yahoo!?<br>Tired of spam? Yahoo! Mail has the best spam protection around \
<br>http://mail.yahoo.com
_______________________________________________
dbus mailing list
dbus@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dbus
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic