summaryrefslogtreecommitdiff
path: root/contrib/openpam/lib/openpam_load.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/openpam/lib/openpam_load.c')
-rw-r--r--contrib/openpam/lib/openpam_load.c60
1 files changed, 9 insertions, 51 deletions
diff --git a/contrib/openpam/lib/openpam_load.c b/contrib/openpam/lib/openpam_load.c
index ef683099cad5..a1057f39a233 100644
--- a/contrib/openpam/lib/openpam_load.c
+++ b/contrib/openpam/lib/openpam_load.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * Copyright (c) 2002-2003 Networks Associates Technology, Inc.
* All rights reserved.
*
* This software was developed for the FreeBSD Project by ThinkSec AS and
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/openpam/lib/openpam_load.c#15 $
+ * $P4: //depot/projects/openpam/lib/openpam_load.c#19 $
*/
#include <dlfcn.h>
@@ -67,7 +67,7 @@ static pam_module_t *modules;
* found modules to speed up the process.
*/
-static pam_module_t *
+pam_module_t *
openpam_load_module(const char *path)
{
pam_module_t *module;
@@ -136,8 +136,8 @@ openpam_release_module(pam_module_t *module)
if (module == modules)
modules = module->next;
openpam_log(PAM_LOG_DEBUG, "releasing %s", module->path);
- free(module->path);
- free(module);
+ FREE(module->path);
+ FREE(module);
}
@@ -154,52 +154,10 @@ openpam_destroy_chain(pam_chain_t *chain)
openpam_destroy_chain(chain->next);
chain->next = NULL;
while (chain->optc--)
- free(chain->optv[chain->optc]);
- free(chain->optv);
+ FREE(chain->optv[chain->optc]);
+ FREE(chain->optv);
openpam_release_module(chain->module);
- free(chain);
-}
-
-/*
- * Add a module to a chain.
- */
-
-int
-openpam_add_module(pam_chain_t *policy[],
- int chain,
- int flag,
- const char *modpath,
- int optc,
- const char *optv[])
-{
- pam_chain_t *new, *iterator;
-
- if ((new = calloc(1, sizeof *new)) == NULL)
- goto buf_err;
- if ((new->optv = malloc(sizeof(char *) * (optc + 1))) == NULL)
- goto buf_err;
- while (optc--)
- if ((new->optv[new->optc++] = strdup(*optv++)) == NULL)
- goto buf_err;
- new->optv[new->optc] = NULL;
- new->flag = flag;
- if ((new->module = openpam_load_module(modpath)) == NULL) {
- openpam_destroy_chain(new);
- return (PAM_OPEN_ERR);
- }
- if ((iterator = policy[chain]) != NULL) {
- while (iterator->next != NULL)
- iterator = iterator->next;
- iterator->next = new;
- } else {
- policy[chain] = new;
- }
- return (PAM_SUCCESS);
-
- buf_err:
- openpam_log(PAM_LOG_ERROR, "%m");
- openpam_destroy_chain(new);
- return (PAM_BUF_ERR);
+ FREE(chain);
}
@@ -212,7 +170,7 @@ openpam_clear_chains(pam_chain_t *policy[])
{
int i;
- for (i = 0; i < PAM_NUM_CHAINS; ++i)
+ for (i = 0; i < PAM_NUM_FACILITIES; ++i)
openpam_destroy_chain(policy[i]);
}