2003-12-02 Richard Hult <richard@imendio.com>
[platform/upstream/dbus.git] / dbus / dbus-userdb.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
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.0
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #ifndef DBUS_USERDB_H
25 #define DBUS_USERDB_H
26
27 #include <dbus/dbus-sysdeps.h>
28
29 DBUS_BEGIN_DECLS;
30
31 typedef struct DBusUserDatabase DBusUserDatabase;
32
33 DBusUserDatabase* _dbus_user_database_new           (void);
34 DBusUserDatabase* _dbus_user_database_ref           (DBusUserDatabase     *db);
35 void              _dbus_user_database_unref         (DBusUserDatabase     *db);
36 dbus_bool_t       _dbus_user_database_get_groups    (DBusUserDatabase     *db,
37                                                      dbus_uid_t            uid,
38                                                      dbus_gid_t          **group_ids,
39                                                      int                  *n_group_ids,
40                                                      DBusError            *error);
41 dbus_bool_t       _dbus_user_database_get_uid       (DBusUserDatabase     *db,
42                                                      dbus_uid_t            uid,
43                                                      const DBusUserInfo  **info,
44                                                      DBusError            *error);
45 dbus_bool_t       _dbus_user_database_get_gid       (DBusUserDatabase     *db,
46                                                      dbus_gid_t            gid,
47                                                      const DBusGroupInfo **info,
48                                                      DBusError            *error);
49 dbus_bool_t       _dbus_user_database_get_username  (DBusUserDatabase     *db,
50                                                      const DBusString     *username,
51                                                      const DBusUserInfo  **info,
52                                                      DBusError            *error);
53 dbus_bool_t       _dbus_user_database_get_groupname (DBusUserDatabase     *db,
54                                                      const DBusString     *groupname,
55                                                      const DBusGroupInfo **info,
56                                                      DBusError            *error);
57
58
59
60 DBusUserDatabase* _dbus_user_database_get_system    (void);
61 void              _dbus_user_database_lock_system   (void);
62 void              _dbus_user_database_unlock_system (void);
63
64 dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
65 dbus_bool_t _dbus_homedir_from_current_process  (const DBusString **homedir);
66 dbus_bool_t _dbus_homedir_from_username         (const DBusString  *username,
67                                                  DBusString        *homedir);
68 dbus_bool_t _dbus_get_user_id                   (const DBusString  *username,
69                                                  dbus_uid_t        *uid);
70 dbus_bool_t _dbus_get_group_id                  (const DBusString  *group_name,
71                                                  dbus_gid_t        *gid);
72 dbus_bool_t _dbus_uid_from_string               (const DBusString  *uid_str,
73                                                  dbus_uid_t        *uid);
74 dbus_bool_t _dbus_credentials_from_username     (const DBusString  *username,
75                                                  DBusCredentials   *credentials);
76 dbus_bool_t _dbus_credentials_from_uid          (dbus_uid_t         user_id,
77                                                  DBusCredentials   *credentials);
78
79
80 DBUS_END_DECLS;
81
82 #endif /* DBUS_USERDB_H */