"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dbus/dbus-userdb.c" between
dbus-1.13.16.tar.xz and dbus-1.13.18.tar.xz

About: D-Bus is an inter-process communication (IPC) system, allowing multiple, concurrently-running applications to communicate with one another. D-Bus supplies both a system daemon and a per-user-login-session daemon. Development version.

dbus-userdb.c  (dbus-1.13.16.tar.xz):dbus-userdb.c  (dbus-1.13.18.tar.xz)
skipping to change at line 45 skipping to change at line 45
* implementation of some of it in dbus-sysdeps-win.c. */ * implementation of some of it in dbus-sysdeps-win.c. */
#if defined(DBUS_WIN) || !defined(DBUS_UNIX) #if defined(DBUS_WIN) || !defined(DBUS_UNIX)
#error "This file only makes sense on Unix OSs" #error "This file only makes sense on Unix OSs"
#endif #endif
/** /**
* @addtogroup DBusInternalsUtils * @addtogroup DBusInternalsUtils
* @{ * @{
*/ */
static DBusUserInfo *
_dbus_user_info_ref (DBusUserInfo *info)
{
_dbus_assert (info->refcount > 0);
_dbus_assert (info->refcount < SIZE_MAX);
info->refcount++;
return info;
}
/** /**
* Frees the given #DBusUserInfo's members with _dbus_user_info_free() * Decrements the reference count. If it reaches 0,
* frees the given #DBusUserInfo's members with _dbus_user_info_free()
* and also calls dbus_free() on the block itself * and also calls dbus_free() on the block itself
* *
* @param info the info * @param info the info
*/ */
void void
_dbus_user_info_free_allocated (DBusUserInfo *info) _dbus_user_info_unref (DBusUserInfo *info)
{ {
if (info == NULL) /* hash table will pass NULL */ if (info == NULL) /* hash table will pass NULL */
return; return;
_dbus_assert (info->refcount > 0);
_dbus_assert (info->refcount < SIZE_MAX);
if (--info->refcount > 0)
return;
_dbus_user_info_free (info); _dbus_user_info_free (info);
dbus_free (info); dbus_free (info);
} }
/** /**
* Frees the given #DBusGroupInfo's members with _dbus_group_info_free() * Decrements the reference count. If it reaches 0,
* frees the given #DBusGroupInfo's members with _dbus_group_info_free()
* and also calls dbus_free() on the block itself * and also calls dbus_free() on the block itself
* *
* @param info the info * @param info the info
*/ */
void void
_dbus_group_info_free_allocated (DBusGroupInfo *info) _dbus_group_info_unref (DBusGroupInfo *info)
{ {
if (info == NULL) /* hash table will pass NULL */ if (info == NULL) /* hash table will pass NULL */
return; return;
_dbus_assert (info->refcount > 0);
_dbus_assert (info->refcount < SIZE_MAX);
if (--info->refcount > 0)
return;
_dbus_group_info_free (info); _dbus_group_info_free (info);
dbus_free (info); dbus_free (info);
} }
/** /**
* Frees the members of info * Frees the members of info
* (but not info itself) * (but not info itself)
* @param info the user info struct * @param info the user info struct
*/ */
void void
skipping to change at line 132 skipping to change at line 155
/** /**
* Looks up a uid or username in the user database. Only one of name * Looks up a uid or username in the user database. Only one of name
* or UID can be provided. There are wrapper functions for this that * or UID can be provided. There are wrapper functions for this that
* are better to use, this one does no locking or anything on the * are better to use, this one does no locking or anything on the
* database and otherwise sort of sucks. * database and otherwise sort of sucks.
* *
* @param db the database * @param db the database
* @param uid the user ID or #DBUS_UID_UNSET * @param uid the user ID or #DBUS_UID_UNSET
* @param username username or #NULL * @param username username or #NULL
* @param error error to fill in * @param error error to fill in
* @returns the entry in the database * @returns the entry in the database (borrowed, do not free)
*/ */
DBusUserInfo* const DBusUserInfo *
_dbus_user_database_lookup (DBusUserDatabase *db, _dbus_user_database_lookup (DBusUserDatabase *db,
dbus_uid_t uid, dbus_uid_t uid,
const DBusString *username, const DBusString *username,
DBusError *error) DBusError *error)
{ {
DBusUserInfo *info; DBusUserInfo *info;
_DBUS_ASSERT_ERROR_IS_CLEAR (error); _DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_assert (uid != DBUS_UID_UNSET || username != NULL); _dbus_assert (uid != DBUS_UID_UNSET || username != NULL);
skipping to change at line 180 skipping to change at line 203
else else
_dbus_verbose ("No cache for user \"%s\"\n", _dbus_verbose ("No cache for user \"%s\"\n",
_dbus_string_get_const_data (username)); _dbus_string_get_const_data (username));
info = dbus_new0 (DBusUserInfo, 1); info = dbus_new0 (DBusUserInfo, 1);
if (info == NULL) if (info == NULL)
{ {
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
return NULL; return NULL;
} }
info->refcount = 1;
if (uid != DBUS_UID_UNSET) if (uid != DBUS_UID_UNSET)
{ {
if (!_dbus_user_info_fill_uid (info, uid, error)) if (!_dbus_user_info_fill_uid (info, uid, error))
{ {
_DBUS_ASSERT_ERROR_IS_SET (error); _DBUS_ASSERT_ERROR_IS_SET (error);
_dbus_user_info_free_allocated (info); _dbus_user_info_unref (info);
return NULL; return NULL;
} }
} }
else else
{ {
if (!_dbus_user_info_fill (info, username, error)) if (!_dbus_user_info_fill (info, username, error))
{ {
_DBUS_ASSERT_ERROR_IS_SET (error); _DBUS_ASSERT_ERROR_IS_SET (error);
_dbus_user_info_free_allocated (info); _dbus_user_info_unref (info);
return NULL; return NULL;
} }
} }
/* be sure we don't use these after here */ /* be sure we don't use these after here */
uid = DBUS_UID_UNSET; uid = DBUS_UID_UNSET;
username = NULL; username = NULL;
/* insert into hash */ /* insert into hash */
if (!_dbus_hash_table_insert_uintptr (db->users, info->uid, info)) if (_dbus_hash_table_insert_uintptr (db->users, info->uid, info))
{
_dbus_user_info_ref (info);
}
else
{ {
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_user_info_free_allocated (info); _dbus_user_info_unref (info);
return NULL; return NULL;
} }
if (!_dbus_hash_table_insert_string (db->users_by_name, if (_dbus_hash_table_insert_string (db->users_by_name,
info->username, info->username,
info)) info))
{
_dbus_user_info_ref (info);
}
else
{ {
_dbus_hash_table_remove_uintptr (db->users, info->uid); _dbus_hash_table_remove_uintptr (db->users, info->uid);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_user_info_unref (info);
return NULL; return NULL;
} }
_dbus_user_info_unref (info);
/* Return a borrowed pointer to the DBusUserInfo owned by the
* hash tables */
return info; return info;
} }
} }
/* Protected by _DBUS_LOCK_system_users */ /* Protected by _DBUS_LOCK_system_users */
static dbus_bool_t database_locked = FALSE; static dbus_bool_t database_locked = FALSE;
static DBusUserDatabase *system_db = NULL; static DBusUserDatabase *system_db = NULL;
static DBusString process_username; static DBusString process_username;
static DBusString process_homedir; static DBusString process_homedir;
skipping to change at line 570 skipping to change at line 607
{ {
DBusUserDatabase *db; DBusUserDatabase *db;
db = dbus_new0 (DBusUserDatabase, 1); db = dbus_new0 (DBusUserDatabase, 1);
if (db == NULL) if (db == NULL)
return NULL; return NULL;
db->refcount = 1; db->refcount = 1;
db->users = _dbus_hash_table_new (DBUS_HASH_UINTPTR, db->users = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
NULL, (DBusFreeFunction) _dbus_user_info_fre e_allocated); NULL, (DBusFreeFunction) _dbus_user_info_unr ef);
if (db->users == NULL) if (db->users == NULL)
goto failed; goto failed;
db->groups = _dbus_hash_table_new (DBUS_HASH_UINTPTR, db->groups = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
NULL, (DBusFreeFunction) _dbus_group_info_f ree_allocated); NULL, (DBusFreeFunction) _dbus_group_info_u nref);
if (db->groups == NULL) if (db->groups == NULL)
goto failed; goto failed;
db->users_by_name = _dbus_hash_table_new (DBUS_HASH_STRING, db->users_by_name = _dbus_hash_table_new (DBUS_HASH_STRING,
NULL, NULL); NULL, (DBusFreeFunction) _dbus_user_ info_unref);
if (db->users_by_name == NULL) if (db->users_by_name == NULL)
goto failed; goto failed;
db->groups_by_name = _dbus_hash_table_new (DBUS_HASH_STRING, db->groups_by_name = _dbus_hash_table_new (DBUS_HASH_STRING,
NULL, NULL); NULL, (DBusFreeFunction) _dbus_grou p_info_unref);
if (db->groups_by_name == NULL) if (db->groups_by_name == NULL)
goto failed; goto failed;
return db; return db;
failed: failed:
_dbus_user_database_unref (db); _dbus_user_database_unref (db);
return NULL; return NULL;
} }
 End of changes. 21 change blocks. 
17 lines changed or deleted 54 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)