From 893d859ed4ab785f46485fad28779f026fa166a1 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 28 Apr 2003 19:29:42 +0000 Subject: 2003-04-28 Havoc Pennington * configure.in: 0.10 * NEWS: update * bus/system.conf.in: add system.d * dbus/dbus-userdb.c (_dbus_user_database_lookup): fix bug when username was provided but not uid * bus/config-parser.c (struct BusConfigParser): keep track of whether the parser is toplevel or was included; change some of the error handling if it's included. --- dbus/dbus-userdb.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'dbus') diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index 00f2dced..4a7b7488 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -69,7 +69,8 @@ _dbus_user_database_lookup (DBusUserDatabase *db, DBusUserInfo *info; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - + _dbus_assert (uid != DBUS_UID_UNSET || username != NULL); + if (uid != DBUS_UID_UNSET) info = _dbus_hash_table_lookup_ulong (db->users, uid); else @@ -93,13 +94,30 @@ _dbus_user_database_lookup (DBusUserDatabase *db, return NULL; } - if (!_dbus_user_info_fill_uid (info, uid, error)) + if (uid != DBUS_UID_UNSET) { - _DBUS_ASSERT_ERROR_IS_SET (error); - free_user_info (info); - return NULL; + if (!_dbus_user_info_fill_uid (info, uid, error)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + free_user_info (info); + return NULL; + } + } + else + { + if (!_dbus_user_info_fill (info, username, error)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + free_user_info (info); + return NULL; + } } + /* be sure we don't use these after here */ + uid = DBUS_UID_UNSET; + username = NULL; + + /* insert into hash */ if (!_dbus_hash_table_insert_ulong (db->users, info->uid, info)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); -- cgit