From 23832672266bb4ff23b66247c0cfa1a2ed0cc97b Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 9 Jun 2007 21:53:20 +0000 Subject: 2007-06-09 Havoc Pennington * bus/dispatch.c (check_get_connection_unix_process_id): adapt since sysdeps-unix.h stuff isn't included anymore * bus/bus.c (bus_context_new): use more abstract functions to change user, so they can be no-ops on Windows * dbus/dbus-credentials.c, dbus/dbus-credentials.h, dbus/dbus-credentials-util.c: new files containing a fully opaque DBusCredentials data type to replace the old not opaque one. * configure.in (DBUS_UNIX): define DBUS_UNIX to match DBUS_WIN on windows * dbus/dbus-userdb.h: prohibit on Windows, next step is to clean up the uses of it in bus/*.c and factor out the parts of cookie auth that depend on it --- dbus/dbus-userdb.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'dbus/dbus-userdb.c') diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index 2aa395dc..c3ae8ef4 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -26,6 +26,7 @@ #include "dbus-test.h" #include "dbus-internals.h" #include "dbus-protocol.h" +#include "dbus-credentials.h" #include /** @@ -65,6 +66,30 @@ _dbus_group_info_free_allocated (DBusGroupInfo *info) dbus_free (info); } +/** + * Frees the members of info + * (but not info itself) + * @param info the user info struct + */ +void +_dbus_user_info_free (DBusUserInfo *info) +{ + dbus_free (info->group_ids); + dbus_free (info->username); + dbus_free (info->homedir); +} + +/** + * Frees the members of info (but not info itself). + * + * @param info the group info + */ +void +_dbus_group_info_free (DBusGroupInfo *info) +{ + dbus_free (info->groupname); +} + /** * Checks if a given string is actually a number * and converts it if it is @@ -412,18 +437,19 @@ _dbus_homedir_from_username (const DBusString *username, } /** - * Gets the credentials corresponding to the given username. + * Adds the credentials corresponding to the given username. * + * @param credentials credentials to fill in * @param username the username - * @param credentials credentials to fill in * @returns #TRUE if the username existed and we got some credentials */ dbus_bool_t -_dbus_credentials_from_username (const DBusString *username, - DBusCredentials *credentials) +_dbus_credentials_add_from_username (DBusCredentials *credentials, + const DBusString *username) { DBusUserDatabase *db; const DBusUserInfo *info; + _dbus_user_database_lock_system (); db = _dbus_user_database_get_system (); @@ -440,9 +466,11 @@ _dbus_credentials_from_username (const DBusString *username, return FALSE; } - credentials->pid = DBUS_PID_UNSET; - credentials->uid = info->uid; - credentials->gid = info->primary_gid; + if (!_dbus_credentials_add_unix_uid(credentials, info->uid)) + { + _dbus_user_database_unlock_system (); + return FALSE; + } _dbus_user_database_unlock_system (); return TRUE; -- cgit