D-Bus  1.10.12
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  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_PRIVATE_EXPORT
00060 dbus_bool_t       _dbus_user_database_get_uid       (DBusUserDatabase     *db,
00061                                                      dbus_uid_t            uid,
00062                                                      const DBusUserInfo  **info,
00063                                                      DBusError            *error);
00064 dbus_bool_t       _dbus_user_database_get_gid       (DBusUserDatabase     *db,
00065                                                      dbus_gid_t            gid,
00066                                                      const DBusGroupInfo **info,
00067                                                      DBusError            *error);
00068 DBUS_PRIVATE_EXPORT
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 DBUS_PRIVATE_EXPORT
00079 DBusUserInfo*  _dbus_user_database_lookup       (DBusUserDatabase *db,
00080                                                  dbus_uid_t        uid,
00081                                                  const DBusString *username,
00082                                                  DBusError        *error);
00083 DBUS_PRIVATE_EXPORT
00084 DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
00085                                                  dbus_gid_t        gid,
00086                                                  const DBusString *groupname,
00087                                                  DBusError        *error);
00088 DBUS_PRIVATE_EXPORT
00089 void           _dbus_user_info_free_allocated   (DBusUserInfo     *info);
00090 DBUS_PRIVATE_EXPORT
00091 void           _dbus_group_info_free_allocated  (DBusGroupInfo    *info);
00092 #endif /* DBUS_USERDB_INCLUDES_PRIVATE */
00093 
00094 DBUS_PRIVATE_EXPORT
00095 DBusUserDatabase* _dbus_user_database_get_system    (void);
00096 DBUS_PRIVATE_EXPORT
00097 dbus_bool_t       _dbus_user_database_lock_system   (void) _DBUS_GNUC_WARN_UNUSED_RESULT;
00098 DBUS_PRIVATE_EXPORT
00099 void              _dbus_user_database_unlock_system (void);
00100 void              _dbus_user_database_flush_system  (void);
00101 
00102 dbus_bool_t _dbus_get_user_id                   (const DBusString  *username,
00103                                                  dbus_uid_t        *uid);
00104 dbus_bool_t _dbus_get_group_id                  (const DBusString  *group_name,
00105                                                  dbus_gid_t        *gid);
00106 DBUS_PRIVATE_EXPORT
00107 dbus_bool_t _dbus_get_user_id_and_primary_group (const DBusString  *username,
00108                                                  dbus_uid_t        *uid_p,
00109                                                  dbus_gid_t        *gid_p);
00110 dbus_bool_t _dbus_credentials_from_uid          (dbus_uid_t         user_id,
00111                                                  DBusCredentials   *credentials);
00112 dbus_bool_t _dbus_groups_from_uid               (dbus_uid_t            uid,
00113                                                  dbus_gid_t          **group_ids,
00114                                                  int                  *n_group_ids);
00115 DBUS_PRIVATE_EXPORT
00116 dbus_bool_t _dbus_is_console_user               (dbus_uid_t         uid,
00117                                                  DBusError         *error);
00118 
00119 DBUS_PRIVATE_EXPORT
00120 dbus_bool_t _dbus_is_a_number                   (const DBusString *str, 
00121                                                  unsigned long    *num);
00122 
00123 DBUS_PRIVATE_EXPORT
00124 dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
00125 DBUS_PRIVATE_EXPORT
00126 dbus_bool_t _dbus_homedir_from_current_process  (const DBusString **homedir);
00127 dbus_bool_t _dbus_homedir_from_username         (const DBusString  *username,
00128                                                  DBusString        *homedir);
00129 
00130 dbus_bool_t _dbus_homedir_from_uid              (dbus_uid_t         uid,
00131                                                  DBusString        *homedir);
00132 
00133 DBUS_END_DECLS
00134 
00135 #endif /* DBUS_USERDB_H */