Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MAPPER_H_
00024 #define __MAPPER_H_
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include <config.h>
00028 #endif
00029
00030 #include <sys/types.h>
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <pwd.h>
00034 #include <../common/cert_st.h>
00035 #include "../scconf/scconf.h"
00036
00040 typedef struct mapper_module_st {
00042 const char *name;
00044 scconf_block *block;
00046 int dbg_level;
00048 void *context;
00050 char **(*entries)(X509 *x509, void *context);
00052 char *(*finder)(X509 *x509, void *context, int *match);
00054 int (*matcher)(X509 *x509, const char *login, void *context);
00056 void (*deinit)( void *context);
00057 } mapper_module;
00058
00063 struct mapfile {
00065 const char *uri;
00067 char *buffer;
00069 size_t length;
00071 char *pt;
00073 char *key;
00075 char *value;
00076 };
00077
00078
00079
00088 mapper_module * mapper_module_init(scconf_block *ctx,const char *mapper_name);
00089
00090
00091
00092
00093
00094
00095 #ifndef __MAPPER_C_
00096 #define MAPPER_EXTERN extern
00097 #else
00098 #define MAPPER_EXTERN
00099 #endif
00100
00101
00102
00108 MAPPER_EXTERN struct mapfile *set_mapent(const char *uri);
00109
00115 MAPPER_EXTERN int get_mapent(struct mapfile *mfile);
00116
00121 MAPPER_EXTERN void end_mapent(struct mapfile *mfile);
00122
00131 MAPPER_EXTERN char *mapfile_find(const char *file,char *key,int ignorecase,int *match);
00132
00141 MAPPER_EXTERN int mapfile_match(const char *file,char *key,const char *value,int ignorecase);
00142
00143
00144
00151 MAPPER_EXTERN char *search_pw_entry(const char *item, int ignorecase);
00152
00160 MAPPER_EXTERN int compare_pw_entry(const char *item, struct passwd *pw,int ignorecase);
00161
00162 #undef MAPPER_EXTERN
00163
00164
00165
00174 #define _DEFAULT_MAPPER_FIND_ENTRIES \
00175 static char ** mapper_find_entries(X509 *x509, void *context) { \
00176 return NULL; \
00177 }
00178
00187 #define _DEFAULT_MAPPER_FIND_USER \
00188 static char * mapper_find_user(X509 *x509,void *context,int *match) { \
00189 if ( !x509 ) return NULL; \
00190 *match = 1; \
00191 return "nobody"; \
00192 }
00193
00204 #define _DEFAULT_MAPPER_MATCH_USER \
00205 static int mapper_match_user(X509 *x509, const char *login, void *context) { \
00206 int match = 0; \
00207 char *username= mapper_find_user(x509,context,&match); \
00208 if (!x509) return -1; \
00209 if (!login) return -1; \
00210 if (!username) return 0; \
00211 if ( ! strcmp(login,username) ) return 1; \
00212 return 0; \
00213 }
00214
00219 #define _DEFAULT_MAPPER_END \
00220 static void mapper_module_end(void *context) { \
00221 free(context); \
00222 return; \
00223 } \
00224
00225
00232 #define _DEFAULT_MAPPER_INIT \
00233 mapper_module* mapper_module_init(scconf_block *blk,const char *name) { \
00234 mapper_module *pt= malloc(sizeof (mapper_module)); \
00235 if (!pt) return NULL; \
00236 pt->name = name; \
00237 pt->context = NULL; \
00238 pt->block = blk; \
00239 pt->dbg_level = get_debug_level(); \
00240 pt->entries = mapper_find_entries; \
00241 pt->finder = mapper_find_user; \
00242 pt->matcher = mapper_match_user; \
00243 pt->deinit = mapper_module_end; \
00244 return pt; \
00245 } \
00246
00247
00248 #endif