Changeset 21 in openpam
- Timestamp:
- Feb 2, 2002, 6:37:08 PM (19 years ago)
- Location:
- trunk/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Makefile
r16 r21 46 46 SRCS += openpam_dispatch.c 47 47 SRCS += openpam_findenv.c 48 SRCS += openpam_load.c 48 49 SRCS += openpam_log.c 49 50 SRCS += openpam_ttyconv.c -
trunk/lib/openpam_impl.h
r20 r21 111 111 int openpam_dispatch(pam_handle_t *, int, int); 112 112 int openpam_findenv(pam_handle_t *, const char *, size_t); 113 int openpam_add_module(pam_handle_t *, int, int, 114 const char *, const char *); 115 void openpam_clear_chains(pam_handle_t *); 113 116 114 117 #endif -
trunk/lib/pam_end.c
r18 r21 35 35 */ 36 36 37 #include <dlfcn.h>38 37 #include <stdlib.h> 39 38 … … 53 52 int status) 54 53 { 55 pam_chain_t *module;56 54 pam_data_t *dp; 57 55 int i; … … 75 73 76 74 /* clear chains */ 77 for (i = 0; i < PAM_NUM_CHAINS; ++i) { 78 while (pamh->chains[i] != NULL) { 79 module = pamh->chains[i]; 80 pamh->chains[i] = module->next; 81 /* XXX free options */ 82 dlclose(module->dlh); 83 free(module->modpath); 84 free(module); 85 } 86 } 75 openpam_clear_chains(pamh); 87 76 88 77 /* clear items */ -
trunk/lib/pam_start.c
r19 r21 35 35 */ 36 36 37 #include <sys/param.h>38 39 37 #include <ctype.h> 40 #include <dlfcn.h>41 38 #include <errno.h> 42 39 #include <stdio.h> … … 88 85 pam_end(ph, r); 89 86 return (r); 90 }91 92 /* XXX move to a different file */93 const char *_pam_sm_func_name[PAM_NUM_PRIMITIVES] = {94 "pam_sm_acct_mgmt",95 "pam_sm_authenticate",96 "pam_sm_chauthtok",97 "pam_sm_close_session",98 "pam_sm_open_session",99 "pam_sm_setcred"100 };101 102 static int103 _pam_add_module(pam_handle_t *pamh,104 int chain,105 int flag,106 const char *modpath,107 const char *options /* XXX */ __unused)108 {109 pam_chain_t *module, *iterator;110 int i;111 112 /* fill in configuration data */113 if ((module = malloc(sizeof(*module))) == NULL) {114 openpam_log(PAM_LOG_ERROR, "malloc(): %m");115 return (PAM_BUF_ERR);116 }117 if ((module->modpath = strdup(modpath)) == NULL) {118 openpam_log(PAM_LOG_ERROR, "strdup(): %m");119 free(module);120 return (PAM_BUF_ERR);121 }122 module->flag = flag;123 module->next = NULL;124 125 /* load module and resolve symbols */126 /*127 * Each module is dlopen()'d once for evey time it occurs in128 * any chain. While the linker is smart enough to not load129 * the same module more than once, it does waste space in the130 * form of linker handles and pam_func structs.131 *132 * TODO: implement a central module cache and replace the133 * array of pam_func structs in struct pam_chain with pointers134 * to the appropriate entry in the module cache.135 *136 * TODO: move this code out into a separate file to hide the137 * details of the module cache and linker API from this file.138 */139 if ((module->dlh = dlopen(modpath, RTLD_NOW)) == NULL) {140 openpam_log(PAM_LOG_ERROR, "dlopen(): %s", dlerror());141 free(module->modpath);142 free(module);143 return (PAM_OPEN_ERR);144 }145 for (i = 0; i < PAM_NUM_PRIMITIVES; ++i)146 module->primitive[i] =147 dlsym(module->dlh, _pam_sm_func_name[i]);148 149 if ((iterator = pamh->chains[chain]) != NULL) {150 while (iterator->next != NULL)151 iterator = iterator->next;152 iterator->next = module;153 } else {154 pamh->chains[chain] = module;155 }156 return (PAM_SUCCESS);157 87 } 158 88 … … 287 217 * appropriate chain and bump the counter. 288 218 */ 289 if ((r = _pam_add_module(pamh, chain, flag, p, q)) !=219 if ((r = openpam_add_module(pamh, chain, flag, p, q)) != 290 220 PAM_SUCCESS) 291 221 return (-r);
Note: See TracChangeset
for help on using the changeset viewer.