pam: share pam errors in a common location.
authorGünther Deschner <gd@samba.org>
Tue, 8 Feb 2011 09:45:39 +0000 (10:45 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 8 Feb 2011 13:05:36 +0000 (14:05 +0100)
Guenther

15 files changed:
libcli/auth/pam_errors.c [moved from source3/lib/pam_errors.c with 98% similarity]
libcli/auth/pam_errors.h [moved from source4/auth/ntlm/pam_errors.h with 90% similarity]
libcli/auth/wscript_build
source3/Makefile.in
source3/auth/pampass.c
source3/include/proto.h
source3/pam_smbpass/general.h
source3/pam_smbpass/wscript_build
source3/winbindd/winbindd_util.c
source3/wscript_build
source4/auth/ntlm/auth_unix.c
source4/auth/ntlm/pam_errors.c [deleted file]
source4/auth/ntlm/wscript_build
source4/torture/winbind/struct_based.c
source4/winbind/wb_samba3_cmd.c

similarity index 98%
rename from source3/lib/pam_errors.c
rename to libcli/auth/pam_errors.c
index e55d7a0415f87191b6c861140aeb46aae5656287..978f8ffdde322982312ec0d6c57f3909d2c37156 100644 (file)
@@ -1,23 +1,24 @@
-/* 
+/*
  *  Unix SMB/CIFS implementation.
  *  PAM error mapping functions
  *  Copyright (C) Andrew Bartlett 2002
- *  
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "includes.h"
+#include "../libcli/auth/pam_errors.h"
 
 #ifdef WITH_PAM
 #if defined(HAVE_SECURITY_PAM_APPL_H)
@@ -28,7 +29,7 @@
 
 #if defined(PAM_AUTHTOK_RECOVERY_ERR) && !defined(PAM_AUTHTOK_RECOVER_ERR)
 #define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
-#endif 
+#endif
 
 /* PAM -> NT_STATUS map */
 static const struct {
@@ -115,7 +116,7 @@ int nt_status_to_pam(NTSTATUS nt_status)
        return PAM_SYSTEM_ERR;
 }
 
-#else 
+#else
 
 /*****************************************************************************
 convert a PAM error to a NT status32 code
@@ -136,4 +137,3 @@ int nt_status_to_pam(NTSTATUS nt_status)
 }
 
 #endif
-
similarity index 90%
rename from source4/auth/ntlm/pam_errors.h
rename to libcli/auth/pam_errors.h
index 2dfe085b770a75dd5c776876cb52e47d65980d92..128910fa717b73029214879cf05f44d95d584916 100644 (file)
@@ -1,24 +1,24 @@
-/* 
+/*
  *  Unix SMB/CIFS implementation.
  *  PAM error mapping functions
  *  Copyright (C) Andrew Bartlett 2002
- *  
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __AUTH_NTLM_PAM_ERRORS_H__
-#define __AUTH_NTLM_PAM_ERRORS_H__
+#ifndef __LIBCLI_AUTH_PAM_ERRORS_H__
+#define __LIBCLI_AUTH_PAM_ERRORS_H__
 
 /*****************************************************************************
 convert a PAM error to a NT status32 code
@@ -30,5 +30,4 @@ convert an NT status32 code to a PAM error
  *****************************************************************************/
 int nt_status_to_pam(NTSTATUS nt_status);
 
-#endif /* __AUTH_NTLM_PAM_ERRORS_H__ */
-
+#endif /* __LIBCLI_AUTH_PAM_ERRORS_H__ */
index 26b7438aa415e765e76fc3b794bfeef96aaad743..c47c6f79a113298f7f1ee091c6d1a35bc32aa7ea 100644 (file)
@@ -24,3 +24,7 @@ bld.SAMBA_SUBSYSTEM('COMMON_SCHANNELDB',
        deps='tdb-wrap'
        )
 
+
+bld.SAMBA_SUBSYSTEM('PAM_ERRORS',
+       source='pam_errors.c'
+       )
index 27de07eb0bc3d96e3ba878360796f242d31c334b..2055a6e8dc415c7d54f6b20300f53bda6ce8c5aa 100644 (file)
@@ -457,7 +457,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
          lib/ms_fnmatch.o lib/errmap_unix.o \
          lib/tallocmsg.o lib/dmallocmsg.o \
          libsmb/clisigning.o libsmb/smb_signing.o \
-         lib/iconv.o lib/pam_errors.o intl/lang_tdb.o \
+         lib/iconv.o intl/lang_tdb.o \
          lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \
          lib/sessionid_tdb.o \
          lib/module.o lib/events.o @LIBTEVENT_OBJ0@ \
@@ -838,7 +838,8 @@ VFS_CROSSRENAME_OBJ = modules/vfs_crossrename.o
 VFS_LINUX_XFS_SGID_OBJ = modules/vfs_linux_xfs_sgid.o
 VFS_TIME_AUDIT_OBJ = modules/vfs_time_audit.o
 
-PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o
+PAM_ERRORS_OBJ = ../libcli/auth/pam_errors.o
+PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o $(PAM_ERRORS_OBJ)
 
 SLCACHE_OBJ = libsmb/samlogon_cache.o
 
@@ -1294,7 +1295,7 @@ PAM_SMBPASS_OBJ_0 = pam_smbpass/pam_smb_auth.o pam_smbpass/pam_smb_passwd.o \
                pam_smbpass/pam_smb_acct.o pam_smbpass/support.o ../lib/util/asn1.o
 PAM_SMBPASS_OBJ = $(PAM_SMBPASS_OBJ_0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
                $(SMBLDAP_OBJ) $(LIBSAMBA_OBJ) \
-               $(LIBTSOCKET_OBJ)
+               $(LIBTSOCKET_OBJ) $(PAM_ERRORS_OBJ)
 
 IDMAP_RW_OBJ = winbindd/idmap_rw.o
 
@@ -1427,7 +1428,8 @@ WINBINDD_OBJ = \
                $(LIBCLI_SAMR_OBJ) \
                $(LIBCLI_NETLOGON_OBJ) \
                rpc_client/init_netlogon.o \
-               rpc_client/init_samr.o
+               rpc_client/init_samr.o \
+               $(PAM_ERRORS_OBJ)
 
 WBINFO_OBJ = ../nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
                $(POPT_LIB_OBJ) $(AFS_SETTOKEN_OBJ) \
index dfeeb22588e7d32d6fe01c204b0937f82634873a..a4f136c5b8bd0fd681396e98c91649a9138545ff 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include "includes.h"
+#include "../libcli/auth/pam_errors.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
index a50917762f7f2fe379d1bee3cc1fdb8bd67e0980..2f2c62747dd643772ef8ff6cfd5cd0f60e5ad6ad 100644 (file)
@@ -608,13 +608,6 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
               bool is_case_sensitive);
 int gen_fnmatch(const char *pattern, const char *string);
 
-/* The following definitions come from lib/pam_errors.c  */
-
-NTSTATUS pam_to_nt_status(int pam_error);
-int nt_status_to_pam(NTSTATUS nt_status);
-NTSTATUS pam_to_nt_status(int pam_error);
-int nt_status_to_pam(NTSTATUS nt_status);
-
 /* The following definitions come from lib/pidfile.c  */
 
 pid_t pidfile_pid(const char *name);
index f6b3e672aeeeccebd5f4802039f4695b6d9e4a2e..74bd870bc5843cb4f339ba3319b51792edb391cd 100644 (file)
@@ -1,4 +1,5 @@
 #include "../librpc/gen_ndr/samr.h"
+#include "../libcli/auth/pam_errors.h"
 
 #ifndef LINUX
 /* This is only needed by modules in the Sun implementation. */
index 1a43bcea71bfb9c593ff744f0b770ffd9e2ba3ad..2eaee2ea98890ad8583da56db091b1d857bcdad2 100644 (file)
@@ -6,7 +6,7 @@ if bld.CONFIG_SET('WITH_PAM_MODULES'):
                   pam_smb_passwd.c
                   pam_smb_acct.c
                   support.c''',
-        deps='''tdb talloc pam wbclient cap ASN1_UTIL PARAM LIB_NONSMBD PASSDB GROUPDB SMBLDAP
+        deps='''tdb talloc pam PAM_ERRORS wbclient cap ASN1_UTIL PARAM LIB_NONSMBD PASSDB GROUPDB SMBLDAP
                 LIBSAMBA LIBTSOCKET''',
         cflags='-DLOCALEDIR=\"%s/locale\"' % bld.env.DATADIR,
         realname='pam_smbpass.so',
index 58cec444aaf95b0bf9da33becb7f94df01a3d034..e87f25e18f4af735669961d93eee9abcb03607f8 100644 (file)
@@ -24,6 +24,7 @@
 #include "winbindd.h"
 #include "secrets.h"
 #include "../libcli/security/security.h"
+#include "../libcli/auth/pam_errors.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
index a799e1ac8a3d0065250dc5272ab7e25f51ec9e28..35e45d758c1a0d849adab36d7237de17c5f8fa4d 100644 (file)
@@ -101,7 +101,7 @@ LIB_SRC = '''${LIBSAMBAUTIL_SRC}
           lib/ms_fnmatch.c lib/errmap_unix.c
           lib/tallocmsg.c lib/dmallocmsg.c
           libsmb/clisigning.c libsmb/smb_signing.c
-          lib/pam_errors.c intl/lang_tdb.c
+          intl/lang_tdb.c
           lib/conn_tdb.c lib/adt_tree.c lib/gencache.c
           lib/sessionid_tdb.c
           lib/module.c lib/events.c ${LIBTEVENT_SRC0}
@@ -995,7 +995,7 @@ bld.SAMBA_SUBSYSTEM('SERVICES',
 
 bld.SAMBA_SUBSYSTEM('PLAINTEXT_AUTH',
                     source=PLAINTEXT_AUTH_SRC,
-                    deps='pam',
+                    deps='pam PAM_ERRORS',
                     vars=locals())
 
 bld.SAMBA_SUBSYSTEM('PASSCHANGE',
@@ -1133,6 +1133,7 @@ bld.SAMBA_BINARY('winbindd/winbindd',
                  LIBCLI_SAMR LIBCLI_LSA LIBRPCCLI_NETLOGON
                  RPC_NDR_DSSETUP NAMED_PIPE_AUTH_TSTREAM INIT_NETLOGON
                  RPC_NCACN_NP RPC_PIPE_REGISTER RPC_SAMR RPC_LSARPC
+                 PAM_ERRORS
                  ''',
                  enabled=bld.env.build_winbind,
                  install_path='${SBINDIR}',
index ba37e0a95ec7e4f7ebd04482c8b234c8683e193e..08759aba6741d7af30db37072da5c6651d914a69 100644 (file)
@@ -25,7 +25,7 @@
 #include "system/passwd.h" /* needed by some systems for struct passwd */
 #include "lib/socket/socket.h"
 #include "lib/tsocket/tsocket.h"
-#include "auth/ntlm/pam_errors.h"
+#include "../libcli/auth/pam_errors.h"
 #include "param/param.h"
 
 /* TODO: look at how to best fill in parms retrieveing a struct passwd info
diff --git a/source4/auth/ntlm/pam_errors.c b/source4/auth/ntlm/pam_errors.c
deleted file mode 100644 (file)
index 9774ad8..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* 
- *  Unix SMB/CIFS implementation.
- *  PAM error mapping functions
- *  Copyright (C) Andrew Bartlett 2002
- *  
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "includes.h"
-
-#ifdef WITH_HAVE_SECURITY_PAM_APPL_H
-#include <security/pam_appl.h>
-
-#if defined(PAM_AUTHTOK_RECOVERY_ERR) && !defined(PAM_AUTHTOK_RECOVER_ERR)
-#define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
-#endif 
-
-/* PAM -> NT_STATUS map */
-static const struct {
-       int pam_code;
-       NTSTATUS ntstatus;
-} pam_to_nt_status_map[] = {
-       {PAM_OPEN_ERR, NT_STATUS_UNSUCCESSFUL},
-       {PAM_SYMBOL_ERR, NT_STATUS_UNSUCCESSFUL},
-       {PAM_SERVICE_ERR, NT_STATUS_UNSUCCESSFUL},
-       {PAM_SYSTEM_ERR,  NT_STATUS_UNSUCCESSFUL},
-       {PAM_BUF_ERR, NT_STATUS_UNSUCCESSFUL},
-       {PAM_PERM_DENIED, NT_STATUS_ACCESS_DENIED},
-       {PAM_AUTH_ERR, NT_STATUS_WRONG_PASSWORD},
-       {PAM_CRED_INSUFFICIENT, NT_STATUS_INSUFFICIENT_LOGON_INFO}, /* FIXME:  Is this correct? */
-       {PAM_AUTHINFO_UNAVAIL, NT_STATUS_LOGON_FAILURE},
-       {PAM_USER_UNKNOWN, NT_STATUS_NO_SUCH_USER},
-       {PAM_MAXTRIES, NT_STATUS_REMOTE_SESSION_LIMIT}, /* FIXME:  Is this correct? */
-       {PAM_NEW_AUTHTOK_REQD, NT_STATUS_PASSWORD_MUST_CHANGE},
-       {PAM_ACCT_EXPIRED, NT_STATUS_ACCOUNT_EXPIRED},
-       {PAM_SESSION_ERR, NT_STATUS_INSUFFICIENT_RESOURCES},
-       {PAM_CRED_UNAVAIL, NT_STATUS_NO_TOKEN},  /* FIXME:  Is this correct? */
-       {PAM_CRED_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},  /* FIXME:  Is this correct? */
-       {PAM_CRED_ERR, NT_STATUS_UNSUCCESSFUL},
-       {PAM_AUTHTOK_ERR, NT_STATUS_UNSUCCESSFUL},
-#ifdef PAM_AUTHTOK_RECOVER_ERR
-       {PAM_AUTHTOK_RECOVER_ERR, NT_STATUS_UNSUCCESSFUL},
-#endif
-       {PAM_AUTHTOK_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},
-       {PAM_SUCCESS, NT_STATUS_OK}
-};
-
-/* NT_STATUS -> PAM map */
-static const struct {
-       NTSTATUS ntstatus;
-       int pam_code;
-} nt_status_to_pam_map[] = {
-       {NT_STATUS_UNSUCCESSFUL, PAM_SYSTEM_ERR},
-       {NT_STATUS_NO_SUCH_USER, PAM_USER_UNKNOWN},
-       {NT_STATUS_WRONG_PASSWORD, PAM_AUTH_ERR},
-       {NT_STATUS_LOGON_FAILURE, PAM_AUTH_ERR},
-       {NT_STATUS_ACCOUNT_EXPIRED, PAM_ACCT_EXPIRED},
-       {NT_STATUS_PASSWORD_EXPIRED, PAM_AUTHTOK_EXPIRED},
-       {NT_STATUS_PASSWORD_MUST_CHANGE, PAM_NEW_AUTHTOK_REQD},
-       {NT_STATUS_OK, PAM_SUCCESS}
-};
-
-/*****************************************************************************
-convert a PAM error to a NT status32 code
- *****************************************************************************/
-NTSTATUS pam_to_nt_status(int pam_error)
-{
-       int i;
-       if (pam_error == 0) return NT_STATUS_OK;
-       
-       for (i=0; NT_STATUS_V(pam_to_nt_status_map[i].ntstatus); i++) {
-               if (pam_error == pam_to_nt_status_map[i].pam_code)
-                       return pam_to_nt_status_map[i].ntstatus;
-       }
-       return NT_STATUS_UNSUCCESSFUL;
-}
-
-/*****************************************************************************
-convert an NT status32 code to a PAM error
- *****************************************************************************/
-int nt_status_to_pam(NTSTATUS nt_status)
-{
-       int i;
-       if NT_STATUS_IS_OK(nt_status) return PAM_SUCCESS;
-       
-       for (i=0; NT_STATUS_V(nt_status_to_pam_map[i].ntstatus); i++) {
-               if (NT_STATUS_EQUAL(nt_status,nt_status_to_pam_map[i].ntstatus))
-                       return nt_status_to_pam_map[i].pam_code;
-       }
-       return PAM_SYSTEM_ERR;
-}
-
-#else 
-
-/*****************************************************************************
-convert a PAM error to a NT status32 code
- *****************************************************************************/
-NTSTATUS pam_to_nt_status(int pam_error)
-{
-       if (pam_error == 0) return NT_STATUS_OK;
-       return NT_STATUS_UNSUCCESSFUL;
-}
-
-/*****************************************************************************
-convert an NT status32 code to a PAM error
- *****************************************************************************/
-int nt_status_to_pam(NTSTATUS nt_status)
-{
-       if (NT_STATUS_EQUAL(nt_status, NT_STATUS_OK)) return 0;
-       return 4; /* PAM_SYSTEM_ERR */
-}
-
-#endif
-
index 8063076b66bf1e3009247ef875cf5ee05d57eda5..b0f519f1c6bd1de98f9d5f32c18396b34aba5c14 100644 (file)
@@ -48,12 +48,6 @@ bld.SAMBA_MODULE('auth_unix',
        )
 
 
-bld.SAMBA_SUBSYSTEM('PAM_ERRORS',
-       source='pam_errors.c',
-       deps='talloc'
-       )
-
-
 bld.SAMBA_LIBRARY('auth',
        source='auth.c auth_util.c auth_simple.c',
        autoproto='auth_proto.h',
index ea81871250a06bb012433eb8d37a56dc0164a298..cb353158d400c7b8cfe573a320aff2f691685cc2 100644 (file)
@@ -24,7 +24,7 @@
 #include "libcli/security/security.h"
 #include "librpc/gen_ndr/netlogon.h"
 #include "param/param.h"
-#include "auth/ntlm/pam_errors.h"
+#include "../libcli/auth/pam_errors.h"
 
 #define DO_STRUCT_REQ_REP_EXT(op,req,rep,expected,strict,warnaction,cmt) do { \
        NSS_STATUS __got, __expected = (expected); \
index 9b8f8e06632a86a2a5a89cdac44481b059148713..7ceee4193e838c14105817e51607302a0b8ce2d3 100644 (file)
@@ -29,7 +29,7 @@
 #include "version.h"
 #include "librpc/gen_ndr/ndr_netlogon.h"
 #include "libcli/security/security.h"
-#include "auth/ntlm/pam_errors.h"
+#include "../libcli/auth/pam_errors.h"
 #include "auth/credentials/credentials.h"
 #include "smbd/service_task.h"