diff options
author | Thorsten Kukuk <kukuk@thkukuk.de> | 2006-01-22 07:36:54 +0000 |
---|---|---|
committer | Thorsten Kukuk <kukuk@thkukuk.de> | 2006-01-22 07:36:54 +0000 |
commit | 5116bebb80ac7ee441c66b1a884d2653755dc4d9 (patch) | |
tree | 3099a4612f58dca3a23633d7a00da4283ad025a9 /libpam/pam_handlers.c | |
parent | b1b9e62160a35087e006faa799c89431c76b4d89 (diff) | |
download | pam-5116bebb80ac7ee441c66b1a884d2653755dc4d9.tar.gz pam-5116bebb80ac7ee441c66b1a884d2653755dc4d9.tar.bz2 pam-5116bebb80ac7ee441c66b1a884d2653755dc4d9.zip |
Relevant BUGIDs: none
Purpose of commit: bugfix
Commit summary:
---------------
Fix compiling of static version of shared libpam, libpamc and libpam_misc
libraries without assuming "--enable-static-modules do not make the modules
dynamically loadable".
2006-01-22 Thorsten Kukuk <kukuk@thkukuk.de>
* configure.in: Don't define PAM_DYNAMIC.
* libpam/pam_handlers.c: Get ride of PAM_DYNAMIC, don't
include pam_dynamic.h
* libpam/pam_dynamic.c: Don't include pam_dynamic.h,
exclude functions if we compile with PAM_STATIC.
* libpam/pam_dynamic.h: Remove.
* libpam/pam_private.h: Add function prototypes from pam_dynamic.h.
* libpam/Makefile.am: Bump version number of libpam, remove
pam_dynamic.h.
Diffstat (limited to 'libpam/pam_handlers.c')
-rw-r--r-- | libpam/pam_handlers.c | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/libpam/pam_handlers.c b/libpam/pam_handlers.c index 1b5b9416..9035fb2f 100644 --- a/libpam/pam_handlers.c +++ b/libpam/pam_handlers.c @@ -4,8 +4,6 @@ * created by Marc Ewing. * Currently maintained by Andrew G. Morgan <morgan@kernel.org> * - * $Id$ - * */ #include "pam_private.h" @@ -18,10 +16,6 @@ #include <fcntl.h> #include <unistd.h> -#ifdef PAM_DYNAMIC -#include "pam_dynamic.h" -#endif /* PAM_DYNAMIC */ - #define BUF_SIZE 1024 #define MODULE_CHUNK 4 #define UNKNOWN_MODULE_PATH "<*unknown module path*>" @@ -599,7 +593,7 @@ int _pam_add_handler(pam_handle_t *pamh struct handlers *the_handlers; const char *sym, *sym2; char *mod_full_path=NULL; -#ifdef PAM_DYNAMIC +#ifndef PAM_STATIC char *mod_full_isa_path=NULL, *isa=NULL; #endif servicefn func, func2; @@ -656,7 +650,26 @@ int _pam_add_handler(pam_handle_t *pamh /* Be pessimistic... */ success = PAM_ABORT; -#ifdef PAM_DYNAMIC +#ifdef PAM_STATIC + /* Only load static function if function was not found dynamically. + * This code should work even if no dynamic loading is available. */ + if (success != PAM_SUCCESS) { + D(("_pam_add_handler: open static handler %s", mod_path)); + mod->dl_handle = _pam_open_static_handler(mod_path); + if (mod->dl_handle == NULL) { + D(("_pam_add_handler: unable to find static handler %s", + mod_path)); + pam_syslog(pamh, LOG_ERR, + "unable to open static handler %s", mod_path); + /* Didn't find module in dynamic or static..will mark bad */ + } else { + D(("static module added successfully")); + success = PAM_SUCCESS; + mod->type = PAM_MT_STATIC_MOD; + pamh->handlers.modules_used++; + } + } +#else D(("_pam_add_handler: _pam_dlopen(%s)", mod_path)); mod->dl_handle = _pam_dlopen(mod_path); D(("_pam_add_handler: _pam_dlopen'ed")); @@ -693,26 +706,6 @@ int _pam_add_handler(pam_handle_t *pamh pamh->handlers.modules_used++; } #endif -#ifdef PAM_STATIC - /* Only load static function if function was not found dynamically. - * This code should work even if no dynamic loading is available. */ - if (success != PAM_SUCCESS) { - D(("_pam_add_handler: open static handler %s", mod_path)); - mod->dl_handle = _pam_open_static_handler(mod_path); - if (mod->dl_handle == NULL) { - D(("_pam_add_handler: unable to find static handler %s", - mod_path)); - pam_syslog(pamh, LOG_ERR, - "unable to open static handler %s", mod_path); - /* Didn't find module in dynamic or static..will mark bad */ - } else { - D(("static module added successfully")); - success = PAM_SUCCESS; - mod->type = PAM_MT_STATIC_MOD; - pamh->handlers.modules_used++; - } - } -#endif if (success != PAM_SUCCESS) { /* add a malformed module */ mod->dl_handle = NULL; @@ -786,14 +779,13 @@ int _pam_add_handler(pam_handle_t *pamh /* are the modules reliable? */ if ( -#ifdef PAM_DYNAMIC - mod->type != PAM_MT_DYNAMIC_MOD - && -#endif /* PAM_DYNAMIC */ #ifdef PAM_STATIC mod->type != PAM_MT_STATIC_MOD && -#endif /* PAM_STATIC */ +#else + mod->type != PAM_MT_DYNAMIC_MOD + && +#endif mod->type != PAM_MT_FAULTY_MOD ) { D(("_pam_add_handlers: illegal module library type; %d", mod->type)); @@ -805,31 +797,29 @@ int _pam_add_handler(pam_handle_t *pamh /* now identify this module's functions - for non-faulty modules */ -#ifdef PAM_DYNAMIC - if ((mod->type == PAM_MT_DYNAMIC_MOD) && - !(func = _pam_dlsym(mod->dl_handle, sym)) ) { - pam_syslog(pamh, LOG_ERR, "unable to resolve symbol: %s", sym); - } -#endif #ifdef PAM_STATIC if ((mod->type == PAM_MT_STATIC_MOD) && (func = (servicefn)_pam_get_static_sym(mod->dl_handle, sym)) == NULL) { pam_syslog(pamh, LOG_ERR, "unable to resolve static symbol: %s", sym); } +#else + if ((mod->type == PAM_MT_DYNAMIC_MOD) && + !(func = _pam_dlsym(mod->dl_handle, sym)) ) { + pam_syslog(pamh, LOG_ERR, "unable to resolve symbol: %s", sym); + } #endif if (sym2) { -#ifdef PAM_DYNAMIC - if ((mod->type == PAM_MT_DYNAMIC_MOD) && - !(func2 = _pam_dlsym(mod->dl_handle, sym2)) ) { - pam_syslog(pamh, LOG_ERR, "unable to resolve symbol: %s", sym2); - } -#endif #ifdef PAM_STATIC if ((mod->type == PAM_MT_STATIC_MOD) && (func2 = (servicefn)_pam_get_static_sym(mod->dl_handle, sym2)) == NULL) { pam_syslog(pamh, LOG_ERR, "unable to resolve symbol: %s", sym2); } +#else + if ((mod->type == PAM_MT_DYNAMIC_MOD) && + !(func2 = _pam_dlsym(mod->dl_handle, sym2)) ) { + pam_syslog(pamh, LOG_ERR, "unable to resolve symbol: %s", sym2); + } #endif } @@ -907,7 +897,7 @@ int _pam_free_handlers(pam_handle_t *pamh) while (pamh->handlers.modules_used) { D(("_pam_free_handlers: dlclose(%s)", mod->name)); free(mod->name); -#ifdef PAM_DYNAMIC +#ifndef PAM_STATIC if (mod->type == PAM_MT_DYNAMIC_MOD) { _pam_dlclose(mod->dl_handle); } |