summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-02-08 10:45:39 +0100
committerGünther Deschner <gd@samba.org>2011-02-08 14:05:36 +0100
commit34722c72f687ad8a357656152aed9f6bafab1cad (patch)
tree4b0c82937608c623336186acc09940035706c01b
parent242797aca93a2f8d1e1670a1eaeb5d8e5cd07a1d (diff)
downloadsamba-34722c72f687ad8a357656152aed9f6bafab1cad.tar.gz
samba-34722c72f687ad8a357656152aed9f6bafab1cad.tar.bz2
samba-34722c72f687ad8a357656152aed9f6bafab1cad.zip
pam: share pam errors in a common location.
Guenther
-rw-r--r--libcli/auth/pam_errors.c (renamed from source3/lib/pam_errors.c)14
-rw-r--r--libcli/auth/pam_errors.h (renamed from source4/auth/ntlm/pam_errors.h)15
-rw-r--r--libcli/auth/wscript_build4
-rw-r--r--source3/Makefile.in10
-rw-r--r--source3/auth/pampass.c1
-rw-r--r--source3/include/proto.h7
-rw-r--r--source3/pam_smbpass/general.h1
-rw-r--r--source3/pam_smbpass/wscript_build2
-rw-r--r--source3/winbindd/winbindd_util.c1
-rw-r--r--source3/wscript_build5
-rw-r--r--source4/auth/ntlm/auth_unix.c2
-rw-r--r--source4/auth/ntlm/pam_errors.c125
-rw-r--r--source4/auth/ntlm/wscript_build6
-rw-r--r--source4/torture/winbind/struct_based.c2
-rw-r--r--source4/winbind/wb_samba3_cmd.c2
15 files changed, 34 insertions, 163 deletions
diff --git a/source3/lib/pam_errors.c b/libcli/auth/pam_errors.c
index e55d7a0415..978f8ffdde 100644
--- a/source3/lib/pam_errors.c
+++ b/libcli/auth/pam_errors.c
@@ -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
-
diff --git a/source4/auth/ntlm/pam_errors.h b/libcli/auth/pam_errors.h
index 2dfe085b77..128910fa71 100644
--- a/source4/auth/ntlm/pam_errors.h
+++ b/libcli/auth/pam_errors.h
@@ -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__ */
diff --git a/libcli/auth/wscript_build b/libcli/auth/wscript_build
index 26b7438aa4..c47c6f79a1 100644
--- a/libcli/auth/wscript_build
+++ b/libcli/auth/wscript_build
@@ -24,3 +24,7 @@ bld.SAMBA_SUBSYSTEM('COMMON_SCHANNELDB',
deps='tdb-wrap'
)
+
+bld.SAMBA_SUBSYSTEM('PAM_ERRORS',
+ source='pam_errors.c'
+ )
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 27de07eb0b..2055a6e8dc 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -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) \
diff --git a/source3/auth/pampass.c b/source3/auth/pampass.c
index dfeeb22588..a4f136c5b8 100644
--- a/source3/auth/pampass.c
+++ b/source3/auth/pampass.c
@@ -27,6 +27,7 @@
*/
#include "includes.h"
+#include "../libcli/auth/pam_errors.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a50917762f..2f2c62747d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -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);
diff --git a/source3/pam_smbpass/general.h b/source3/pam_smbpass/general.h
index f6b3e672ae..74bd870bc5 100644
--- a/source3/pam_smbpass/general.h
+++ b/source3/pam_smbpass/general.h
@@ -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. */
diff --git a/source3/pam_smbpass/wscript_build b/source3/pam_smbpass/wscript_build
index 1a43bcea71..2eaee2ea98 100644
--- a/source3/pam_smbpass/wscript_build
+++ b/source3/pam_smbpass/wscript_build
@@ -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',
diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index 58cec444aa..e87f25e18f 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -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
diff --git a/source3/wscript_build b/source3/wscript_build
index a799e1ac8a..35e45d758c 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -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}',
diff --git a/source4/auth/ntlm/auth_unix.c b/source4/auth/ntlm/auth_unix.c
index ba37e0a95e..08759aba67 100644
--- a/source4/auth/ntlm/auth_unix.c
+++ b/source4/auth/ntlm/auth_unix.c
@@ -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
index 9774ad8727..0000000000
--- a/source4/auth/ntlm/pam_errors.c
+++ /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
-
diff --git a/source4/auth/ntlm/wscript_build b/source4/auth/ntlm/wscript_build
index 8063076b66..b0f519f1c6 100644
--- a/source4/auth/ntlm/wscript_build
+++ b/source4/auth/ntlm/wscript_build
@@ -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',
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index ea81871250..cb353158d4 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -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); \
diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c
index 9b8f8e0663..7ceee4193e 100644
--- a/source4/winbind/wb_samba3_cmd.c
+++ b/source4/winbind/wb_samba3_cmd.c
@@ -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"