From c074d5f200590ad8d7d3c98f3d4debf5f4dfff00 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Sat, 3 Sep 2005 17:09:19 +0000 Subject: Relevant BUGIDs: none Purpose of commit: new feature Commit summary: --------------- Add pam_syslog to unify log messages from PAM modules. --- libpam/pam_handlers.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libpam/pam_handlers.c') diff --git a/libpam/pam_handlers.c b/libpam/pam_handlers.c index fd5e8760..b2d7c3a7 100644 --- a/libpam/pam_handlers.c +++ b/libpam/pam_handlers.c @@ -576,6 +576,27 @@ static int _pam_assemble_line(FILE *f, char *buffer, int buf_len) return used; } +static char * +extract_modulename(const char *mod_path) +{ + const char *p = strrchr (mod_path, '/'); + char *dot, *retval; + + if (p == NULL) + p = mod_path; + else + *p++; + + if ((retval = strdup (p)) == NULL) + return NULL; + + dot = strrchr (retval, '.'); + if (dot) + *dot = '\0'; + + return retval; +} + typedef int (*servicefn)(pam_handle_t *, int, int, char **); int _pam_add_handler(pam_handle_t *pamh @@ -886,6 +907,7 @@ int _pam_add_handler(pam_handle_t *pamh (*handler_p)->cached_retval_p = &((*handler_p)->cached_retval); (*handler_p)->argc = argc; (*handler_p)->argv = argv; /* not a copy */ + (*handler_p)->mod_name = extract_modulename(mod->name); (*handler_p)->next = NULL; /* some of the modules have a second calling function */ @@ -916,6 +938,7 @@ int _pam_add_handler(pam_handle_t *pamh } else { (*handler_p2)->argv = NULL; /* no arguments */ } + (*handler_p2)->mod_name = extract_modulename(mod->name); (*handler_p2)->next = NULL; } @@ -1018,6 +1041,8 @@ void _pam_free_handlers_aux(struct handler **hp) while (h) { last = h; _pam_drop(h->argv); /* This is all alocated in a single chunk */ + if (h->mod_name) + _pam_drop(h->mod_name); h = h->next; memset(last, 0, sizeof(*last)); free(last); -- cgit v1.2.3