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:
parent
637fafa964
commit
911d657644
|
@ -258,9 +258,6 @@ struct pam_module {
|
||||||
char *path;
|
char *path;
|
||||||
pam_func_t func[PAM_NUM_PRIMITIVES];
|
pam_func_t func[PAM_NUM_PRIMITIVES];
|
||||||
void *dlh;
|
void *dlh;
|
||||||
int refcount;
|
|
||||||
pam_module_t *prev;
|
|
||||||
pam_module_t *next;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -60,11 +60,8 @@ const char *_pam_sm_func_name[PAM_NUM_PRIMITIVES] = {
|
||||||
"pam_sm_chauthtok"
|
"pam_sm_chauthtok"
|
||||||
};
|
};
|
||||||
|
|
||||||
static pam_module_t *modules;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Locate a matching dynamic or static module. Keep a list of previously
|
* Locate a matching dynamic or static module.
|
||||||
* found modules to speed up the process.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pam_module_t *
|
pam_module_t *
|
||||||
|
@ -72,12 +69,6 @@ openpam_load_module(const char *path)
|
||||||
{
|
{
|
||||||
pam_module_t *module;
|
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);
|
module = openpam_dynamic(path);
|
||||||
openpam_log(PAM_LOG_DEBUG, "%s dynamic %s",
|
openpam_log(PAM_LOG_DEBUG, "%s dynamic %s",
|
||||||
(module == NULL) ? "no" : "using", path);
|
(module == NULL) ? "no" : "using", path);
|
||||||
|
@ -94,14 +85,6 @@ openpam_load_module(const char *path)
|
||||||
openpam_log(PAM_LOG_ERROR, "no %s found", path);
|
openpam_log(PAM_LOG_ERROR, "no %s found", path);
|
||||||
return (NULL);
|
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);
|
return (module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,25 +99,10 @@ openpam_release_module(pam_module_t *module)
|
||||||
{
|
{
|
||||||
if (module == NULL)
|
if (module == NULL)
|
||||||
return;
|
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)
|
if (module->dlh == NULL)
|
||||||
/* static module */
|
/* static module */
|
||||||
return;
|
return;
|
||||||
dlclose(module->dlh);
|
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);
|
openpam_log(PAM_LOG_DEBUG, "releasing %s", module->path);
|
||||||
FREE(module->path);
|
FREE(module->path);
|
||||||
FREE(module);
|
FREE(module);
|
||||||
|
|
Loading…
Reference in New Issue