1 /* pam_static.c -- static module loading helper functions */
3 /* created by Michael K. Johnson, johnsonm@redhat.com
5 * $Id: pam_static.c,v 1.4 1996/12/01 03:14:13 morgan Exp $
6 * $FreeBSD: src/contrib/libpam/libpam/pam_static.c,v 1.2.6.2 2001/06/11 15:28:12 markm Exp $
7 * $DragonFly: src/contrib/libpam/libpam/Attic/pam_static.c,v 1.3 2003/11/10 06:14:38 dillon Exp $
9 * $Log: pam_static.c,v $
10 * Revision 1.4 1996/12/01 03:14:13 morgan
13 * Revision 1.3 1996/11/10 20:09:16 morgan
14 * name convention change _pam_
16 * Revision 1.2 1996/06/02 08:02:56 morgan
17 * Michael's minor alterations
19 * Revision 1.1 1996/05/26 04:34:04 morgan
28 #include "pam_private.h"
30 SET_DECLARE(_pam_static_modules, struct pam_module);
32 /* This whole file is only used for PAM_STATIC */
36 /* Return pointer to data structure used to define a static module */
37 struct pam_module * _pam_open_static_handler(char *path) {
39 char *lpath = path, *end;
40 struct pam_module **pamp;
42 if (strchr(lpath, '/')) {
43 /* ignore path and leading "/" */
44 lpath = strrchr(lpath, '/') + 1;
46 /* create copy to muck with (must free before return) */
47 lpath = _pam_strdup(lpath);
48 /* chop .so off copy if it exists (or other extension on other
50 end = strstr(lpath, ".so");
55 /* now go find the module */
56 SET_FOREACH(pamp, _pam_static_modules) {
57 D(("%s=?%s\n", lpath, (*pamp)->name));
58 if ((*pamp)->name && !strcmp((*pamp)->name, lpath)) {
67 /* Return pointer to function requested from static module
68 * Can't just return void *, because ANSI C disallows casting a
69 * pointer to a function to a void *...
70 * This definition means:
71 * _pam_get_static_sym is a function taking two arguments and
72 * returning a pointer to a function which takes no arguments
73 * and returns void... */
74 voidfunc *_pam_get_static_sym(struct pam_module *mod, const char *symname) {
76 if (! strcmp(symname, "pam_sm_authenticate")) {
77 return ((voidfunc *)mod->pam_sm_authenticate);
78 } else if (! strcmp(symname, "pam_sm_setcred")) {
79 return ((voidfunc *)mod->pam_sm_setcred);
80 } else if (! strcmp(symname, "pam_sm_acct_mgmt")) {
81 return ((voidfunc *)mod->pam_sm_acct_mgmt);
82 } else if (! strcmp(symname, "pam_sm_open_session")) {
83 return ((voidfunc *)mod->pam_sm_open_session);
84 } else if (! strcmp(symname, "pam_sm_close_session")) {
85 return ((voidfunc *)mod->pam_sm_close_session);
86 } else if (! strcmp(symname, "pam_sm_chauthtok")) {
87 return ((voidfunc *)mod->pam_sm_chauthtok);
89 /* getting to this point is an error */
90 return ((voidfunc *)NULL);
93 #endif /* PAM_STATIC */
96 * Copyright (C) 1995 by Red Hat Software, Michael K. Johnson
99 * Redistribution and use in source and binary forms, with or without
100 * modification, are permitted provided that the following conditions
102 * 1. Redistributions of source code must retain the above copyright
103 * notice, and the entire permission notice in its entirety,
104 * including the disclaimer of warranties.
105 * 2. Redistributions in binary form must reproduce the above copyright
106 * notice, this list of conditions and the following disclaimer in the
107 * documentation and/or other materials provided with the distribution.
108 * 3. The name of the author may not be used to endorse or promote
109 * products derived from this software without specific prior
110 * written permission.
112 * ALTERNATIVELY, this product may be distributed under the terms of
113 * the GNU Public License, in which case the provisions of the GPL are
114 * required INSTEAD OF the above restrictions. (This clause is
115 * necessary due to a potential bad interaction between the GPL and
116 * the restrictions contained in a BSD-style copyright.)
118 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
119 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
120 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
121 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
122 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
123 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
124 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
125 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
126 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
127 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
128 * OF THE POSSIBILITY OF SUCH DAMAGE.