25 #define DBUS_USERDB_INCLUDES_PRIVATE 1    26 #include "dbus-userdb.h"    27 #include "dbus-test.h"    28 #include "dbus-internals.h"    29 #include "dbus-protocol.h"    33 #include <systemd/sd-login.h>    59   if (access (
"/run/systemd/seats/", F_OK) >= 0)
    65       r = sd_uid_get_seats (uid, 0, 
NULL);
    79 #ifdef HAVE_CONSOLE_OWNER_FILE    86       _DBUS_SET_OOM (error);
    93       _DBUS_SET_OOM (error);
   109       _DBUS_SET_OOM (error);
   163   DBusUserDatabase *db;
   203   DBusUserDatabase *db;
   253   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   268                                            _dbus_string_get_const_data (groupname));
   281         _dbus_verbose (
"No cache for groupname \"%s\"\n",
   282                        _dbus_string_get_const_data (groupname));
   295               _DBUS_ASSERT_ERROR_IS_SET (error);
   304               _DBUS_ASSERT_ERROR_IS_SET (error);
   353   return *info != 
NULL;
   373   return *info != 
NULL;
   392   DBusUserDatabase *db;
   420       if (*group_ids == 
NULL)
   436 #ifdef DBUS_ENABLE_EMBEDDED_TESTS   445 _dbus_userdb_test (
const char *test_data_dir)
   450   unsigned long *group_ids;
   466   printf (
"    Current user: %s homedir: %s gids:",
   467           _dbus_string_get_const_data (username),
   468           _dbus_string_get_const_data (homedir));
   470   for (i=0; i<n_group_ids; i++)
   471       printf(
" %ld", group_ids[i]);
   476   printf (
"Is Console user: %i\n",
   478   printf (
"Invocation was OK: %s\n", error.
message ? error.
message : 
"yes");
   480   printf (
"Is Console user 4711: %i\n",
   482   printf (
"Invocation was OK: %s\n", error.
message ? error.
message : 
"yes");
 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++. 
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(). 
Portable struct with stat() results. 
#define dbus_new(type, count)
Safe macro for using dbus_malloc(). 
#define DBUS_GID_FORMAT
an appropriate printf format for dbus_gid_t 
dbus_bool_t _dbus_groups_from_uid(dbus_uid_t uid, dbus_gid_t **group_ids, int *n_group_ids)
Gets all groups corresponding to the given UID. 
dbus_bool_t _dbus_user_database_lock_system(void)
Locks global system user database. 
dbus_bool_t _dbus_is_console_user(dbus_uid_t uid, DBusError *error)
Checks to see if the UID sent in is the console user. 
#define _dbus_assert(condition)
Aborts with an error message if the condition is false. 
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_gid_t primary_gid
GID. 
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. 
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. 
char * groupname
Group name. 
#define DBUS_UID_UNSET
an invalid UID used to represent an uninitialized dbus_uid_t field 
dbus_bool_t _dbus_user_database_get_groupname(DBusUserDatabase *db, const DBusString *groupname, const DBusGroupInfo **info, DBusError *error)
Gets the user information for the given group name, returned group info should not be freed...
const char * _dbus_error_from_errno(int error_number)
Converts a UNIX errno, or Windows errno or WinSock error value into a DBusError name. 
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_get_user_id_and_primary_group(const DBusString *username, dbus_uid_t *uid_p, dbus_gid_t *gid_p)
Gets user ID and primary group given username. 
dbus_gid_t * group_ids
Groups IDs, including above primary group. 
dbus_bool_t _dbus_user_database_get_gid(DBusUserDatabase *db, dbus_gid_t gid, const DBusGroupInfo **info, DBusError *error)
Gets the user information for the given GID, returned group info should not be freed. 
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. 
int n_group_ids
Size of group IDs array. 
dbus_bool_t _dbus_hash_table_insert_string(DBusHashTable *table, char *key, void *value)
Creates a hash entry with the given key and value. 
dbus_bool_t _dbus_group_info_fill_gid(DBusGroupInfo *info, dbus_gid_t gid, DBusError *error)
Initializes the given DBusGroupInfo struct with information about the given group ID...
DBusGroupInfo * _dbus_user_database_lookup_group(DBusUserDatabase *db, dbus_gid_t gid, const DBusString *groupname, DBusError *error)
Looks up a gid or group name in the user database. 
dbus_bool_t _dbus_get_group_id(const DBusString *groupname, dbus_gid_t *gid)
Gets group ID given groupname. 
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. 
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(). 
#define DBUS_GID_UNSET
an invalid GID used to represent an uninitialized dbus_gid_t field 
#define TRUE
Expands to "1". 
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called. 
dbus_bool_t _dbus_group_info_fill(DBusGroupInfo *info, const DBusString *groupname, DBusError *error)
Initializes the given DBusGroupInfo struct with information about the given group name...
dbus_uid_t uid
User owning file. 
#define DBUS_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more. 
#define DBUS_UID_FORMAT
an appropriate printf format for dbus_uid_t 
dbus_bool_t _dbus_homedir_from_current_process(const DBusString **homedir)
Gets homedir of user owning current process. 
Information about a UNIX group. 
dbus_bool_t _dbus_stat(const DBusString *filename, DBusStat *statbuf, DBusError *error)
stat() wrapper. 
dbus_bool_t _dbus_get_user_id(const DBusString *username, dbus_uid_t *uid)
Gets user ID given username. 
void dbus_error_init(DBusError *error)
Initializes a DBusError structure. 
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. 
dbus_bool_t _dbus_user_at_console(const char *username, DBusError *error)
Checks if user is at the console. 
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation. 
#define FALSE
Expands to "0". 
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. 
unsigned long dbus_gid_t
A group ID. 
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. 
Information about a UNIX user.