dbus-userdb.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* dbus-userdb.h User database abstraction
00003  * 
00004  * Copyright (C) 2003  Red Hat, Inc.
00005  *
00006  * Licensed under the Academic Free License version 2.1
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 #ifndef DBUS_USERDB_H
00025 #define DBUS_USERDB_H
00026 
00027 #include <dbus/dbus-sysdeps.h>
00028 
00029 DBUS_BEGIN_DECLS
00030 
00031 typedef struct DBusUserDatabase DBusUserDatabase;
00032 
00033 #ifdef DBUS_USERDB_INCLUDES_PRIVATE
00034 #include <dbus/dbus-hash.h>
00035 
00039 struct DBusUserDatabase
00040 {
00041   int refcount; 
00043   DBusHashTable *users; 
00044   DBusHashTable *groups; 
00045   DBusHashTable *users_by_name; 
00046   DBusHashTable *groups_by_name; 
00048 };
00049 
00050 #endif /* DBUS_USERDB_INCLUDES_PRIVATE */
00051 
00052 DBusUserDatabase* _dbus_user_database_new           (void);
00053 DBusUserDatabase* _dbus_user_database_ref           (DBusUserDatabase     *db);
00054 void              _dbus_user_database_flush         (DBusUserDatabase     *db);
00055 void              _dbus_user_database_unref         (DBusUserDatabase     *db);
00056 dbus_bool_t       _dbus_user_database_get_groups    (DBusUserDatabase     *db,
00057                                                      dbus_uid_t            uid,
00058                                                      dbus_gid_t          **group_ids,
00059                                                      int                  *n_group_ids,
00060                                                      DBusError            *error);
00061 dbus_bool_t       _dbus_user_database_get_uid       (DBusUserDatabase     *db,
00062                                                      dbus_uid_t            uid,
00063                                                      const DBusUserInfo  **info,
00064                                                      DBusError            *error);
00065 dbus_bool_t       _dbus_user_database_get_gid       (DBusUserDatabase     *db,
00066                                                      dbus_gid_t            gid,
00067                                                      const DBusGroupInfo **info,
00068                                                      DBusError            *error);
00069 dbus_bool_t       _dbus_user_database_get_username  (DBusUserDatabase     *db,
00070                                                      const DBusString     *username,
00071                                                      const DBusUserInfo  **info,
00072                                                      DBusError            *error);
00073 dbus_bool_t       _dbus_user_database_get_groupname (DBusUserDatabase     *db,
00074                                                      const DBusString     *groupname,
00075                                                      const DBusGroupInfo **info,
00076                                                      DBusError            *error);
00077 
00078 #ifdef DBUS_USERDB_INCLUDES_PRIVATE
00079 DBusUserInfo*  _dbus_user_database_lookup       (DBusUserDatabase *db,
00080                                                  dbus_uid_t        uid,
00081                                                  const DBusString *username,
00082                                                  DBusError        *error);
00083 DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
00084                                                  dbus_gid_t        gid,
00085                                                  const DBusString *groupname,
00086                                                  DBusError        *error);
00087 void           _dbus_user_info_free_allocated   (DBusUserInfo     *info);
00088 void           _dbus_group_info_free_allocated  (DBusGroupInfo    *info);
00089 #endif /* DBUS_USERDB_INCLUDES_PRIVATE */
00090 
00091 DBusUserDatabase* _dbus_user_database_get_system    (void);
00092 void              _dbus_user_database_lock_system   (void);
00093 void              _dbus_user_database_unlock_system (void);
00094 
00095 dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
00096 dbus_bool_t _dbus_homedir_from_current_process  (const DBusString **homedir);
00097 dbus_bool_t _dbus_homedir_from_username         (const DBusString  *username,
00098                                                  DBusString        *homedir);
00099 dbus_bool_t _dbus_get_user_id                   (const DBusString  *username,
00100                                                  dbus_uid_t        *uid);
00101 dbus_bool_t _dbus_get_group_id                  (const DBusString  *group_name,
00102                                                  dbus_gid_t        *gid);
00103 dbus_bool_t _dbus_credentials_from_username     (const DBusString  *username,
00104                                                  DBusCredentials   *credentials);
00105 dbus_bool_t _dbus_credentials_from_uid          (dbus_uid_t         user_id,
00106                                                  DBusCredentials   *credentials);
00107 dbus_bool_t _dbus_is_console_user               (dbus_uid_t         uid,
00108                                                  DBusError         *error);
00109 
00110 dbus_bool_t _dbus_is_a_number                   (const DBusString *str, 
00111                                                  unsigned long    *num);
00112 
00113 
00114 DBUS_END_DECLS
00115 
00116 #endif /* DBUS_USERDB_H */

Generated on Tue Apr 15 15:54:04 2008 for D-Bus by  doxygen 1.5.1