D-Bus: dbus-userdb.h Source File

D-Bus 1.10.22

dbus-userdb.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-userdb.h User database abstraction
3 *
4 * Copyright (C) 2003 Red Hat, Inc.
5 *
6 * Licensed under the Academic Free License version 2.1
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23
24 #ifndef DBUS_USERDB_H
25 #define DBUS_USERDB_H
26
27 #include <dbus/dbus-sysdeps-unix.h>
28
29 #ifdef DBUS_WIN
30 #error "Don't include this on Windows"
31 #endif
32
33 DBUS_BEGIN_DECLS
34
35 typedef struct DBusUserDatabase DBusUserDatabase;
36
37 #ifdef DBUS_USERDB_INCLUDES_PRIVATE
38 #include <dbus/dbus-hash.h>
39
43 struct DBusUserDatabase
44 {
45 int refcount;
47 DBusHashTable *users;
48 DBusHashTable *groups;
49 DBusHashTable *users_by_name;
50 DBusHashTable *groups_by_name;
52 };
53
54
55 DBusUserDatabase* _dbus_user_database_new (void);
56 DBusUserDatabase* _dbus_user_database_ref (DBusUserDatabase *db);
57 void _dbus_user_database_flush (DBusUserDatabase *db);
58 void _dbus_user_database_unref (DBusUserDatabase *db);
59 DBUS_PRIVATE_EXPORT
60 dbus_bool_t _dbus_user_database_get_uid (DBusUserDatabase *db,
61 dbus_uid_t uid,
62 const DBusUserInfo **info,
63 DBusError *error);
64 dbus_bool_t _dbus_user_database_get_gid (DBusUserDatabase *db,
65 dbus_gid_t gid,
66 const DBusGroupInfo **info,
67 DBusError *error);
68 DBUS_PRIVATE_EXPORT
69 dbus_bool_t _dbus_user_database_get_username (DBusUserDatabase *db,
70 const DBusString *username,
71 const DBusUserInfo **info,
72 DBusError *error);
73 dbus_bool_t _dbus_user_database_get_groupname (DBusUserDatabase *db,
74 const DBusString *groupname,
75 const DBusGroupInfo **info,
76 DBusError *error);
77
78 DBUS_PRIVATE_EXPORT
79 DBusUserInfo* _dbus_user_database_lookup (DBusUserDatabase *db,
80 dbus_uid_t uid,
81 const DBusString *username,
82 DBusError *error);
83 DBUS_PRIVATE_EXPORT
84 DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
85 dbus_gid_t gid,
86 const DBusString *groupname,
87 DBusError *error);
88 DBUS_PRIVATE_EXPORT
89 void _dbus_user_info_free_allocated (DBusUserInfo *info);
90 DBUS_PRIVATE_EXPORT
91 void _dbus_group_info_free_allocated (DBusGroupInfo *info);
92 #endif /* DBUS_USERDB_INCLUDES_PRIVATE */
93
94 DBUS_PRIVATE_EXPORT
95 DBusUserDatabase* _dbus_user_database_get_system (void);
96 DBUS_PRIVATE_EXPORT
97 dbus_bool_t _dbus_user_database_lock_system (void) _DBUS_GNUC_WARN_UNUSED_RESULT;
98 DBUS_PRIVATE_EXPORT
99 void _dbus_user_database_unlock_system (void);
100 void _dbus_user_database_flush_system (void);
101
102 dbus_bool_t _dbus_get_user_id (const DBusString *username,
103 dbus_uid_t *uid);
104 dbus_bool_t _dbus_get_group_id (const DBusString *group_name,
105 dbus_gid_t *gid);
106 DBUS_PRIVATE_EXPORT
107 dbus_bool_t _dbus_get_user_id_and_primary_group (const DBusString *username,
108 dbus_uid_t *uid_p,
109 dbus_gid_t *gid_p);
110 dbus_bool_t _dbus_credentials_from_uid (dbus_uid_t user_id,
111 DBusCredentials *credentials);
112 dbus_bool_t _dbus_groups_from_uid (dbus_uid_t uid,
113 dbus_gid_t **group_ids,
114 int *n_group_ids);
115 DBUS_PRIVATE_EXPORT
116 dbus_bool_t _dbus_is_console_user (dbus_uid_t uid,
117 DBusError *error);
118
119 DBUS_PRIVATE_EXPORT
120 dbus_bool_t _dbus_is_a_number (const DBusString *str,
121 unsigned long *num);
122
123 DBUS_PRIVATE_EXPORT
124 dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
125 DBUS_PRIVATE_EXPORT
126 dbus_bool_t _dbus_homedir_from_current_process (const DBusString **homedir);
127 dbus_bool_t _dbus_homedir_from_username (const DBusString *username,
128 DBusString *homedir);
129
130 dbus_bool_t _dbus_homedir_from_uid (dbus_uid_t uid,
131 DBusString *homedir);
132
133 DBUS_END_DECLS
134
135 #endif /* DBUS_USERDB_H */
DBusCredentials
Definition: dbus-credentials.c:48
_dbus_user_database_lookup
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.
Definition: dbus-userdb.c:128
DBUS_BEGIN_DECLS
#define DBUS_BEGIN_DECLS
Macro used prior to declaring functions in the D-Bus header files.
_dbus_groups_from_uid
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.
Definition: dbus-userdb-util.c:388
_dbus_user_database_lock_system
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_user_database_lock_system(void) _DBUS_GNUC_WARN_UNUSED_RESULT
Locks global system user database.
Definition: dbus-userdb.c:306
_dbus_is_console_user
DBUS_PRIVATE_EXPORT 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.
Definition: dbus-userdb-util.c:49
_dbus_user_database_flush_system
void _dbus_user_database_flush_system(void)
Flushes the system global user database;.
Definition: dbus-userdb.c:349
_dbus_homedir_from_username
dbus_bool_t _dbus_homedir_from_username(const DBusString *username, DBusString *homedir)
Gets the home directory for the given user.
Definition: dbus-userdb.c:419
_dbus_user_database_flush
void _dbus_user_database_flush(DBusUserDatabase *db)
Flush all information out of the user database.
Definition: dbus-userdb.c:593
_dbus_user_database_get_uid
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.
Definition: dbus-userdb.c:657
_dbus_user_database_unlock_system
DBUS_PRIVATE_EXPORT void _dbus_user_database_unlock_system(void)
Unlocks global system user database.
Definition: dbus-userdb.c:323
_dbus_user_database_get_groupname
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...
Definition: dbus-userdb-util.c:347
_dbus_user_info_free_allocated
void _dbus_user_info_free_allocated(DBusUserInfo *info)
Frees the given DBusUserInfo&#39;s members with _dbus_user_info_free() and also calls dbus_free() on the ...
Definition: dbus-userdb.c:45
_dbus_user_database_get_system
DBUS_PRIVATE_EXPORT DBusUserDatabase * _dbus_user_database_get_system(void)
Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system(...
Definition: dbus-userdb.c:336
_dbus_homedir_from_uid
dbus_bool_t _dbus_homedir_from_uid(dbus_uid_t uid, DBusString *homedir)
Gets the home directory for the given user.
Definition: dbus-userdb.c:461
_dbus_get_user_id_and_primary_group
DBUS_PRIVATE_EXPORT 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.
Definition: dbus-userdb-util.c:199
_dbus_user_database_get_gid
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.
Definition: dbus-userdb-util.c:367
_dbus_is_a_number
DBUS_PRIVATE_EXPORT 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.
Definition: dbus-userdb.c:103
DBusString
Definition: dbus-string.h:42
_dbus_group_info_free_allocated
void _dbus_group_info_free_allocated(DBusGroupInfo *info)
Frees the given DBusGroupInfo&#39;s members with _dbus_group_info_free() and also calls dbus_free() on th...
Definition: dbus-userdb.c:61
dbus_bool_t
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
_dbus_user_database_lookup_group
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.
Definition: dbus-userdb-util.c:246
_dbus_get_group_id
dbus_bool_t _dbus_get_group_id(const DBusString *group_name, dbus_gid_t *gid)
Gets group ID given groupname.
Definition: dbus-userdb-util.c:160
DBusError
Object representing an exception.
Definition: dbus-errors.h:48
_dbus_user_database_new
DBusUserDatabase * _dbus_user_database_new(void)
Creates a new user database object used to look up and cache user information.
Definition: dbus-userdb.c:550
_dbus_homedir_from_current_process
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_homedir_from_current_process(const DBusString **homedir)
Gets homedir of user owning current process.
Definition: dbus-userdb.c:395
DBusGroupInfo
Information about a UNIX group.
Definition: dbus-sysdeps-unix.h:119
_dbus_get_user_id
dbus_bool_t _dbus_get_user_id(const DBusString *username, dbus_uid_t *uid)
Gets user ID given username.
Definition: dbus-userdb-util.c:146
DBusHashTable
Internals of DBusHashTable.
Definition: dbus-hash.c:168
_dbus_user_database_get_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.
Definition: dbus-userdb.c:676
dbus_gid_t
unsigned long dbus_gid_t
A group ID.
Definition: dbus-sysdeps.h:109
_dbus_user_database_unref
void _dbus_user_database_unref(DBusUserDatabase *db)
Decrements refcount of user database.
Definition: dbus-userdb.c:623
dbus_uid_t
unsigned long dbus_uid_t
A user ID.
Definition: dbus-sysdeps.h:107
_dbus_username_from_current_process
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_username_from_current_process(const DBusString **username)
Gets username of user owning current process.
Definition: dbus-userdb.c:371
DBusUserInfo
Information about a UNIX user.
Definition: dbus-sysdeps-unix.h:106
DBUS_END_DECLS
#define DBUS_END_DECLS
Macro used after declaring functions in the D-Bus header files.