s/pxeldr/pxeboot/
[dragonfly.git] / contrib / openpam / lib / pam_strerror.c
1 /*-
2  * Copyright (c) 2002-2003 Networks Associates Technology, Inc.
3  * All rights reserved.
4  *
5  * This software was developed for the FreeBSD Project by ThinkSec AS and
6  * Network Associates Laboratories, the Security Research Division of
7  * Network Associates, Inc.  under DARPA/SPAWAR contract N66001-01-C-8035
8  * ("CBOSS"), as part of the DARPA CHATS research program.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote
19  *    products derived from this software without specific prior written
20  *    permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $P4: //depot/projects/openpam/lib/pam_strerror.c#13 $
35  */
36
37 #include <stdio.h>
38
39 #include <security/pam_appl.h>
40
41 #include "openpam_impl.h"
42
43 const char *_pam_err_name[PAM_NUM_ERRORS] = {
44         "PAM_SUCCESS",
45         "PAM_OPEN_ERR",
46         "PAM_SYMBOL_ERR",
47         "PAM_SERVICE_ERR",
48         "PAM_SYSTEM_ERR",
49         "PAM_BUF_ERR",
50         "PAM_CONV_ERR",
51         "PAM_PERM_DENIED",
52         "PAM_MAXTRIES",
53         "PAM_AUTH_ERR",
54         "PAM_NEW_AUTHTOK_REQD",
55         "PAM_CRED_INSUFFICIENT",
56         "PAM_AUTHINFO_UNAVAIL",
57         "PAM_USER_UNKNOWN",
58         "PAM_CRED_UNAVAIL",
59         "PAM_CRED_EXPIRED",
60         "PAM_CRED_ERR",
61         "PAM_ACCT_EXPIRED",
62         "PAM_AUTHTOK_EXPIRED",
63         "PAM_SESSION_ERR",
64         "PAM_AUTHTOK_ERR",
65         "PAM_AUTHTOK_RECOVERY_ERR",
66         "PAM_AUTHTOK_LOCK_BUSY",
67         "PAM_AUTHTOK_DISABLE_AGING",
68         "PAM_NO_MODULE_DATA",
69         "PAM_IGNORE",
70         "PAM_ABORT",
71         "PAM_TRY_AGAIN",
72         "PAM_MODULE_UNKNOWN",
73         "PAM_DOMAIN_UNKNOWN"
74 };
75
76 /*
77  * XSSO 4.2.1
78  * XSSO 6 page 92
79  *
80  * Get PAM standard error message string
81  */
82
83 const char *
84 pam_strerror(pam_handle_t *pamh,
85         int error_number)
86 {
87         static char unknown[16];
88
89         (void)pamh;
90
91         switch (error_number) {
92         case PAM_SUCCESS:
93                 return ("success");
94         case PAM_OPEN_ERR:
95                 return ("failed to load module");
96         case PAM_SYMBOL_ERR:
97                 return ("invalid symbol");
98         case PAM_SERVICE_ERR:
99                 return ("error in service module");
100         case PAM_SYSTEM_ERR:
101                 return ("system error");
102         case PAM_BUF_ERR:
103                 return ("memory buffer error");
104         case PAM_CONV_ERR:
105                 return ("conversation failure");
106         case PAM_PERM_DENIED:
107                 return ("permission denied");
108         case PAM_MAXTRIES:
109                 return ("maximum number of tries exceeded");
110         case PAM_AUTH_ERR:
111                 return ("authentication error");
112         case PAM_NEW_AUTHTOK_REQD:
113                 return ("new authentication token required");
114         case PAM_CRED_INSUFFICIENT:
115                 return ("insufficient credentials");
116         case PAM_AUTHINFO_UNAVAIL:
117                 return ("authentication information is unavailable");
118         case PAM_USER_UNKNOWN:
119                 return ("unknown user");
120         case PAM_CRED_UNAVAIL:
121                 return ("failed to retrieve user credentials");
122         case PAM_CRED_EXPIRED:
123                 return ("user credentials have expired");
124         case PAM_CRED_ERR:
125                 return ("failed to set user credentials");
126         case PAM_ACCT_EXPIRED:
127                 return ("user account has expired");
128         case PAM_AUTHTOK_EXPIRED:
129                 return ("password has expired");
130         case PAM_SESSION_ERR:
131                 return ("session failure");
132         case PAM_AUTHTOK_ERR:
133                 return ("authentication token failure");
134         case PAM_AUTHTOK_RECOVERY_ERR:
135                 return ("failed to recover old authentication token");
136         case PAM_AUTHTOK_LOCK_BUSY:
137                 return ("authentication token lock busy");
138         case PAM_AUTHTOK_DISABLE_AGING:
139                 return ("authentication token aging disabled");
140         case PAM_NO_MODULE_DATA:
141                 return ("module data not found");
142         case PAM_IGNORE:
143                 return ("ignore this module");
144         case PAM_ABORT:
145                 return ("general failure");
146         case PAM_TRY_AGAIN:
147                 return ("try again");
148         case PAM_MODULE_UNKNOWN:
149                 return ("unknown module type");
150         case PAM_DOMAIN_UNKNOWN:
151                 return ("unknown authentication domain");
152         default:
153                 snprintf(unknown, sizeof unknown, "#%d", error_number);
154                 return (unknown);
155         }
156 }
157
158 /**
159  * The =pam_strerror function returns a pointer to a string containing a
160  * textual description of the error indicated by the =error_number
161  * argument, in the context of the PAM transaction described by the =pamh
162  * argument.
163  */