D-Bus 1.14.10
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
34
35typedef struct DBusUserDatabase DBusUserDatabase;
36
37#ifdef DBUS_USERDB_INCLUDES_PRIVATE
38#include <dbus/dbus-hash.h>
39
43struct DBusUserDatabase
44{
45 int refcount;
47 DBusHashTable *users;
48 DBusHashTable *groups;
49 DBusHashTable *users_by_name;
50 DBusHashTable *groups_by_name;
52};
53
54
55DBusUserDatabase* _dbus_user_database_new (void);
56DBusUserDatabase* _dbus_user_database_ref (DBusUserDatabase *db);
57void _dbus_user_database_flush (DBusUserDatabase *db);
58void _dbus_user_database_unref (DBusUserDatabase *db);
59DBUS_PRIVATE_EXPORT
60dbus_bool_t _dbus_user_database_get_uid (DBusUserDatabase *db,
61 dbus_uid_t uid,
62 const DBusUserInfo **info,
63 DBusError *error);
64DBUS_PRIVATE_EXPORT
66 const DBusString *username,
67 const DBusUserInfo **info,
68 DBusError *error);
69DBUS_PRIVATE_EXPORT
70const DBusUserInfo *_dbus_user_database_lookup (DBusUserDatabase *db,
71 dbus_uid_t uid,
72 const DBusString *username,
73 DBusError *error);
74DBUS_PRIVATE_EXPORT
75const DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
76 dbus_gid_t gid,
77 const DBusString *groupname,
78 DBusError *error);
79
81DBUS_PRIVATE_EXPORT
83#endif /* DBUS_USERDB_INCLUDES_PRIVATE */
84
85DBUS_PRIVATE_EXPORT
86DBusUserDatabase* _dbus_user_database_get_system (void);
87DBUS_PRIVATE_EXPORT _DBUS_WARN_UNUSED_RESULT
89DBUS_PRIVATE_EXPORT
92
94 dbus_uid_t *uid);
96 dbus_gid_t *gid);
97DBUS_PRIVATE_EXPORT
99 dbus_uid_t *uid_p,
100 dbus_gid_t *gid_p);
102 dbus_gid_t **group_ids,
103 int *n_group_ids,
104 DBusError *error);
105DBUS_PRIVATE_EXPORT
107 DBusError *error);
108
109DBUS_PRIVATE_EXPORT
111 unsigned long *num);
112
113DBUS_PRIVATE_EXPORT
115DBUS_PRIVATE_EXPORT
118 DBusString *homedir);
119
121
122#endif /* DBUS_USERDB_H */
DBUS_PRIVATE_EXPORT _DBUS_WARN_UNUSED_RESULT dbus_bool_t _dbus_user_database_lock_system(void)
Locks global system user database.
Definition: dbus-userdb.c:351
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:440
DBusUserDatabase * _dbus_user_database_new(void)
Creates a new user database object used to look up and cache user information.
Definition: dbus-userdb.c:596
DBUS_PRIVATE_EXPORT void _dbus_user_database_unlock_system(void)
Unlocks global system user database.
Definition: dbus-userdb.c:368
void _dbus_user_database_unref(DBusUserDatabase *db)
Decrements refcount of user database.
Definition: dbus-userdb.c:669
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:703
void _dbus_user_database_flush_system(void)
Flushes the system global user database;.
Definition: dbus-userdb.c:394
dbus_bool_t _dbus_get_group_id(const DBusString *group_name, dbus_gid_t *gid)
Gets group ID given groupname.
void _dbus_group_info_unref(DBusGroupInfo *info)
Decrements the reference count.
Definition: dbus-userdb.c:85
const 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:158
void _dbus_user_info_unref(DBusUserInfo *info)
Decrements the reference count.
Definition: dbus-userdb.c:62
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:416
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.
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.
void _dbus_user_database_flush(DBusUserDatabase *db)
Flush all information out of the user database.
Definition: dbus-userdb.c:639
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_homedir_from_uid(dbus_uid_t uid, DBusString *homedir)
Gets the home directory for the given user.
Definition: dbus-userdb.c:464
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.
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:722
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:133
dbus_bool_t _dbus_get_user_id(const DBusString *username, dbus_uid_t *uid)
Gets user ID given username.
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:381
#define DBUS_BEGIN_DECLS
Macro used prior to declaring functions in the D-Bus header files.
#define DBUS_END_DECLS
Macro used after declaring functions in the D-Bus header files.
unsigned long dbus_uid_t
A user ID.
Definition: dbus-sysdeps.h:137
unsigned long dbus_gid_t
A group ID.
Definition: dbus-sysdeps.h:139
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
Object representing an exception.
Definition: dbus-errors.h:49
Information about a UNIX group.
Internals of DBusHashTable.
Definition: dbus-hash.c:174
Information about a UNIX user.