summaryrefslogtreecommitdiff
path: root/libpam
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2006-01-22 07:36:54 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2006-01-22 07:36:54 +0000
commit5116bebb80ac7ee441c66b1a884d2653755dc4d9 (patch)
tree3099a4612f58dca3a23633d7a00da4283ad025a9 /libpam
parentb1b9e62160a35087e006faa799c89431c76b4d89 (diff)
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')
-rw-r--r--libpam/Makefile.am4
-rw-r--r--libpam/pam_dynamic.c6
-rw-r--r--libpam/pam_dynamic.h11
-rw-r--r--libpam/pam_handlers.c82
-rw-r--r--libpam/pam_private.h9
5 files changed, 49 insertions, 63 deletions
diff --git a/libpam/Makefile.am b/libpam/Makefile.am
index 81329a3f..4f60ad47 100644
--- a/libpam/Makefile.am
+++ b/libpam/Makefile.am
@@ -13,10 +13,10 @@ EXTRA_DIST = libpam.map
include_HEADERS = $(addprefix include/security/, _pam_compat.h _pam_macros.h _pam_types.h \
pam_appl.h pam_malloc.h pam_modules.h pam_ext.h pam_modutil.h)
-noinst_HEADERS = pam_dynamic.h pam_prelude.h pam_private.h pam_tokens.h \
+noinst_HEADERS = pam_prelude.h pam_private.h pam_tokens.h \
pam_modutil_private.h
-libpam_la_LDFLAGS = -no-undefined -version-info 81:2:81 @LIBAUDIT@
+libpam_la_LDFLAGS = -no-undefined -version-info 81:3:81 @LIBAUDIT@
if HAVE_VERSIONING
libpam_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libpam.map
endif
diff --git a/libpam/pam_dynamic.c b/libpam/pam_dynamic.c
index 6bb3d559..5be33c36 100644
--- a/libpam/pam_dynamic.c
+++ b/libpam/pam_dynamic.c
@@ -33,6 +33,8 @@
#include "pam_private.h"
+#ifndef PAM_STATIC
+
#ifdef PAM_SHL
# include <dl.h>
#elif defined(PAM_DYLD)
@@ -41,8 +43,6 @@
# include <dlfcn.h>
#endif /* PAM_SHL */
-#include "pam_dynamic.h"
-
#ifndef SHLIB_SYM_PREFIX
#define SHLIB_SYM_PREFIX "_"
#endif
@@ -138,3 +138,5 @@ _pam_dlerror (void)
return dlerror ();
#endif
}
+
+#endif
diff --git a/libpam/pam_dynamic.h b/libpam/pam_dynamic.h
deleted file mode 100644
index 35c427ae..00000000
--- a/libpam/pam_dynamic.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _PAM_DYNAMIC_H
-#define _PAM_DYNAMIC_H
-
-typedef int (*servicefn)(pam_handle_t *, int, int, char **);
-
-void *_pam_dlopen (const char *mod_path);
-servicefn _pam_dlsym (void *handle, const char *symbol);
-void _pam_dlclose (void *handle);
-const char *_pam_dlerror (void);
-
-#endif
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);
}
diff --git a/libpam/pam_private.h b/libpam/pam_private.h
index 3d86b868..5ab0f8c5 100644
--- a/libpam/pam_private.h
+++ b/libpam/pam_private.h
@@ -219,8 +219,9 @@ void _pam_start_timer(pam_handle_t *pamh);
void _pam_await_timer(pam_handle_t *pamh, int status);
typedef void (*voidfunc(void))(void);
-#ifdef PAM_STATIC
+typedef int (*servicefn)(pam_handle_t *, int, int, char **);
+#ifdef PAM_STATIC
/* The next two in ../modules/_pam_static/pam_static.c */
/* Return pointer to data structure used to define a static module */
@@ -229,7 +230,11 @@ struct pam_module * _pam_open_static_handler(const char *path);
/* Return pointer to function requested from static module */
voidfunc *_pam_get_static_sym(struct pam_module *mod, const char *symname);
-
+#else
+void *_pam_dlopen (const char *mod_path);
+servicefn _pam_dlsym (void *handle, const char *symbol);
+void _pam_dlclose (void *handle);
+const char *_pam_dlerror (void);
#endif
/* For now we just use a stack and linear search for module data. */