source: vendor/current/source3/lib/pam_errors.c@ 597

Last change on this file since 597 was 414, checked in by Herwig Bauernfeind, 16 years ago

Samba 3.5.0: Initial import

File size: 4.9 KB
Line 
1/*
2 * Unix SMB/CIFS implementation.
3 * PAM error mapping functions
4 * Copyright (C) Andrew Bartlett 2002
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "includes.h"
21
22#ifdef WITH_PAM
23#if defined(HAVE_SECURITY_PAM_APPL_H)
24#include <security/pam_appl.h>
25#elif defined(HAVE_PAM_PAM_APPL_H)
26#include <pam/pam_appl.h>
27#endif
28
29#if defined(PAM_AUTHTOK_RECOVERY_ERR) && !defined(PAM_AUTHTOK_RECOVER_ERR)
30#define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
31#endif
32
33/* PAM -> NT_STATUS map */
34static const struct {
35 int pam_code;
36 NTSTATUS ntstatus;
37} pam_to_nt_status_map[] = {
38 {PAM_OPEN_ERR, NT_STATUS_UNSUCCESSFUL},
39 {PAM_SYMBOL_ERR, NT_STATUS_UNSUCCESSFUL},
40 {PAM_SERVICE_ERR, NT_STATUS_UNSUCCESSFUL},
41 {PAM_SYSTEM_ERR, NT_STATUS_UNSUCCESSFUL},
42 {PAM_BUF_ERR, NT_STATUS_NO_MEMORY},
43 {PAM_PERM_DENIED, NT_STATUS_ACCESS_DENIED},
44 {PAM_AUTH_ERR, NT_STATUS_WRONG_PASSWORD},
45 {PAM_CRED_INSUFFICIENT, NT_STATUS_INSUFFICIENT_LOGON_INFO}, /* FIXME: Is this correct? */
46 {PAM_AUTHINFO_UNAVAIL, NT_STATUS_LOGON_FAILURE},
47 {PAM_USER_UNKNOWN, NT_STATUS_NO_SUCH_USER},
48 {PAM_MAXTRIES, NT_STATUS_REMOTE_SESSION_LIMIT}, /* FIXME: Is this correct? */
49 {PAM_NEW_AUTHTOK_REQD, NT_STATUS_PASSWORD_MUST_CHANGE},
50 {PAM_ACCT_EXPIRED, NT_STATUS_ACCOUNT_EXPIRED},
51 {PAM_SESSION_ERR, NT_STATUS_INSUFFICIENT_RESOURCES},
52 {PAM_CRED_UNAVAIL, NT_STATUS_NO_TOKEN}, /* FIXME: Is this correct? */
53 {PAM_CRED_EXPIRED, NT_STATUS_PASSWORD_EXPIRED}, /* FIXME: Is this correct? */
54 {PAM_CRED_ERR, NT_STATUS_UNSUCCESSFUL},
55 {PAM_AUTHTOK_ERR, NT_STATUS_UNSUCCESSFUL},
56#ifdef PAM_AUTHTOK_RECOVER_ERR
57 {PAM_AUTHTOK_RECOVER_ERR, NT_STATUS_UNSUCCESSFUL},
58#endif
59 {PAM_AUTHTOK_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},
60 {PAM_SUCCESS, NT_STATUS_OK}
61};
62
63/* NT_STATUS -> PAM map */
64static const struct {
65 NTSTATUS ntstatus;
66 int pam_code;
67} nt_status_to_pam_map[] = {
68 {NT_STATUS_UNSUCCESSFUL, PAM_SYSTEM_ERR},
69 {NT_STATUS_NO_SUCH_USER, PAM_USER_UNKNOWN},
70 {NT_STATUS_WRONG_PASSWORD, PAM_AUTH_ERR},
71 {NT_STATUS_LOGON_FAILURE, PAM_AUTH_ERR},
72 {NT_STATUS_ACCOUNT_EXPIRED, PAM_ACCT_EXPIRED},
73 {NT_STATUS_PASSWORD_EXPIRED, PAM_AUTHTOK_EXPIRED},