1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <dbus/dbus-sysdeps-unix.h>
30 #error "Don't include this on Windows"
35 typedef struct DBusUserDatabase DBusUserDatabase;
37 #ifdef DBUS_USERDB_INCLUDES_PRIVATE
38 #include <dbus/dbus-hash.h>
41 * Internals of DBusUserDatabase
43 struct DBusUserDatabase
45 int refcount; /**< Reference count */
47 DBusHashTable *users; /**< Users in the database by UID */
48 DBusHashTable *groups; /**< Groups in the database by GID */
49 DBusHashTable *users_by_name; /**< Users in the database by name */
50 DBusHashTable *groups_by_name; /**< Groups in the database by name */
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);
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,
69 dbus_bool_t _dbus_user_database_get_username (DBusUserDatabase *db,
70 const DBusString *username,
71 const DBusUserInfo **info,
73 dbus_bool_t _dbus_user_database_get_groupname (DBusUserDatabase *db,
74 const DBusString *groupname,
75 const DBusGroupInfo **info,
79 const DBusUserInfo *_dbus_user_database_lookup (DBusUserDatabase *db,
81 const DBusString *username,
84 const DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
86 const DBusString *groupname,
89 void _dbus_user_info_unref (DBusUserInfo *info);
91 void _dbus_group_info_unref (DBusGroupInfo *info);
92 #endif /* DBUS_USERDB_INCLUDES_PRIVATE */
95 DBusUserDatabase* _dbus_user_database_get_system (void);
97 dbus_bool_t _dbus_user_database_lock_system (void) _DBUS_GNUC_WARN_UNUSED_RESULT;
99 void _dbus_user_database_unlock_system (void);
100 void _dbus_user_database_flush_system (void);
102 dbus_bool_t _dbus_get_user_id (const DBusString *username,
104 dbus_bool_t _dbus_get_group_id (const DBusString *group_name,
107 dbus_bool_t _dbus_get_user_id_and_primary_group (const DBusString *username,
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,
116 dbus_bool_t _dbus_is_console_user (dbus_uid_t uid,
120 dbus_bool_t _dbus_is_a_number (const DBusString *str,
124 dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
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);
130 dbus_bool_t _dbus_homedir_from_uid (dbus_uid_t uid,
131 DBusString *homedir);
135 #endif /* DBUS_USERDB_H */