]> granicus.if.org Git - linux-pam/commitdiff
pam_unix: make configuration consistent in --enable-static-modules mode
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 3 Feb 2012 00:13:44 +0000 (00:13 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 3 Feb 2012 00:13:44 +0000 (00:13 +0000)
In --enable-static-modules mode, it was not possible to use "pam_unix"
in PAM config files.  Instead, different names had to be used for each
management group: pam_unix_auth, pam_unix_acct, pam_unix_passwd and
pam_unix_session.  This change makes pam_unix configuration consistent
with other PAM modules.

* README: Remove the paragraph describing pam_unix distinctions in
--enable-static-modules mode.
* libpam/pam_static_modules.h (_pam_unix_acct_modstruct,
_pam_unix_auth_modstruct, _pam_unix_passwd_modstruct,
_pam_unix_session_modstruct): Remove.
(_pam_unix_modstruct): New pam_module declaration.
* modules/pam_unix/pam_unix_static.h: New file.
* modules/pam_unix/pam_unix_static.c: Likewise.
* modules/pam_unix/Makefile.am (noinst_HEADERS): Add pam_unix_static.h
(pam_unix_la_SOURCES) [STATIC_MODULES]: Add pam_unix_static.c
* modules/pam_unix/pam_unix_acct.c [PAM_STATIC]: Include
pam_unix_static.h
[PAM_STATIC] (_pam_unix_acct_modstruct): Remove.
* modules/pam_unix/pam_unix_auth.c [PAM_STATIC]: Include
pam_unix_static.h
[PAM_STATIC] (_pam_unix_auth_modstruct): Remove.
* modules/pam_unix/pam_unix_passwd.c [PAM_STATIC]: Include
pam_unix_static.h
[PAM_STATIC] (_pam_unix_passwd_modstruct): Remove.
* modules/pam_unix/pam_unix_sess.c [PAM_STATIC]: Include
pam_unix_static.h
[PAM_STATIC] (_pam_unix_session_modstruct): Remove.

Suggested-by: Matveychikov Ilya <i.matveychikov@securitycode.ru>
README
libpam/pam_static_modules.h
modules/pam_unix/Makefile.am
modules/pam_unix/pam_unix_acct.c
modules/pam_unix/pam_unix_auth.c
modules/pam_unix/pam_unix_passwd.c
modules/pam_unix/pam_unix_sess.c
modules/pam_unix/pam_unix_static.c [new file with mode: 0644]
modules/pam_unix/pam_unix_static.h [new file with mode: 0644]

diff --git a/README b/README
index 81159140a689c9d7bfcc31c60f601415135ed68c..994dd95af5ce86de242ec977fe71d6bc311428e6 100644 (file)
--- a/README
+++ b/README
@@ -52,10 +52,6 @@ build a static libpam including all PAM modules, you have to call:
 
       ./configure --enable-static-modules --disable-pie
 
-In this case you cannot use pam_unix in the PAM config files instead you
-have to use pam_unix_acct, pam_unix_auth, pam_unix_passwd and
-pam_unix_session.
-
 To run the build checks with static modules, you need to run the
 following command: make -C test check && make check
 
index b1739ed147c4e7ca99305f5ca9ccc2552cfb71ed..698989bdb0e4ccf3464decaa110df696801421df 100644 (file)
@@ -80,10 +80,7 @@ extern struct pam_module _pam_timestamp_modstruct;
 extern struct pam_module _pam_tty_audit_modstruct;
 #endif
 extern struct pam_module _pam_umask_modstruct;
-extern struct pam_module _pam_unix_acct_modstruct;
-extern struct pam_module _pam_unix_auth_modstruct;
-extern struct pam_module _pam_unix_passwd_modstruct;
-extern struct pam_module _pam_unix_session_modstruct;
+extern struct pam_module _pam_unix_modstruct;
 extern struct pam_module _pam_userdb_modstruct;
 extern struct pam_module _pam_warn_modstruct;
 extern struct pam_module _pam_wheel_modstruct;
@@ -142,10 +139,7 @@ static struct pam_module *static_modules[] = {
   &_pam_tty_audit_modstruct,
 #endif
   &_pam_umask_modstruct,
-  &_pam_unix_acct_modstruct,
-  &_pam_unix_auth_modstruct,
-  &_pam_unix_passwd_modstruct,
-  &_pam_unix_session_modstruct,
+  &_pam_unix_modstruct,
   &_pam_userdb_modstruct,
   &_pam_warn_modstruct,
   &_pam_wheel_modstruct,
index ab0d55ac631e6f428e0813971042d10a748508a9..56ed591640b8282fbbbfe1d5365552ebca7cedd7 100644 (file)
@@ -34,7 +34,8 @@ pam_unix_la_LIBADD = $(top_builddir)/libpam/libpam.la \
 
 securelib_LTLIBRARIES = pam_unix.la
 
-noinst_HEADERS = md5.h support.h yppasswd.h bigcrypt.h passverify.h
+noinst_HEADERS = md5.h support.h yppasswd.h bigcrypt.h passverify.h \
+                pam_unix_static.h
 
 sbin_PROGRAMS = unix_chkpwd unix_update
 
@@ -43,6 +44,9 @@ noinst_PROGRAMS = bigcrypt
 pam_unix_la_SOURCES = bigcrypt.c pam_unix_acct.c \
        pam_unix_auth.c pam_unix_passwd.c pam_unix_sess.c support.c \
        passverify.c yppasswd_xdr.c md5_good.c md5_broken.c
+if STATIC_MODULES
+pam_unix_la_SOURCES += pam_unix_static.c
+endif
 
 bigcrypt_SOURCES = bigcrypt.c bigcrypt_main.c
 bigcrypt_CFLAGS = $(AM_CFLAGS)
index 2731b8bcd75efcf7410b8a3f2c7fe04c3a3909e8..8e90cc9ad4359f2fcb899c3f8f4a168002c990a2 100644 (file)
 
 /* indicate that the following groups are defined */
 
-#define PAM_SM_ACCOUNT
+#ifdef PAM_STATIC
+# include "pam_unix_static.h"
+#else
+# define PAM_SM_ACCOUNT
+#endif
 
 #include <security/pam_modules.h>
 #include <security/pam_ext.h>
@@ -178,8 +182,8 @@ int _unix_run_verify_binary(pam_handle_t *pamh, unsigned int ctrl,
  * account management module.
  */
 
-PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t * pamh, int flags,
-                               int argc, const char **argv)
+int
+pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv)
 {
        unsigned int ctrl;
        const void *void_uname;
@@ -291,17 +295,3 @@ PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t * pamh, int flags,
 
        return retval;
 }
-
-
-/* static module data */
-#ifdef PAM_STATIC
-struct pam_module _pam_unix_acct_modstruct = {
-    "pam_unix_acct",
-    NULL,
-    NULL,
-    pam_sm_acct_mgmt,
-    NULL,
-    NULL,
-    NULL,
-};
-#endif
index 1379d96cc8f38da21331df686dd7c856fab9049b..44573e6c108bd02f035258c15a8a221ac0549219 100644 (file)
 
 /* indicate the following groups are defined */
 
-#define PAM_SM_AUTH
+#ifdef PAM_STATIC
+# include "pam_unix_static.h"
+#else
+# define PAM_SM_AUTH
+#endif
 
 #define _PAM_EXTERN_FUNCTIONS
 #include <security/_pam_macros.h>
@@ -98,9 +102,8 @@ setcred_free (pam_handle_t *pamh UNUSED, void *ptr, int err UNUSED)
                free (ptr);
 }
 
-
-PAM_EXTERN int pam_sm_authenticate(pam_handle_t * pamh, int flags
-                                  ,int argc, const char **argv)
+int
+pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv)
 {
        unsigned int ctrl;
        int retval, *ret_data = NULL;
@@ -190,7 +193,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t * pamh, int flags
  * warned you. -- AOY
  */
 
-PAM_EXTERN int
+int
 pam_sm_setcred (pam_handle_t *pamh, int flags UNUSED,
                int argc UNUSED, const char **argv UNUSED)
 {
@@ -213,15 +216,3 @@ pam_sm_setcred (pam_handle_t *pamh, int flags UNUSED,
 
        return retval;
 }
-
-#ifdef PAM_STATIC
-struct pam_module _pam_unix_auth_modstruct = {
-    "pam_unix_auth",
-    pam_sm_authenticate,
-    pam_sm_setcred,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-};
-#endif
index 498a81c6ab179cedc15709c92118eeb391f7586b..e9059d3c3593e42e4da395cf27f09c607f21206c 100644 (file)
 
 /* indicate the following groups are defined */
 
-#define PAM_SM_PASSWORD
+#ifdef PAM_STATIC
+# include "pam_unix_static.h"
+#else
+# define PAM_SM_PASSWORD
+#endif
 
 #include <security/pam_modules.h>
 #include <security/pam_ext.h>
@@ -523,9 +527,8 @@ static int _pam_unix_approve_pass(pam_handle_t * pamh
        return retval;
 }
 
-
-PAM_EXTERN int pam_sm_chauthtok(pam_handle_t * pamh, int flags,
-                               int argc, const char **argv)
+int
+pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv)
 {
        unsigned int ctrl, lctrl;
        int retval;
@@ -823,17 +826,3 @@ PAM_EXTERN int pam_sm_chauthtok(pam_handle_t * pamh, int flags,
 
        return retval;
 }
-
-
-/* static module data */
-#ifdef PAM_STATIC
-struct pam_module _pam_unix_passwd_modstruct = {
-    "pam_unix_passwd",
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    pam_sm_chauthtok,
-};
-#endif
index 72046ea0796c83f88a0df632e943ee720a3c8cd4..d1376732e63c68804d001ac83f4be1c2337562b4 100644 (file)
 
 /* indicate the following groups are defined */
 
-#define PAM_SM_SESSION
+#ifdef PAM_STATIC
+# include "pam_unix_static.h"
+#else
+# define PAM_SM_SESSION
+#endif
 
 #include <security/_pam_macros.h>
 #include <security/pam_modules.h>
@@ -63,8 +67,8 @@
  * session module.
  */
 
-PAM_EXTERN int pam_sm_open_session(pam_handle_t * pamh, int flags,
-                                  int argc, const char **argv)
+int
+pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
 {
        char *user_name, *service;
        unsigned int ctrl;
@@ -98,8 +102,8 @@ PAM_EXTERN int pam_sm_open_session(pam_handle_t * pamh, int flags,
        return PAM_SUCCESS;
 }
 
-PAM_EXTERN int pam_sm_close_session(pam_handle_t * pamh, int flags,
-                                   int argc, const char **argv)
+int
+pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
 {
        char *user_name, *service;
        unsigned int ctrl;
@@ -127,16 +131,3 @@ PAM_EXTERN int pam_sm_close_session(pam_handle_t * pamh, int flags,
 
        return PAM_SUCCESS;
 }
-
-/* static module data */
-#ifdef PAM_STATIC
-struct pam_module _pam_unix_session_modstruct = {
-    "pam_unix_session",
-    NULL,
-    NULL,
-    NULL,
-    pam_sm_open_session,
-    pam_sm_close_session,
-    NULL,
-};
-#endif
diff --git a/modules/pam_unix/pam_unix_static.c b/modules/pam_unix/pam_unix_static.c
new file mode 100644 (file)
index 0000000..160268c
--- /dev/null
@@ -0,0 +1,23 @@
+#include "config.h"
+
+#ifdef PAM_STATIC
+
+#define static extern
+#define PAM_SM_ACCOUNT
+#define PAM_SM_AUTH
+#define PAM_SM_PASSWORD
+#define PAM_SM_SESSION
+#include "pam_unix_static.h"
+#include <security/pam_modules.h>
+
+struct pam_module _pam_unix_modstruct = {
+       "pam_unix",
+       pam_sm_authenticate,
+       pam_sm_setcred,
+       pam_sm_acct_mgmt,
+       pam_sm_open_session,
+       pam_sm_close_session,
+       pam_sm_chauthtok,
+};
+
+#endif
diff --git a/modules/pam_unix/pam_unix_static.h b/modules/pam_unix/pam_unix_static.h
new file mode 100644 (file)
index 0000000..39b05ef
--- /dev/null
@@ -0,0 +1,6 @@
+#define pam_sm_acct_mgmt _pam_unix_sm_acct_mgmt
+#define pam_sm_authenticate _pam_unix_sm_authenticate
+#define pam_sm_setcred _pam_unix_sm_setcred
+#define pam_sm_chauthtok _pam_unix_sm_chauthtok
+#define pam_sm_open_session _pam_unix_sm_open_session
+#define pam_sm_close_session _pam_unix_sm_close_session