summaryrefslogtreecommitdiff
path: root/contrib/openpam/lib/openpam_load.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2002-03-05 13:49:56 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2002-03-05 13:49:56 +0000
commit4579d22cac62b140f99be77fe99c614e9d8d070f (patch)
tree1435317b57611a50e1b3cf878a8256c67e69f519 /contrib/openpam/lib/openpam_load.c
parent46acc3702698ba19936598ab0b2bcb79d0541e14 (diff)
Diffstat (limited to 'contrib/openpam/lib/openpam_load.c')
-rw-r--r--contrib/openpam/lib/openpam_load.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/contrib/openpam/lib/openpam_load.c b/contrib/openpam/lib/openpam_load.c
index 057e38fef70f3..68b7788fa406b 100644
--- a/contrib/openpam/lib/openpam_load.c
+++ b/contrib/openpam/lib/openpam_load.c
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $P4: //depot/projects/openpam/lib/openpam_load.c#10 $
*/
#include <dlfcn.h>
@@ -54,16 +54,14 @@ const char *_pam_sm_func_name[PAM_NUM_PRIMITIVES] = {
static pam_module_t *modules;
/*
- * Load a dynamic module, or locate a static one. Keep a list of
- * previously found modules to speed up the process.
+ * Locate a matching dynamic or static module. Keep a list of previously
+ * found modules to speed up the process.
*/
static pam_module_t *
openpam_load_module(const char *path)
{
pam_module_t *module;
- void *dlh;
- int i;
/* check cache first */
for (module = modules; module != NULL; module = module->next)
@@ -71,17 +69,7 @@ openpam_load_module(const char *path)
goto found;
/* nope; try to load */
- if ((dlh = dlopen(path, RTLD_NOW)) == NULL) {
- openpam_log(PAM_LOG_ERROR, "dlopen(): %s", dlerror());
- } else {
- if ((module = calloc(1, sizeof *module)) == NULL)
- goto buf_err;
- if ((module->path = strdup(path)) == NULL)
- goto buf_err;
- module->dlh = dlh;
- for (i = 0; i < PAM_NUM_PRIMITIVES; ++i)
- module->func[i] = dlsym(dlh, _pam_sm_func_name[i]);
- }
+ module = openpam_dynamic(path);
openpam_log(PAM_LOG_DEBUG, "%s dynamic %s",
(module == NULL) ? "no" : "using", path);
@@ -101,11 +89,6 @@ openpam_load_module(const char *path)
found:
++module->refcount;
return (module);
- buf_err:
- openpam_log(PAM_LOG_ERROR, "malloc(): %m");
- dlclose(dlh);
- free(module);
- return (NULL);
}
@@ -136,6 +119,7 @@ openpam_release_module(pam_module_t *module)
module->prev->next = module->next;
if (module->next != NULL)
module->next->prev = module->prev;
+ free(module->path);
free(module);
}