From cf32a03bc9556d6c3dc927d7eb9d276d21d43d41 Mon Sep 17 00:00:00 2001 From: jdp Date: Wed, 20 Jan 1999 21:55:30 +0000 Subject: Make it possible to use PAM in statically-linked applications. --- .../libpam/libpam/include/security/pam_modules.h | 56 ++++++++++++++++++++++ contrib/libpam/libpam/pam_static.c | 34 ++----------- 2 files changed, 61 insertions(+), 29 deletions(-) (limited to 'contrib/libpam') diff --git a/contrib/libpam/libpam/include/security/pam_modules.h b/contrib/libpam/libpam/include/security/pam_modules.h index 6ba9cc6..080bcfc 100644 --- a/contrib/libpam/libpam/include/security/pam_modules.h +++ b/contrib/libpam/libpam/include/security/pam_modules.h @@ -28,6 +28,21 @@ #ifndef _SECURITY_PAM_MODULES_H #define _SECURITY_PAM_MODULES_H +/* + * Define either PAM_STATIC or PAM_DYNAMIC, based on whether PIC + * compilation is being used. + */ +#if !defined(PIC) && !defined(PAM_STATIC) +#define PAM_STATIC +#endif +#ifndef PAM_STATIC +#define PAM_DYNAMIC +#endif + +#ifdef PAM_STATIC +#include +#endif + #include /* Linux-PAM common defined types */ /* these defines are used by pam_set_item() and pam_get_item() and are @@ -71,9 +86,50 @@ struct pam_module { int argc, const char **argv); }; +#ifdef PAM_SM_AUTH +#define PAM_SM_AUTH_ENTRY pam_sm_authenticate +#define PAM_SM_SETCRED_ENTRY pam_sm_setcred +#else +#define PAM_SM_AUTH_ENTRY NULL +#define PAM_SM_SETCRED_ENTRY NULL +#endif + +#ifdef PAM_SM_ACCOUNT +#define PAM_SM_ACCOUNT_ENTRY pam_sm_acct_mgmt +#else +#define PAM_SM_ACCOUNT_ENTRY NULL +#endif + +#ifdef PAM_SM_SESSION +#define PAM_SM_OPEN_SESSION_ENTRY pam_sm_open_session +#define PAM_SM_CLOSE_SESSION_ENTRY pam_sm_close_session +#else +#define PAM_SM_OPEN_SESSION_ENTRY NULL +#define PAM_SM_CLOSE_SESSION_ENTRY NULL +#endif + +#ifdef PAM_SM_PASSWORD +#define PAM_SM_PASSWORD_ENTRY pam_sm_chauthtok +#else +#define PAM_SM_PASSWORD_ENTRY NULL +#endif + +#define PAM_MODULE_ENTRY(name) \ + static struct pam_module _pam_modstruct = { \ + name, \ + PAM_SM_AUTH_ENTRY, \ + PAM_SM_SETCRED_ENTRY, \ + PAM_SM_ACCOUNT_ENTRY, \ + PAM_SM_OPEN_SESSION_ENTRY, \ + PAM_SM_CLOSE_SESSION_ENTRY, \ + PAM_SM_PASSWORD_ENTRY \ + }; \ + DATA_SET(_pam_static_modules, _pam_modstruct) + #else /* !PAM_STATIC */ #define PAM_EXTERN extern +#define PAM_MODULE_ENTRY(name) #endif /* PAM_STATIC */ diff --git a/contrib/libpam/libpam/pam_static.c b/contrib/libpam/libpam/pam_static.c index d840a2d..c94895e 100644 --- a/contrib/libpam/libpam/pam_static.c +++ b/contrib/libpam/libpam/pam_static.c @@ -19,43 +19,24 @@ * */ -/* This whole file is only used for PAM_STATIC */ - -#ifdef PAM_STATIC - #include #include #include #include "pam_private.h" -/* - * Need to include pointers to static modules; this was built by each - * of the modules that register... - */ - -#include "../modules/_static_module_list" - -/* - * and here is a structure that connects libpam to the above static - * modules - */ - -static struct pam_module *static_modules[] = { +/* This whole file is only used for PAM_STATIC */ -#include "../modules/_static_module_entry" +#ifdef PAM_STATIC - NULL -}; - -/* - * and now for the functions - */ +extern struct linker_set _pam_static_modules; /* Return pointer to data structure used to define a static module */ struct pam_module * _pam_open_static_handler(char *path) { int i; char *lpath = path, *end; + struct pam_module **static_modules = + (struct pam_module **)_pam_static_modules.ls_items; if (strchr(lpath, '/')) { /* ignore path and leading "/" */ @@ -79,11 +60,6 @@ struct pam_module * _pam_open_static_handler(char *path) { } } - if (static_modules[i] == NULL) { - pam_system_log(pamh, NULL, LOG_ERR, "no static module named %s", - lpath); - } - free(lpath); return (static_modules[i]); } -- cgit v1.1