summaryrefslogtreecommitdiffstats
path: root/contrib/libpam
diff options
context:
space:
mode:
authorjdp <jdp@FreeBSD.org>1999-01-20 21:55:30 +0000
committerjdp <jdp@FreeBSD.org>1999-01-20 21:55:30 +0000
commitcf32a03bc9556d6c3dc927d7eb9d276d21d43d41 (patch)
tree2676314f5ae37c6b0cc69d8819e10f023fafccbd /contrib/libpam
parentef01c22e1080a19283f19943021d45e9ad3a711f (diff)
downloadFreeBSD-src-cf32a03bc9556d6c3dc927d7eb9d276d21d43d41.zip
FreeBSD-src-cf32a03bc9556d6c3dc927d7eb9d276d21d43d41.tar.gz
Make it possible to use PAM in statically-linked applications.
Diffstat (limited to 'contrib/libpam')
-rw-r--r--contrib/libpam/libpam/include/security/pam_modules.h56
-rw-r--r--contrib/libpam/libpam/pam_static.c34
2 files changed, 61 insertions, 29 deletions
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 <linker_set.h>
+#endif
+
#include <security/_pam_types.h> /* 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#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]);
}
OpenPOWER on IntegriCloud