27#define DBUS_USERDB_INCLUDES_PRIVATE 1
28#include "dbus-userdb.h"
30#include "dbus-internals.h"
31#include "dbus-protocol.h"
32#include <dbus/dbus-test-tap.h>
37#if defined(DBUS_WIN) || !defined(DBUS_UNIX)
38#error "This file only makes sense on Unix OSs"
42#include <systemd/sd-login.h>
72 if (access (
"/run/systemd/seats/", F_OK) >= 0)
78 r = sd_uid_get_seats (uid, 0,
NULL);
92#ifdef HAVE_CONSOLE_OWNER_FILE
99 _DBUS_SET_OOM (error);
106 _DBUS_SET_OOM (error);
148 DBusUserDatabase *db;
190 DBusUserDatabase *db;
240 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
268 _dbus_verbose (
"No cache for groupname \"%s\"\n",
283 _DBUS_ASSERT_ERROR_IS_SET (error);
292 _DBUS_ASSERT_ERROR_IS_SET (error);
304 _dbus_group_info_ref (info);
318 _dbus_group_info_ref (info);
354 DBusUserDatabase *db;
356 dbus_bool_t ret =
FALSE;
363 _DBUS_SET_OOM (error);
370 _DBUS_SET_OOM (error);
382 if (*group_ids ==
NULL)
384 _DBUS_SET_OOM (error);
395 _DBUS_ASSERT_ERROR_XOR_BOOL (error, ret);
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
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_hash_table_insert_string(DBusHashTable *table, char *key, void *value)
Creates a hash entry with the given key and value.
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.
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_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_stat(const DBusString *filename, DBusStat *statbuf, DBusError *error)
stat() wrapper.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
dbus_bool_t _dbus_user_database_lock_system(void)
Locks global system user database.
const char * _dbus_error_from_errno(int error_number)
Converts a UNIX errno, or Windows errno or WinSock error value into a DBusError name.
void _dbus_user_database_unlock_system(void)
Unlocks global system 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.
dbus_bool_t _dbus_get_group_id(const DBusString *groupname, dbus_gid_t *gid)
Gets group ID given groupname.
void _dbus_group_info_unref(DBusGroupInfo *info)
Decrements the reference count.
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.
const 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_groups_from_uid(dbus_uid_t uid, dbus_gid_t **group_ids, int *n_group_ids, DBusError *error)
Gets all groups corresponding to the given UID.
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_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_is_a_number(const DBusString *str, unsigned long *num)
Checks if a given string is actually a number and converts it if it is.
dbus_bool_t _dbus_get_user_id(const DBusString *username, dbus_uid_t *uid)
Gets user ID given username.
DBusUserDatabase * _dbus_user_database_get_system(void)
Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system(...
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
#define dbus_new(type, count)
Safe macro for using dbus_malloc().
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as _DBUS_STRING_IN...
const char * _dbus_string_get_const_data(const DBusString *str)
Gets the raw character buffer from a const string.
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_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.
unsigned long dbus_uid_t
A user ID.
unsigned long dbus_gid_t
A group ID.
#define DBUS_UID_UNSET
an invalid UID used to represent an uninitialized dbus_uid_t field
#define DBUS_GID_UNSET
an invalid GID used to represent an uninitialized dbus_gid_t field
#define DBUS_GID_FORMAT
an appropriate printf format for dbus_gid_t
#define DBUS_UID_FORMAT
an appropriate printf format for dbus_uid_t
Object representing an exception.
Information about a UNIX group.
char * groupname
Group name.
size_t refcount
Reference count.
Portable struct with stat() results.
dbus_uid_t uid
User owning file.
Information about a UNIX user.
int n_group_ids
Size of group IDs array.
dbus_gid_t * group_ids
Groups IDs, including above primary group.
dbus_gid_t primary_gid
GID.