#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include <../common/cert_st.h>
#include "../scconf/scconf.h"
Go to the source code of this file.
|  | 
| struct | mapper_module_st | 
|  | Structure to be filled on mapper module initialization.  More... 
 | 
|  | 
| struct | mapfile | 
|  | This struct is used in processing map files a map file is a list of "key" " -> " "value" text lines.  More... 
 | 
|  | 
|  | 
| mapper_module * | mapper_module_init (scconf_block *ctx, const char *mapper_name) | 
|  | Initialize module and mapper_module_st structure.  More... 
 | 
|  | 
| MAPPER_EXTERN struct mapfile * | set_mapent (const char *uri) | 
|  | Initialize a mapper entry table.  More... 
 | 
|  | 
| MAPPER_EXTERN int | get_mapent (struct mapfile *mfile) | 
|  | Retrieve next entry of given map file.  More... 
 | 
|  | 
| MAPPER_EXTERN void | end_mapent (struct mapfile *mfile) | 
|  | Release a mapentry structure.  More... 
 | 
|  | 
| MAPPER_EXTERN char * | mapfile_find (const char *file, char *key, int ignorecase, int *match) | 
|  | Try to map "key" to provided mapfile.  More... 
 | 
|  | 
| MAPPER_EXTERN int | mapfile_match (const char *file, char *key, const char *value, int ignorecase) | 
|  | Try to match provided key to provided name by mean of a mapfile.  More... 
 | 
|  | 
| MAPPER_EXTERN char * | search_pw_entry (const char *item, int ignorecase) | 
|  | find the user login that matches pw_name or pw_gecos with provided item  More... 
 | 
|  | 
| MAPPER_EXTERN int | compare_pw_entry (const char *item, struct passwd *pw, int ignorecase) | 
|  | Test if provided item matches pw_name or pw_gecos of provided password structure.  More... 
 | 
|  | 
◆ _DEFAULT_MAPPER_END
      
        
          | #define _DEFAULT_MAPPER_END | 
      
 
Value:static void mapper_module_end(void *context) {                          \
        free(context);                                                  \
        return;                                                         \
}                                                                       \
Macro for de-initialization routine. 
- Parameters
- 
  
  
Definition at line 219 of file mapper.h.
 
 
◆ _DEFAULT_MAPPER_FIND_ENTRIES
      
        
          | #define _DEFAULT_MAPPER_FIND_ENTRIES | 
      
 
Value:static char ** mapper_find_entries(X509 *x509, void *context) {         \
        return NULL;                                                    \
}
Default macro for locate certificate entry. 
Provided as sample for debugging, not for real user 
- Parameters
- 
  
    | x509 | X509 Certificate |  | context | Mapper context |  
 
- Returns
- String array with up to 15 results or NULL if fail 
Definition at line 174 of file mapper.h.
 
 
◆ _DEFAULT_MAPPER_FIND_USER
      
        
          | #define _DEFAULT_MAPPER_FIND_USER | 
      
 
Value:static char * mapper_find_user(X509 *x509,void *context,int *match) {           \
        if ( !x509 ) return NULL;                                       \
        *match = 1;                                                     \
        return "nobody";                                                \
}
Default macro for locating user. 
Should not be used except for debugging, as always returns "nobody" 
- Parameters
- 
  
    | x509 | X509 Certificate |  | context | Mapper context |  
 
- Returns
- Found user, or NULL 
Definition at line 187 of file mapper.h.
 
 
◆ _DEFAULT_MAPPER_INIT
      
        
          | #define _DEFAULT_MAPPER_INIT | 
      
 
Value:        if (!pt) return NULL;                                           \
        pt->name    = name;                                             \
        pt->context = NULL;                                             \
        pt->block   = blk;                                              \
        pt->entries = mapper_find_entries;                              \
        pt->finder  = mapper_find_user;                                 \
        pt->matcher = mapper_match_user;                                \
        pt->deinit  = mapper_module_end;                        \
        return pt;                                                      \
}                                                                       \
mapper_module * mapper_module_init(scconf_block *ctx, const char *mapper_name)
Initialize module and mapper_module_st structure. 
Structure to be filled on mapper module initialization. 
DEBUG_EXTERN int get_debug_level(void)
get_debug_level() Returns the current debug level. 
Macro for default init function. 
- Parameters
- 
  
    | blk | Mapper Configuration file block |  | name | Name of this mapper |  
 
- Returns
- pointer to mapper_module data, else NULL NOTE: mapper module data MUST BE defined in module 
Definition at line 232 of file mapper.h.
 
 
◆ _DEFAULT_MAPPER_MATCH_USER
      
        
          | #define _DEFAULT_MAPPER_MATCH_USER | 
      
 
Value:static int mapper_match_user(X509 *x509, const char *login, void *context) { \
        int match = 0;                                                  \
        char *username= mapper_find_user(x509,context,&match);          \
        if (!x509) return -1;                                           \
        if (!login) return -1;                                          \
        if (!username) return 0;                      \
        if ( ! strcmp(login,username) ) return 1;       \
        return 0;                                         \
}
Macro for match mapper function. 
- Parameters
- 
  
    | x509 | X509 Certificate |  | login | user to match, or null to find user that matches certificate |  | context | Mapper context |  
 
- Returns
- 1 on success; login points to matched user 0 on no match -1 on error 
Definition at line 204 of file mapper.h.
 
 
◆ MAPPER_EXTERN
      
        
          | #define MAPPER_EXTERN   extern | 
      
 
 
◆ mapper_module
Structure to be filled on mapper module initialization. 
 
 
◆ compare_pw_entry()
      
        
          | MAPPER_EXTERN int compare_pw_entry | ( | const char * | item, | 
        
          |  |  | struct passwd * | pw, | 
        
          |  |  | int | ignorecase | 
        
          |  | ) |  |  | 
      
 
Test if provided item matches pw_name or pw_gecos of provided password structure. 
- Parameters
- 
  
    | item | String to be compared |  | pw | password entry to search into |  | ignorecase | Flag to check upper/lowercase in string comparisions |  
 
- Returns
- 1 on match, 0 on no match, -1 on error 
 
 
◆ end_mapent()
Release a mapentry structure. 
- Parameters
- 
  
    | mfile | Map file structure to be released |  
 
 
 
◆ get_mapent()
Retrieve next entry of given map file. 
- Parameters
- 
  
    | mfile | Map file entry pointer |  
 
- Returns
- 1 on sucess, 0 on no more entries, -1 on error 
 
 
◆ mapfile_find()
      
        
          | MAPPER_EXTERN char* mapfile_find | ( | const char * | file, | 
        
          |  |  | char * | key, | 
        
          |  |  | int | ignorecase, | 
        
          |  |  | int * | match | 
        
          |  | ) |  |  | 
      
 
Try to map "key" to provided mapfile. 
- Parameters
- 
  
    | file | URL of map file |  | key | String to be mapped |  | ignorecase | Flag to indicate upper/lowercase ignore in string compare |  | match | Set to 1 for mapped string return, unmodified for key return |  
 
- Returns
- key on no match, else a clone_str()'d of found mapping 
 
 
◆ mapfile_match()
      
        
          | MAPPER_EXTERN int mapfile_match | ( | const char * | file, | 
        
          |  |  | char * | key, | 
        
          |  |  | const char * | value, | 
        
          |  |  | int | ignorecase | 
        
          |  | ) |  |  | 
      
 
Try to match provided key to provided name by mean of a mapfile. 
- Parameters
- 
  
    | file | URL of map file |  | key | String to be mapped |  | value | String to be matched against mapped result |  | ignorecase | Flag to indicate upper/lowercase ignore in string compare |  
 
- Returns
- 1 on match, 0 on no match, -1 on process error 
 
 
◆ mapper_module_init()
Initialize module and mapper_module_st structure. 
EVERY mapper module MUST provide and export this function if dinamycally linked 
- Parameters
- 
  
    | ctx | Pointer to related configuration file context |  | mapper_name | Name of this mapper. Used for multi-mapper modules |  
 
- Returns
- Pointer to a mapper_module structure, or NULL if failed 
 
 
◆ search_pw_entry()
      
        
          | MAPPER_EXTERN char* search_pw_entry | ( | const char * | item, | 
        
          |  |  | int | ignorecase | 
        
          |  | ) |  |  | 
      
 
find the user login that matches pw_name or pw_gecos with provided item 
- Parameters
- 
  
    | item | Data to be searched from password database |  | ignorecase | Flag to check upper/lowercase in string comparisions |  
 
- Returns
- userlogin if match found, else NULL 
 
 
◆ set_mapent()
Initialize a mapper entry table. 
- Parameters
- 
  
    | uri | Universal Resource Locator of the file to be mapped |  
 
- Returns
- A mapfile structure pointer or NULL