1 /* pam_static.c -- static module loading helper functions */
3 /* created by Michael K. Johnson, johnsonm@redhat.com
8 /* This whole file is only used for PAM_STATIC */
16 #include "pam_private.h"
19 * Need to include pointers to static modules; this was built by each
20 * of the modules that register...
23 #include "../modules/_static_module_list"
26 * and here is a structure that connects libpam to the above static
30 static struct pam_module *static_modules[] = {
32 #include "../modules/_static_module_entry"
38 * and now for the functions
41 /* Return pointer to data structure used to define a static module */
42 struct pam_module * _pam_open_static_handler(const char *path)
45 const char *clpath = path;
48 if (strchr(clpath, '/')) {
49 /* ignore path and leading "/" */
50 clpath = strrchr(path, '/') + 1;
52 /* create copy to muck with (must free before return) */
53 lpath = _pam_strdup(clpath);
54 /* chop .so off copy if it exists (or other extension on other
56 end = strstr(lpath, ".so");
61 /* now go find the module */
62 for (i = 0; static_modules[i] != NULL; i++) {
63 D(("%s=?%s\n", lpath, static_modules[i]->name));
64 if (static_modules[i]->name &&
65 ! strcmp(static_modules[i]->name, lpath)) {
70 if (static_modules[i] == NULL) {
71 pam_syslog (pamh, LOG_ERR, "no static module named %s", lpath);
75 return (static_modules[i]);
78 /* Return pointer to function requested from static module
79 * Can't just return void *, because ANSI C disallows casting a
80 * pointer to a function to a void *...
81 * This definition means:
82 * _pam_get_static_sym is a function taking two arguments and
83 * returning a pointer to a function which takes no arguments
84 * and returns void... */
85 voidfunc *_pam_get_static_sym(struct pam_module *mod, const char *symname) {
87 if (! strcmp(symname, "pam_sm_authenticate")) {
88 return ((voidfunc *)mod->pam_sm_authenticate);
89 } else if (! strcmp(symname, "pam_sm_setcred")) {
90 return ((voidfunc *)mod->pam_sm_setcred);
91 } else if (! strcmp(symname, "pam_sm_acct_mgmt")) {
92 return ((voidfunc *)mod->pam_sm_acct_mgmt);
93 } else if (! strcmp(symname, "pam_sm_open_session")) {
94 return ((voidfunc *)mod->pam_sm_open_session);
95 } else if (! strcmp(symname, "pam_sm_close_session")) {
96 return ((voidfunc *)mod->pam_sm_close_session);
97 } else if (! strcmp(symname, "pam_sm_chauthtok")) {
98 return ((voidfunc *)mod->pam_sm_chauthtok);
100 /* getting to this point is an error */
101 return ((voidfunc *)NULL);
104 #endif /* PAM_STATIC */
107 * Copyright (C) 1995 by Red Hat Software, Michael K. Johnson
108 * All rights reserved
110 * Redistribution and use in source and binary forms, with or without
111 * modification, are permitted provided that the following conditions
113 * 1. Redistributions of source code must retain the above copyright
114 * notice, and the entire permission notice in its entirety,
115 * including the disclaimer of warranties.
116 * 2. Redistributions in binary form must reproduce the above copyright
117 * notice, this list of conditions and the following disclaimer in the
118 * documentation and/or other materials provided with the distribution.
119 * 3. The name of the author may not be used to endorse or promote
120 * products derived from this software without specific prior
121 * written permission.
123 * ALTERNATIVELY, this product may be distributed under the terms of
124 * the GNU Public License, in which case the provisions of the GPL are
125 * required INSTEAD OF the above restrictions. (This clause is
126 * necessary due to a potential bad interaction between the GPL and
127 * the restrictions contained in a BSD-style copyright.)
129 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
130 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
131 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
132 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
133 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
134 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
135 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
136 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
137 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
138 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
139 * OF THE POSSIBILITY OF SUCH DAMAGE.