1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-userdb.h User database abstraction
4 * Copyright (C) 2003 Red Hat, Inc.
6 * Licensed under the Academic Free License version 2.1
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <dbus/dbus-sysdeps.h>
31 typedef struct DBusUserDatabase DBusUserDatabase;
33 #ifdef DBUS_USERDB_INCLUDES_PRIVATE
34 #include <dbus/dbus-hash.h>
37 * Internals of DBusUserDatabase
39 struct DBusUserDatabase
41 int refcount; /**< Reference count */
43 DBusHashTable *users; /**< Users in the database by UID */
44 DBusHashTable *groups; /**< Groups in the database by GID */
45 DBusHashTable *users_by_name; /**< Users in the database by name */
46 DBusHashTable *groups_by_name; /**< Groups in the database by name */
50 #endif /* DBUS_USERDB_INCLUDES_PRIVATE */
52 DBusUserDatabase* _dbus_user_database_new (void);
53 DBusUserDatabase* _dbus_user_database_ref (DBusUserDatabase *db);
54 void _dbus_user_database_unref (DBusUserDatabase *db);
55 dbus_bool_t _dbus_user_database_get_groups (DBusUserDatabase *db,
57 dbus_gid_t **group_ids,
60 dbus_bool_t _dbus_user_database_get_uid (DBusUserDatabase *db,
62 const DBusUserInfo **info,
64 dbus_bool_t _dbus_user_database_get_gid (DBusUserDatabase *db,
66 const DBusGroupInfo **info,
68 dbus_bool_t _dbus_user_database_get_username (DBusUserDatabase *db,
69 const DBusString *username,
70 const DBusUserInfo **info,
72 dbus_bool_t _dbus_user_database_get_groupname (DBusUserDatabase *db,
73 const DBusString *groupname,
74 const DBusGroupInfo **info,
77 #ifdef DBUS_USERDB_INCLUDES_PRIVATE
78 DBusUserInfo* _dbus_user_database_lookup (DBusUserDatabase *db,
80 const DBusString *username,
82 DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
84 const DBusString *groupname,
86 void _dbus_user_info_free_allocated (DBusUserInfo *info);
87 void _dbus_group_info_free_allocated (DBusGroupInfo *info);
88 #endif /* DBUS_USERDB_INCLUDES_PRIVATE */
90 DBusUserDatabase* _dbus_user_database_get_system (void);
91 void _dbus_user_database_lock_system (void);
92 void _dbus_user_database_unlock_system (void);
94 dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
95 dbus_bool_t _dbus_homedir_from_current_process (const DBusString **homedir);
96 dbus_bool_t _dbus_homedir_from_username (const DBusString *username,
98 dbus_bool_t _dbus_get_user_id (const DBusString *username,
100 dbus_bool_t _dbus_get_group_id (const DBusString *group_name,
102 dbus_bool_t _dbus_credentials_from_username (const DBusString *username,
103 DBusCredentials *credentials);
104 dbus_bool_t _dbus_credentials_from_uid (dbus_uid_t user_id,
105 DBusCredentials *credentials);
106 dbus_bool_t _dbus_is_console_user (dbus_uid_t uid,
112 #endif /* DBUS_USERDB_H */