00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef libuser_user_private_h
00026 #define libuser_user_private_h
00027
00028 #include <glib.h>
00029 #include <gmodule.h>
00030 #include "user.h"
00031
00032 #define LU_ENT_MAGIC 0x19d381c2
00033 #define LU_MODULE_VERSION 0x00050000
00034
00035 #include <libintl.h>
00036 #include <locale.h>
00037 #define _(String) gettext(String)
00038
00039
00040
00041 typedef struct lu_string_cache {
00042 GTree *tree;
00043 char * (*cache)(struct lu_string_cache *, const char *);
00044 void (*free)(struct lu_string_cache *);
00045 } lu_string_cache_t;
00046
00054 struct lu_string_cache *lu_string_cache_new(gboolean case_sensitive);
00055
00056
00057 struct lu_ent {
00058 u_int32_t magic;
00059 enum lu_type type;
00060 struct lu_string_cache *acache;
00061 struct lu_string_cache *vcache;
00062 GTree *original_attributes;
00063
00064 GTree *attributes;
00065
00066 const char *source_info;
00067
00068 const char *source_auth;
00069
00070 };
00071
00072
00073 struct lu_context {
00074 struct lu_string_cache *scache;
00075 char *auth_name;
00076
00077
00078 enum lu_type auth_type;
00079
00080 void *config;
00081
00082 lu_prompt_fn *prompter;
00083 gpointer prompter_data;
00084
00085 GList *auth_module_names;
00086
00087 GList *info_module_names;
00088
00089 GTree *modules;
00090
00091 };
00092
00093
00094 typedef enum lu_module_type {
00095 auth = 0xca20,
00096 info = 0xec33,
00097 } lu_module_type_t;
00098
00099
00100 typedef struct lu_module {
00101 u_int32_t version;
00102 GModule *module_handle;
00103 struct lu_string_cache *scache;
00104 const char *name;
00105 struct lu_context *lu_context;
00106 void *module_context;
00107
00108
00109 gboolean (*user_lookup_name)(struct lu_module *module, gconstpointer name, struct lu_ent *ent, struct lu_error **error);
00110 gboolean (*group_lookup_name)(struct lu_module *module, gconstpointer name, struct lu_ent *ent, struct lu_error **error);
00111 gboolean (*user_lookup_id)(struct lu_module *module, gconstpointer uid, struct lu_ent *ent, struct lu_error **error);
00112 gboolean (*group_lookup_id)(struct lu_module *module, gconstpointer gid, struct lu_ent *ent, struct lu_error **error);
00113
00114
00115 gboolean (*user_add)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00116 gboolean (*user_mod)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00117 gboolean (*user_del)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00118
00119
00120 gboolean (*user_lock)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00121 gboolean (*user_unlock)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00122 gboolean (*user_islocked)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00123 gboolean (*user_setpass)(struct lu_module *module, struct lu_ent *ent, const char *newpass, struct lu_error **error);
00124
00125
00126 gboolean (*group_add)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00127 gboolean (*group_mod)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00128 gboolean (*group_del)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00129
00130
00131 gboolean (*group_lock)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00132 gboolean (*group_unlock)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00133 gboolean (*group_islocked)(struct lu_module *module, struct lu_ent *ent, struct lu_error **error);
00134 gboolean (*group_setpass)(struct lu_module *module, struct lu_ent *ent, const char *newpass, struct lu_error **error);
00135
00136
00137 GList *(*users_enumerate)(struct lu_module *module, const char *pattern, struct lu_error **error);
00138 GList *(*groups_enumerate)(struct lu_module *module, const char *pattern, struct lu_error **error);
00139 GList *(*users_enumerate_by_group)(struct lu_module *module, const char *group, gid_t gid, struct lu_error **error);
00140 GList *(*groups_enumerate_by_user)(struct lu_module *module, const char *user, struct lu_error **error);
00141
00142
00143 gboolean (*close)(struct lu_module *module);
00144 } lu_module_t;
00145
00146
00147
00148
00149
00150 typedef struct lu_module * (*lu_module_init_t)(struct lu_context *context, struct lu_error **error);
00151
00152 gboolean lu_cfg_init(struct lu_context *context, struct lu_error **error);
00153 void lu_cfg_done(struct lu_context *context);
00154
00155 void lu_ent_set_source_info(struct lu_ent *ent, const char *source);
00156 void lu_ent_set_source_auth(struct lu_ent *ent, const char *source);
00157
00158 GList *lu_g_list_copy(GList *list);
00159
00160 gint lu_str_equal(gconstpointer v1, gconstpointer v2);
00161 gint lu_str_case_equal(gconstpointer v1, gconstpointer v2);
00162 gint lu_strcmp(gconstpointer v1, gconstpointer v2);
00163 gint lu_strcasecmp(gconstpointer v1, gconstpointer v2);
00164
00165 guint lu_strv_len(gchar **v);
00166
00167 const char *lu_make_crypted(const char *plain, const char *previous);
00168
00169 gpointer lu_util_lock_obtain(int fd, struct lu_error **error);
00170 void lu_util_lock_free(int fd, gpointer lock);
00171
00172 char *lu_util_line_get_matching1(int fd, const char *firstpart, struct lu_error **error);
00173 char *lu_util_line_get_matching3(int fd, const char *thirdpart, struct lu_error **error);
00174 char *lu_util_line_get_matchingx(int fd, const char *part, int field, struct lu_error **error);
00175 char *lu_util_field_read(int fd, const char *first, unsigned int field, struct lu_error **error);
00176 gboolean lu_util_field_write(int fd, const char *first, unsigned int field, const char *value, struct lu_error **error);
00177 char *lu_util_shadow_current_date(struct lu_string_cache *cache);
00178
00179 #endif