dbus-userdb.h

00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
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-unix.h>
00028 
00029 #ifdef DBUS_WIN
00030 #error "Don't include this on Windows"
00031 #endif
00032 
00033 DBUS_BEGIN_DECLS
00034 
00035 typedef struct DBusUserDatabase DBusUserDatabase;
00036 
00037 #ifdef DBUS_USERDB_INCLUDES_PRIVATE
00038 #include <dbus/dbus-hash.h>
00039 
00043 struct DBusUserDatabase
00044 {
00045   int refcount; 
00047   DBusHashTable *users; 
00048   DBusHashTable *groups; 
00049   DBusHashTable *users_by_name; 
00050   DBusHashTable *groups_by_name; 
00052 };
00053 
00054 
00055 DBusUserDatabase* _dbus_user_database_new           (void);
00056 DBusUserDatabase* _dbus_user_database_ref           (DBusUserDatabase     *db);
00057 void              _dbus_user_database_flush         (DBusUserDatabase     *db);
00058 void              _dbus_user_database_unref         (DBusUserDatabase     *db);
00059 dbus_bool_t       _dbus_user_database_get_uid       (DBusUserDatabase     *db,
00060                                                      dbus_uid_t            uid,
00061                                                      const DBusUserInfo  **info,
00062                                                      DBusError            *error);
00063 dbus_bool_t       _dbus_user_database_get_gid       (DBusUserDatabase     *db,
00064                                                      dbus_gid_t            gid,
00065                                                      const DBusGroupInfo **info,
00066                                                      DBusError            *error);
00067 dbus_bool_t       _dbus_user_database_get_username  (DBusUserDatabase     *db,
00068                                                      const DBusString     *username,
00069                                                      const DBusUserInfo  **info,
00070                                                      DBusError            *error);
00071 dbus_bool_t       _dbus_user_database_get_groupname (DBusUserDatabase     *db,
00072                                                      const DBusString     *groupname,
00073                                                      const DBusGroupInfo **info,
00074                                                      DBusError            *error);
00075 
00076 DBusUserInfo*  _dbus_user_database_lookup       (DBusUserDatabase *db,
00077                                                  dbus_uid_t        uid,
00078                                                  const DBusString *username,
00079                                                  DBusError        *error);
00080 DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
00081                                                  dbus_gid_t        gid,
00082                                                  const DBusString *groupname,
00083                                                  DBusError        *error);
00084 void           _dbus_user_info_free_allocated   (DBusUserInfo     *info);
00085 void           _dbus_group_info_free_allocated  (DBusGroupInfo    *info);
00086 #endif /* DBUS_USERDB_INCLUDES_PRIVATE */
00087 
00088 DBusUserDatabase* _dbus_user_database_get_system    (void);
00089 void              _dbus_user_database_lock_system   (void);
00090 void              _dbus_user_database_unlock_system (void);
00091 void              _dbus_user_database_flush_system  (void);
00092 
00093 dbus_bool_t _dbus_get_user_id                   (const DBusString  *username,
00094                                                  dbus_uid_t        *uid);
00095 dbus_bool_t _dbus_get_group_id                  (const DBusString  *group_name,
00096                                                  dbus_gid_t        *gid);
00097 dbus_bool_t _dbus_get_user_id_and_primary_group (const DBusString  *username,
00098                                                  dbus_uid_t        *uid_p,
00099                                                  dbus_gid_t        *gid_p);
00100 dbus_bool_t _dbus_credentials_from_uid          (dbus_uid_t         user_id,
00101                                                  DBusCredentials   *credentials);
00102 dbus_bool_t _dbus_groups_from_uid               (dbus_uid_t            uid,
00103                                                  dbus_gid_t          **group_ids,
00104                                                  int                  *n_group_ids);
00105 dbus_bool_t _dbus_is_console_user               (dbus_uid_t         uid,
00106                                                  DBusError         *error);
00107 
00108 dbus_bool_t _dbus_is_a_number                   (const DBusString *str, 
00109                                                  unsigned long    *num);
00110 
00111 dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
00112 dbus_bool_t _dbus_homedir_from_current_process  (const DBusString **homedir);
00113 dbus_bool_t _dbus_homedir_from_username         (const DBusString  *username,
00114                                                  DBusString        *homedir);
00115 
00116 dbus_bool_t _dbus_homedir_from_uid              (dbus_uid_t         uid,
00117                                                  DBusString        *homedir);
00118 
00119 DBUS_END_DECLS
00120 
00121 #endif /* DBUS_USERDB_H */

Generated on Sat Dec 6 19:43:44 2008 for D-Bus by  doxygen 1.5.1