Changeset 25 in openpam
- Timestamp:
- 02/04/02 15:00:16 (11 years ago)
- Location:
- trunk/lib
- Files:
-
- 4 edited
-
openpam_dispatch.c (modified) (4 diffs)
-
openpam_impl.h (modified) (4 diffs)
-
openpam_load.c (modified) (6 diffs)
-
pam_start.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/openpam_dispatch.c
r20 r25 63 63 64 64 /* prevent recursion */ 65 if (pamh-> dispatching) {65 if (pamh->current != NULL) { 66 66 openpam_log(PAM_LOG_ERROR, "indirect recursion"); 67 return (PAM_SYSTEM_ERR); 68 } 69 pamh->dispatching = 1; 67 return (PAM_ABORT); 68 } 70 69 71 70 /* pick a chain */ … … 86 85 break; 87 86 default: 88 pamh->dispatching = 0;89 87 return (PAM_SYSTEM_ERR); 90 88 } … … 99 97 openpam_log(PAM_LOG_ERROR, "%s: no %s()", 100 98 module->modpath, _pam_sm_func_name[primitive]); 101 pamh->dispatching = 0;102 99 r = PAM_SYMBOL_ERR; 103 100 } else { 104 r = (module->primitive[primitive])(pamh, flags); 101 pamh->current = module; 102 r = (module->primitive[primitive])(pamh, flags, 103 module->optc, (const char **)module->optv); 104 pamh->current = NULL; 105 105 openpam_log(PAM_LOG_DEBUG, "%s: %s(): %s", 106 106 module->modpath, _pam_sm_func_name[primitive], … … 148 148 } 149 149 150 pamh->dispatching = 0;151 150 return (fail ? err : PAM_SUCCESS); 152 151 } -
trunk/lib/openpam_impl.h
r21 r25 68 68 extern const char *_pam_sm_func_name[PAM_NUM_PRIMITIVES]; 69 69 70 typedef int (*pam_func_t)(pam_handle_t *, int );70 typedef int (*pam_func_t)(pam_handle_t *, int, int, const char **); 71 71 72 72 typedef struct pam_chain pam_chain_t; … … 74 74 int flag; 75 75 char *modpath; 76 /* XXX options */ 76 int optc; 77 char **optv; 77 78 pam_chain_t *next; 78 79 void *dlh; … … 92 93 struct pam_handle { 93 94 char *service; 94 int dispatching;95 95 96 96 /* chains */ 97 97 pam_chain_t *chains[PAM_NUM_CHAINS]; 98 pam_chain_t *current; 98 99 99 100 /* items and data */ … … 112 113 int openpam_findenv(pam_handle_t *, const char *, size_t); 113 114 int openpam_add_module(pam_handle_t *, int, int, 114 const char *, const char*);115 const char *, int, const char **); 115 116 void openpam_clear_chains(pam_handle_t *); 116 117 -
trunk/lib/openpam_load.c
r22 r25 52 52 }; 53 53 54 static void 55 openpam_destroy_module(pam_chain_t *module) 56 { 57 if (module->dlh != NULL) 58 dlclose(module->dlh); 59 while (module->optc--) 60 free(module->optv[module->optc]); 61 free(module->optv); 62 free(module->modpath); 63 free(module); 64 } 65 54 66 int 55 67 openpam_add_module(pam_handle_t *pamh, … … 57 69 int flag, 58 70 const char *modpath, 59 const char *options /* XXX */ __unused) 71 int optc, 72 const char *optv[]) 60 73 { 61 74 pam_chain_t *module, *iterator; … … 63 76 64 77 /* fill in configuration data */ 65 if ((module = malloc(sizeof(*module))) == NULL) { 66 openpam_log(PAM_LOG_ERROR, "malloc(): %m"); 67 return (PAM_BUF_ERR); 68 } 69 if ((module->modpath = strdup(modpath)) == NULL) { 70 openpam_log(PAM_LOG_ERROR, "strdup(): %m"); 71 free(module); 72 return (PAM_BUF_ERR); 73 } 78 if ((module = calloc(1, sizeof(*module))) == NULL) 79 goto buf_err; 80 if ((module->modpath = strdup(modpath)) == NULL) 81 goto buf_err; 82 if ((module->optv = malloc(sizeof(char *) * (optc + 1))) == NULL) 83 goto buf_err; 84 while (optc--) 85 if ((module->optv[module->optc++] = strdup(*optv++)) == NULL) 86 goto buf_err; 87 module->optv[module->optc] = NULL; 74 88 module->flag = flag; 75 89 module->next = NULL; … … 88 102 if ((module->dlh = dlopen(modpath, RTLD_NOW)) == NULL) { 89 103 openpam_log(PAM_LOG_ERROR, "dlopen(): %s", dlerror()); 90 free(module->modpath); 91 free(module); 104 openpam_destroy_module(module); 92 105 return (PAM_OPEN_ERR); 93 106 } … … 104 117 } 105 118 return (PAM_SUCCESS); 119 120 buf_err: 121 openpam_log(PAM_LOG_ERROR, "%m"); 122 openpam_destroy_module(module); 123 return (PAM_BUF_ERR); 106 124 } 107 125 … … 120 138 module = pamh->chains[i]; 121 139 pamh->chains[i] = module->next; 122 /* XXX free options */ 123 dlclose(module->dlh); 124 free(module->modpath); 125 free(module); 140 openpam_destroy_module(module); 126 141 } 127 142 } -
trunk/lib/pam_start.c
r21 r25 90 90 #define PAM_D_STYLE 1 91 91 #define MAX_LINE_LEN 1024 92 #define MAX_OPTIONS 256 92 93 93 94 static int … … 98 99 { 99 100 char buf[MAX_LINE_LEN], *p, *q; 100 int ch, chain, flag, line, n, r; 101 const char *optv[MAX_OPTIONS + 1]; 102 int ch, chain, flag, line, optc, n, r; 101 103 size_t len; 102 104 FILE *f; … … 207 209 208 210 /* get options */ 209 if (*q != '\0') {210 *q++ = 0;211 for (optc = 0; *q != '\0' && optc < MAX_OPTIONS; ++optc) { 212 *q++ = '\0'; 211 213 while (isspace(*q)) 212 214 ++q; 215 optv[optc] = q; 216 while (*q != '\0' && !isspace(*q)) 217 ++q; 218 } 219 optv[optc] = NULL; 220 if (*q != '\0') { 221 *q = '\0'; 222 openpam_log(PAM_LOG_ERROR, 223 "%s: too many options on line %d", 224 filename, line); 213 225 } 214 226 … … 217 229 * appropriate chain and bump the counter. 218 230 */ 219 if ((r = openpam_add_module(pamh, chain, flag, p, q)) !=220 PAM_SUCCESS)231 r = openpam_add_module(pamh, chain, flag, p, optc, optv); 232 if (r != PAM_SUCCESS) 221 233 return (-r); 222 234 ++n;
Note: See TracChangeset
for help on using the changeset viewer.