- Timestamp:
- Mar 10, 2010, 11:34:36 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/openpam_dynamic.c
r423 r433 62 62 openpam_dynamic(const char *path) 63 63 { 64 const pam_module_t *dlmodule; 64 65 pam_module_t *module; 65 66 const char *prefix; … … 69 70 70 71 dlh = NULL; 71 if ((module = calloc(1, sizeof *module)) == NULL)72 goto buf_err;73 72 74 73 /* Prepend the standard prefix if not an absolute pathname. */ … … 80 79 /* try versioned module first, then unversioned module */ 81 80 if (asprintf(&vpath, "%s%s.%d", prefix, path, LIB_MAJ) < 0) 82 goto buf_err;81 goto err; 83 82 if ((dlh = dlopen(vpath, RTLD_NOW)) == NULL) { 84 83 openpam_log(PAM_LOG_DEBUG, "%s: %s", vpath, dlerror()); … … 87 86 openpam_log(PAM_LOG_DEBUG, "%s: %s", vpath, dlerror()); 88 87 FREE(vpath); 89 FREE(module);90 88 return (NULL); 91 89 } 92 90 } 93 91 FREE(vpath); 92 if ((module = calloc(1, sizeof *module)) == NULL) 93 goto buf_err; 94 94 if ((module->path = strdup(path)) == NULL) 95 95 goto buf_err; 96 96 module->dlh = dlh; 97 dlmodule = dlsym(dlh, "_pam_module"); 97 98 for (i = 0; i < PAM_NUM_PRIMITIVES; ++i) { 98 module->func[i] = (pam_func_t)dlsym(dlh, _pam_sm_func_name[i]); 99 module->func[i] = dlmodule ? dlmodule->func[i] : 100 (pam_func_t)dlsym(dlh, _pam_sm_func_name[i]); 99 101 if (module->func[i] == NULL) 100 102 openpam_log(PAM_LOG_DEBUG, "%s: %s(): %s", … … 103 105 return (module); 104 106 buf_err: 105 openpam_log(PAM_LOG_ERROR, "%m");106 107 if (dlh != NULL) 107 108 dlclose(dlh); 108 109 FREE(module); 110 err: 111 openpam_log(PAM_LOG_ERROR, "%m"); 109 112 return (NULL); 110 113 }
Note: See TracChangeset
for help on using the changeset viewer.