24 #define DBUS_USERDB_INCLUDES_PRIVATE 1    25 #include "dbus-userdb.h"    26 #include "dbus-hash.h"    27 #include "dbus-test.h"    28 #include "dbus-internals.h"    29 #include "dbus-protocol.h"    30 #include "dbus-credentials.h"   109       end == _dbus_string_get_length (str))
   135   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   164         _dbus_verbose (
"No cache for user \"%s\"\n",
   165                        _dbus_string_get_const_data (username));
   178               _DBUS_ASSERT_ERROR_IS_SET (error);
   187               _DBUS_ASSERT_ERROR_IS_SET (error);
   219 static DBusUserDatabase *system_db = 
NULL;
   224 shutdown_system_db (
void *data)
   226   if (system_db != 
NULL)
   234 init_system_db (
void)
   238   if (system_db == 
NULL)
   244       if (system_db == 
NULL)
   263               _dbus_warn (
"Could not get password database information for UID of current process: %s",
   310       database_locked = 
TRUE;
   325   database_locked = 
FALSE;
   357    if (system_db != 
NULL)
   376   if (!init_system_db ())
   381   *username = &process_username;
   400   if (!init_system_db ())
   405   *homedir = &process_homedir;
   422   DBusUserDatabase *db;
   464   DBusUserDatabase *db;
   469       const char *from_environment;
   473       if (from_environment != 
NULL)
   523   DBusUserDatabase *db;
   562   DBusUserDatabase *db;
   573   if (db->users == 
NULL)
   579   if (db->groups == 
NULL)
   584   if (db->users_by_name == 
NULL)
   589   if (db->groups_by_name == 
NULL)
   611 #ifdef DBUS_ENABLE_EMBEDDED_TESTS   618 _dbus_user_database_ref (DBusUserDatabase  *db)
   638   if (db->refcount == 0)
   646       if (db->users_by_name)
   649       if (db->groups_by_name)
   673   return *info != 
NULL;
   692   return *info != 
NULL;
 dbus_bool_t dbus_error_has_name(const DBusError *error, const char *name)
Checks whether the error is set and has the given name. 
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString. 
void * _dbus_hash_table_lookup_uintptr(DBusHashTable *table, uintptr_t key)
Looks up the value for a given integer in a hash table of type DBUS_HASH_UINTPTR. ...
const char * message
public error message field 
#define NULL
A null pointer, defined appropriately for C or C++. 
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory. 
DBusUserInfo * _dbus_user_database_lookup(DBusUserDatabase *db, dbus_uid_t uid, const DBusString *username, DBusError *error)
Looks up a uid or username in the user database. 
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0(). 
void _dbus_user_info_free(DBusUserInfo *info)
Frees the members of info (but not info itself) 
dbus_bool_t _dbus_user_database_lock_system(void)
Locks global system user database. 
#define _dbus_assert(condition)
Aborts with an error message if the condition is false. 
#define DBUS_ERROR_INIT
Expands to a suitable initializer for a DBusError on the stack. 
void _dbus_user_database_flush_system(void)
Flushes the system global user database;. 
void dbus_error_free(DBusError *error)
Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...
dbus_bool_t _dbus_homedir_from_username(const DBusString *username, DBusString *homedir)
Gets the home directory for the given user. 
dbus_bool_t _dbus_hash_table_insert_uintptr(DBusHashTable *table, uintptr_t key, void *value)
Creates a hash entry with the given key and value. 
void _dbus_hash_table_unref(DBusHashTable *table)
Decrements the reference count for a hash table, freeing the hash table if the count reaches zero...
void _dbus_user_database_flush(DBusUserDatabase *db)
Flush all information out of the user database. 
dbus_bool_t _dbus_user_database_get_uid(DBusUserDatabase *db, dbus_uid_t uid, const DBusUserInfo **info, DBusError *error)
Gets the user information for the given UID, returned user info should not be freed. 
void _dbus_user_database_unlock_system(void)
Unlocks global system user database. 
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string. 
Hash keys are integer capable to hold a pointer. 
void _dbus_hash_table_remove_all(DBusHashTable *table)
Removed all entries from a hash table. 
char * groupname
Group name. 
#define DBUS_UID_UNSET
an invalid UID used to represent an uninitialized dbus_uid_t field 
void _dbus_user_info_free_allocated(DBusUserInfo *info)
Frees the given DBusUserInfo's members with _dbus_user_info_free() and also calls dbus_free() on the ...
dbus_bool_t _dbus_user_info_fill(DBusUserInfo *info, const DBusString *username, DBusError *error)
Gets user info for the given username. 
void _dbus_group_info_free(DBusGroupInfo *info)
Frees the members of info (but not info itself). 
DBusUserDatabase * _dbus_user_database_get_system(void)
Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system(...
dbus_bool_t _dbus_homedir_from_uid(dbus_uid_t uid, DBusString *homedir)
Gets the home directory for the given user. 
dbus_gid_t * group_ids
Groups IDs, including above primary group. 
dbus_bool_t _dbus_is_a_number(const DBusString *str, unsigned long *num)
Checks if a given string is actually a number and converts it if it is. 
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0(). 
void _dbus_group_info_free_allocated(DBusGroupInfo *info)
Frees the given DBusGroupInfo's members with _dbus_group_info_free() and also calls dbus_free() on th...
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE. 
void _dbus_warn(const char *format,...)
Prints a warning message to stderr. 
dbus_bool_t _dbus_credentials_add_from_user(DBusCredentials *credentials, const DBusString *username)
Adds the credentials corresponding to the given username. 
dbus_bool_t _dbus_hash_table_insert_string(DBusHashTable *table, char *key, void *value)
Creates a hash entry with the given key and value. 
Object representing an exception. 
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError. 
DBusUserDatabase * _dbus_user_database_new(void)
Creates a new user database object used to look up and cache user information. 
#define _DBUS_UNLOCK(name)
Unlocks a global lock. 
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(). 
dbus_uid_t _dbus_geteuid(void)
Gets our effective UID. 
#define TRUE
Expands to "1". 
#define DBUS_UID_FORMAT
an appropriate printf format for dbus_uid_t 
char * homedir
Home directory. 
dbus_bool_t _dbus_homedir_from_current_process(const DBusString **homedir)
Gets homedir of user owning current process. 
Information about a UNIX group. 
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_string_parse_uint(const DBusString *str, int start, unsigned long *value_return, int *end_return)
Parses an unsigned integer contained in a DBusString. 
dbus_uid_t _dbus_getuid(void)
Gets our UID. 
dbus_bool_t _dbus_user_info_fill_uid(DBusUserInfo *info, dbus_uid_t uid, DBusError *error)
Gets user info for the given user ID. 
void * _dbus_hash_table_lookup_string(DBusHashTable *table, const char *key)
Looks up the value for a given string in a hash table of type DBUS_HASH_STRING. 
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation. 
#define FALSE
Expands to "0". 
DBusCredentials * credentials
Credentials of other end read from the socket. 
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_register_shutdown_func(DBusShutdownFunction function, void *data)
Register a cleanup function to be called exactly once the next time dbus_shutdown() is called...
#define _DBUS_LOCK(name)
Locks a global lock, initializing it first if necessary. 
dbus_bool_t _dbus_user_database_get_username(DBusUserDatabase *db, const DBusString *username, const DBusUserInfo **info, DBusError *error)
Gets the user information for the given username. 
dbus_bool_t _dbus_credentials_add_unix_uid(DBusCredentials *credentials, dbus_uid_t uid)
Add a UNIX user ID to the credentials. 
const char * _dbus_getenv(const char *varname)
Wrapper for getenv(). 
void _dbus_user_database_unref(DBusUserDatabase *db)
Decrements refcount of user database. 
unsigned long dbus_uid_t
A user ID. 
dbus_bool_t _dbus_hash_table_remove_uintptr(DBusHashTable *table, uintptr_t key)
Removes the hash entry for the given key. 
dbus_bool_t _dbus_username_from_current_process(const DBusString **username)
Gets username of user owning current process. 
DBusHashTable * _dbus_hash_table_new(DBusHashType type, DBusFreeFunction key_free_function, DBusFreeFunction value_free_function)
Constructs a new hash table. 
Information about a UNIX user.