From a5c4da8d631c538490c1920689d590c19a60f1d6 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Sun, 22 Jan 2006 15:40:58 +0000 Subject: Relevant BUGIDs: none Purpose of commit: bugfix Commit summary: --------------- Fix infrastructure and compile errors for PAM_STATIC (static modules): 2006-01-22 Thorsten Kukuk * modules/pam_succeed_if/pam_succeed_if.c (pam_sm_acct_mgmt): Add support for static modules. * modules/pam_xauth/pam_xauth.c: Likewise. * libpam/pam_handlers.c (_pam_add_handler): Add pamh to _pam_open_static_handler call. * libpam/pam_static.c (_pam_open_static_handler): Add pamh as argument. * libpam/pam_private.h: Adjust prototype. --- ChangeLog | 13 ++++++++++++- libpam/pam_handlers.c | 2 +- libpam/pam_private.h | 9 +++++---- libpam/pam_static.c | 10 +++++----- modules/pam_succeed_if/pam_succeed_if.c | 27 ++++++++++++++++++++++----- modules/pam_xauth/pam_xauth.c | 17 +++++++++++++++-- 6 files changed, 60 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6477d520..34a3d53a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,20 @@ 2006-01-22 Thorsten Kukuk + * modules/pam_succeed_if/pam_succeed_if.c (pam_sm_acct_mgmt): + Add support for static modules. + * modules/pam_xauth/pam_xauth.c: Likewise. + + * libpam/pam_handlers.c (_pam_add_handler): Add pamh to + _pam_open_static_handler call. + + * libpam/pam_static.c (_pam_open_static_handler): Add pamh + as argument. + * libpam/pam_private.h: Adjust prototype. + * 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, + * 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. diff --git a/libpam/pam_handlers.c b/libpam/pam_handlers.c index 9035fb2f..62342fda 100644 --- a/libpam/pam_handlers.c +++ b/libpam/pam_handlers.c @@ -655,7 +655,7 @@ int _pam_add_handler(pam_handle_t *pamh * 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); + mod->dl_handle = _pam_open_static_handler(pamh, mod_path); if (mod->dl_handle == NULL) { D(("_pam_add_handler: unable to find static handler %s", mod_path)); diff --git a/libpam/pam_private.h b/libpam/pam_private.h index 5ab0f8c5..ad804791 100644 --- a/libpam/pam_private.h +++ b/libpam/pam_private.h @@ -225,7 +225,8 @@ typedef int (*servicefn)(pam_handle_t *, int, int, char **); /* The next two in ../modules/_pam_static/pam_static.c */ /* Return pointer to data structure used to define a static module */ -struct pam_module * _pam_open_static_handler(const char *path); +struct pam_module * _pam_open_static_handler (pam_handle_t *pamh, + const char *path); /* Return pointer to function requested from static module */ @@ -299,7 +300,7 @@ if ((pamh) == NULL) { \ extern int _pam_auditlog(pam_handle_t *pamh, int action, int retval, int flags); extern int _pam_audit_end(pam_handle_t *pamh, int pam_status); #endif - + /* * Copyright (C) 1995 by Red Hat Software, Marc Ewing * Copyright (c) 1996-8,2001 by Andrew G. Morgan @@ -318,13 +319,13 @@ extern int _pam_audit_end(pam_handle_t *pamh, int pam_status); * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * ALTERNATIVELY, this product may be distributed under the terms of * the GNU Public License, in which case the provisions of the GPL are * required INSTEAD OF the above restrictions. (This clause is * necessary due to a potential bad interaction between the GPL and * the restrictions contained in a BSD-style copyright.) - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE diff --git a/libpam/pam_static.c b/libpam/pam_static.c index e2c6aac3..7ea4c81b 100644 --- a/libpam/pam_static.c +++ b/libpam/pam_static.c @@ -1,8 +1,7 @@ -/* pam_static.c -- static module loading helper functions */ - -/* created by Michael K. Johnson, johnsonm@redhat.com +/* + * pam_static.c -- static module loading helper functions * - * $Id$ + * created by Michael K. Johnson, johnsonm@redhat.com */ /* This whole file is only used for PAM_STATIC */ @@ -39,7 +38,8 @@ static struct pam_module *static_modules[] = { */ /* Return pointer to data structure used to define a static module */ -struct pam_module * _pam_open_static_handler(const char *path) +struct pam_module * +_pam_open_static_handler (pam_handle_t *pamh, const char *path) { int i; const char *clpath = path; diff --git a/modules/pam_succeed_if/pam_succeed_if.c b/modules/pam_succeed_if/pam_succeed_if.c index f84fdd3f..d343cae8 100644 --- a/modules/pam_succeed_if/pam_succeed_if.c +++ b/modules/pam_succeed_if/pam_succeed_if.c @@ -53,6 +53,10 @@ #include #include #include + +#define PAM_SM_AUTH +#define PAM_SM_ACCOUNT + #include #include #include @@ -313,21 +317,21 @@ evaluate(pam_handle_t *pamh, int debug, if (strcasecmp(qual, "innetgr") == 0) { const void *rhost; if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS) - rhost = NULL; + rhost = NULL; return evaluate_innetgr(rhost, pwd->pw_name, right); } /* (Rhost, user) is not in this group. */ if (strcasecmp(qual, "notinnetgr") == 0) { const void *rhost; if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS) - rhost = NULL; + rhost = NULL; return evaluate_notinnetgr(rhost, pwd->pw_name, right); } /* Fail closed. */ return PAM_SERVICE_ERR; } -int +PAM_EXTERN int pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED, int argc, const char **argv) { @@ -460,15 +464,28 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED, return ret; } -int +PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh UNUSED, int flags UNUSED, int argc UNUSED, const char **argv UNUSED) { return PAM_SUCCESS; } -int +PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) { return pam_sm_authenticate(pamh, flags, argc, argv); } + +/* static module data */ +#ifdef PAM_STATIC +struct pam_module _pam_succeed_if_modstruct = { + "pam_succeed_if", + pam_sm_authenticate, + pam_sm_setcred, + pam_sm_acct_mgmt, + NULL, + NULL, + NULL +}; +#endif diff --git a/modules/pam_xauth/pam_xauth.c b/modules/pam_xauth/pam_xauth.c index 5376bd8b..3772bd06 100644 --- a/modules/pam_xauth/pam_xauth.c +++ b/modules/pam_xauth/pam_xauth.c @@ -33,8 +33,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* "$Id$" */ - #include "config.h" #include #include @@ -52,6 +50,8 @@ #include #include +#define PAM_SM_SESSION + #include #include #include @@ -665,3 +665,16 @@ pam_sm_close_session (pam_handle_t *pamh, int flags UNUSED, } return PAM_SUCCESS; } + +/* static module data */ +#ifdef PAM_STATIC +struct pam_module _pam_xauth_modstruct = { + "pam_xauth", + NULL, + NULL, + NULL, + pam_sm_open_session, + pam_sm_close_session, + NULL +}; +#endif -- cgit v1.2.3