summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-transport.c
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2004-07-19 20:55:58 +0000
committerDavid Zeuthen <davidz@redhat.com>2004-07-19 20:55:58 +0000
commitc9c0adce43caa00345ad2aeb55822eabde523c2c (patch)
tree0fcc4a4b7f5f453781b654a689efb84277fea9e5 /dbus/dbus-transport.c
parentdcbc92bfeb600efb7244f80247655f004cb558b2 (diff)
2004-07-19 David Zeuthen <david@fubar.dk>
* dbus/dbus-protocol.h: Add DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN * bus/dispatch.c: (check_get_connection_unix_user): Debug says GetProperty; but the method is called GetConnectionUnixUser (check_get_connection_unix_process_id): New function (bus_dispatch_test): Actually call check_get_connection_unix_user(); also call check_get_connection_unix_process_id() * bus/driver.c: (bus_driver_handle_get_connection_unix_process_id): New function, handles GetConnectionUnixProcessID on the org.freedesktop.DBus interface * dbus/dbus-auth.c: (handle_server_data_external_mech): Set pid from the credentials obtained from the socket * dbus/dbus-connection.c: (dbus_connection_get_unix_process_id): New function * dbus/dbus-connection.h: Add prototype for dbus_connection_get_unix_process_id * dbus/dbus-transport.c: (_dbus_transport_get_unix_process_id): New function * dbus/dbus-transport.h: Add prototype for _dbus_transport_get_unix_process_id
Diffstat (limited to 'dbus/dbus-transport.c')
-rw-r--r--dbus/dbus-transport.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c
index 371ecbfb..ada960d4 100644
--- a/dbus/dbus-transport.c
+++ b/dbus/dbus-transport.c
@@ -938,6 +938,38 @@ _dbus_transport_get_unix_user (DBusTransport *transport,
}
/**
+ * See dbus_connection_get_unix_process_id().
+ *
+ * @param transport the transport
+ * @param pid return location for the process ID
+ * @returns #TRUE if uid is filled in with a valid process ID
+ */
+dbus_bool_t
+_dbus_transport_get_unix_process_id (DBusTransport *transport,
+ unsigned long *pid)
+{
+ DBusCredentials auth_identity;
+
+ *pid = DBUS_PID_UNSET; /* Caller should never use this value on purpose,
+ * but we set it to a safe number, INT_MAX,
+ * just to root out possible bugs in bad callers.
+ */
+
+ if (!transport->authenticated)
+ return FALSE;
+
+ _dbus_auth_get_identity (transport->auth, &auth_identity);
+
+ if (auth_identity.pid != DBUS_PID_UNSET)
+ {
+ *pid = auth_identity.pid;
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+/**
* See dbus_connection_set_unix_user_function().
*
* @param transport the transport