From c9c0adce43caa00345ad2aeb55822eabde523c2c Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Mon, 19 Jul 2004 20:55:58 +0000 Subject: 2004-07-19 David Zeuthen * 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 --- dbus/dbus-connection.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'dbus/dbus-connection.c') diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index d68c3958..58ab7900 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -2984,6 +2984,37 @@ dbus_connection_get_unix_user (DBusConnection *connection, return result; } +/** + * Gets the process ID of the connection if any. + * Returns #TRUE if the uid is filled in. + * Always returns #FALSE prior to authenticating the + * connection. + * + * @param connection the connection + * @param pid return location for the process ID + * @returns #TRUE if uid is filled in with a valid process ID + */ +dbus_bool_t +dbus_connection_get_unix_process_id (DBusConnection *connection, + unsigned long *pid) +{ + dbus_bool_t result; + + _dbus_return_val_if_fail (connection != NULL, FALSE); + _dbus_return_val_if_fail (pid != NULL, FALSE); + + CONNECTION_LOCK (connection); + + if (!_dbus_transport_get_is_authenticated (connection->transport)) + result = FALSE; + else + result = _dbus_transport_get_unix_process_id (connection->transport, + pid); + CONNECTION_UNLOCK (connection); + + return result; +} + /** * Sets a predicate function used to determine whether a given user ID * is allowed to connect. When an incoming connection has -- cgit