Get rid of the module cache; it serves little purpose, and makes OpenPAM

thread-unsafe.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@403 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2007-11-28 12:29:08 +00:00
parent 637fafa964
commit 911d657644
2 changed files with 1 additions and 36 deletions

View File

@ -258,9 +258,6 @@ struct pam_module {
char *path;
pam_func_t func[PAM_NUM_PRIMITIVES];
void *dlh;
int refcount;
pam_module_t *prev;
pam_module_t *next;
};
/*

View File

@ -60,11 +60,8 @@ const char *_pam_sm_func_name[PAM_NUM_PRIMITIVES] = {
"pam_sm_chauthtok"
};
static pam_module_t *modules;
/*
* Locate a matching dynamic or static module. Keep a list of previously
* found modules to speed up the process.
* Locate a matching dynamic or static module.
*/
pam_module_t *
@ -72,12 +69,6 @@ openpam_load_module(const char *path)
{
pam_module_t *module;
/* check cache first */
for (module = modules; module != NULL; module = module->next)
if (strcmp(module->path, path) == 0)
goto found;
/* nope; try to load */
module = openpam_dynamic(path);
openpam_log(PAM_LOG_DEBUG, "%s dynamic %s",
(module == NULL) ? "no" : "using", path);
@ -94,14 +85,6 @@ openpam_load_module(const char *path)
openpam_log(PAM_LOG_ERROR, "no %s found", path);
return (NULL);
}
openpam_log(PAM_LOG_DEBUG, "adding %s to cache", module->path);
module->next = modules;
if (module->next != NULL)
module->next->prev = module;
module->prev = NULL;
modules = module;
found:
++module->refcount;
return (module);
}
@ -116,25 +99,10 @@ openpam_release_module(pam_module_t *module)
{
if (module == NULL)
return;
--module->refcount;
if (module->refcount > 0)
/* still in use */
return;
if (module->refcount < 0) {
openpam_log(PAM_LOG_ERROR, "module %s has negative refcount",
module->path);
module->refcount = 0;
}
if (module->dlh == NULL)
/* static module */
return;
dlclose(module->dlh);
if (module->prev != NULL)
module->prev->next = module->next;
if (module->next != NULL)
module->next->prev = module->prev;
if (module == modules)
modules = module->next;
openpam_log(PAM_LOG_DEBUG, "releasing %s", module->path);
FREE(module->path);
FREE(module);