dbus/dbus dbus-auth.c, 1.36, 1.37 dbus-connection.c, 1.81,
1.82 dbus-connection.h, 1.29, 1.30 dbus-protocol.h, 1.29,
1.30 dbus-transport.c, 1.38, 1.39 dbus-transport.h, 1.14, 1.15
David Zeuthen
david at freedesktop.org
Mon Jul 19 13:56:00 PDT 2004
Update of /cvs/dbus/dbus/dbus
In directory pdx:/tmp/cvs-serv4610/dbus
Modified Files:
dbus-auth.c dbus-connection.c dbus-connection.h
dbus-protocol.h dbus-transport.c dbus-transport.h
Log Message:
2004-07-19 David Zeuthen <david at 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
Index: dbus-auth.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-auth.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- dbus-auth.c 20 Jun 2004 15:28:14 -0000 1.36
+++ dbus-auth.c 19 Jul 2004 20:55:58 -0000 1.37
@@ -1048,9 +1048,9 @@
DBUS_AUTH_NAME (auth),
auth->desired_identity.uid,
auth->credentials.uid);
-
+
+ auth->authorized_identity.pid = auth->credentials.pid;
auth->authorized_identity.uid = auth->desired_identity.uid;
-
return TRUE;
}
else
Index: dbus-connection.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- dbus-connection.c 20 Jun 2004 15:28:15 -0000 1.81
+++ dbus-connection.c 19 Jul 2004 20:55:58 -0000 1.82
@@ -2985,6 +2985,37 @@
}
/**
+ * 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
* authenticated with a particular user ID, this function is called;
Index: dbus-connection.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-connection.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- dbus-connection.h 20 Jun 2004 15:28:15 -0000 1.29
+++ dbus-connection.h 19 Jul 2004 20:55:58 -0000 1.30
@@ -138,6 +138,8 @@
DBusFreeFunction free_data_function);
dbus_bool_t dbus_connection_get_unix_user (DBusConnection *connection,
unsigned long *uid);
+dbus_bool_t dbus_connection_get_unix_process_id (DBusConnection *connection,
+ unsigned long *pid);
void dbus_connection_set_unix_user_function (DBusConnection *connection,
DBusAllowUnixUserFunction function,
void *data,
Index: dbus-protocol.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-protocol.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- dbus-protocol.h 20 Jun 2004 15:28:15 -0000 1.29
+++ dbus-protocol.h 19 Jul 2004 20:55:58 -0000 1.30
@@ -154,6 +154,7 @@
#define DBUS_ERROR_SPAWN_CHILD_EXITED "org.freedesktop.DBus.Error.Spawn.ChildExited"
#define DBUS_ERROR_SPAWN_CHILD_SIGNALED "org.freedesktop.DBus.Error.Spawn.ChildSignaled"
#define DBUS_ERROR_SPAWN_FAILED "org.freedesktop.DBus.Error.Spawn.Failed"
+#define DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN "org.freedesktop.DBus.Error.UnixProcessIdUnknown"
#ifdef __cplusplus
}
Index: dbus-transport.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- dbus-transport.c 17 May 2004 23:34:55 -0000 1.38
+++ dbus-transport.c 19 Jul 2004 20:55:58 -0000 1.39
@@ -938,6 +938,38 @@
}
/**
+ * 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
Index: dbus-transport.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-transport.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- dbus-transport.h 20 Jun 2004 15:28:15 -0000 1.14
+++ dbus-transport.h 19 Jul 2004 20:55:58 -0000 1.15
@@ -59,6 +59,8 @@
long _dbus_transport_get_max_received_size (DBusTransport *transport);
dbus_bool_t _dbus_transport_get_unix_user (DBusTransport *transport,
unsigned long *uid);
+dbus_bool_t _dbus_transport_get_unix_process_id (DBusTransport *transport,
+ unsigned long *pid);
void _dbus_transport_set_unix_user_function (DBusTransport *transport,
DBusAllowUnixUserFunction function,
void *data,
More information about the dbus-commit
mailing list