Initial release, version 0.0.0.
[gsasl.git] / lib / error.c
blob87ab7070760a3e0b483642eb2cf92585174abb5c
1 /* error.c error handling functionality
2 * Copyright (C) 2002 Simon Josefsson
4 * This file is part of libgsasl.
6 * Libgsasl is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libgsasl 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with libgsasl; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "internal.h"
24 /**
25 * gsasl_strerror:
26 * @err: libgsasl error code
28 * Return value: Returns a pointer to a statically allocated string
29 * containing a description of the error with the error value
30 * @var{err}. This string can be used to output a diagnostic message
31 * to the user.
32 **/
33 const char *
34 gsasl_strerror (int err)
36 const char *p;
38 switch (err)
40 case GSASL_OK:
41 p = _("Libgsasl success");
42 break;
44 case GSASL_NEEDS_MORE:
45 p = _("SASL mechanisms needs more data (application error)");
46 break;
48 case GSASL_UNKNOWN_MECHANISM:
49 p = _("Unknown SASL mechanism (application error)");
50 break;
52 case GSASL_MECHANISM_CALLED_TOO_MANY_TIMES:
53 p = _("SASL mechanism called too many times (application error)");
54 break;
56 case GSASL_TOO_SMALL_BUFFER:
57 p = _("SASL function need larger buffer (application error)");
58 break;
60 case GSASL_FOPEN_ERROR:
61 p = _("Could not open file in SASL library");
62 break;
64 case GSASL_FCLOSE_ERROR:
65 p = _("Could not close file in SASL library");
66 break;
68 case GSASL_MALLOC_ERROR:
69 p = _("Memory allocation error in SASL library");
70 break;
72 case GSASL_BASE64_ERROR:
73 p = _("Base 64 coding error in SASL library");
74 break;
76 case GSASL_GCRYPT_ERROR:
77 p = _("Gcrypt error in SASL library");
78 break;
80 case GSASL_GSSAPI_RELEASE_BUFFER_ERROR:
81 p = _("GSSAPI library could not deallocate memory in gss_release_buffer() in SASL library. This is a serious internal error.");
82 break;
84 case GSASL_GSSAPI_IMPORT_NAME_ERROR:
85 p = _("GSSAPI library could not understand a peer name in gss_import_name() in SASL library. This may be due to incorrect user supplied data.");
86 break;
88 case GSASL_GSSAPI_INIT_SEC_CONTEXT_ERROR:
89 p = _("GSSAPI error in client while negotiating security context in gss_init_sec_context() in SASL library. This is most likely due insufficient credentials or malicious interactions.");
90 break;
92 case GSASL_GSSAPI_ACCEPT_SEC_CONTEXT_ERROR:
93 p = _("GSSAPI error in server while negotiating security context in gss_init_sec_context() in SASL library. This is most likely due insufficient credentials or malicious interactions.");
94 break;
96 case GSASL_GSSAPI_UNWRAP_ERROR:
97 p = _("GSSAPI error while decrypting or decoding data in gss_unwrap() in SASL library. This is most likely due to data corruption.");
98 break;
100 case GSASL_GSSAPI_WRAP_ERROR:
101 p = _("GSSAPI error while encrypting or encoding data in gss_wrap() in SASL library.");
102 break;
104 case GSASL_GSSAPI_ACQUIRE_CRED_ERROR:
105 p = _("GSSAPI error acquiring credentials in gss_acquire_cred() in SASL library. This is most likely due to not having the proper Kerberos key available in /etc/krb5.keytab on the server.");
106 break;
108 case GSASL_GSSAPI_DISPLAY_NAME_ERROR:
109 p = _("GSSAPI error creating a display name denoting the client in gss_display_name() in SASL library. This is probably because the client suplied bad data.");
110 break;
112 case GSASL_GSSAPI_UNSUPPORTED_PROTECTION_ERROR:
113 p = _("Other entity requested integrity or confidentiality protection in GSSAPI mechanism but this is currently not implemented.");
114 break;
116 case GSASL_NEED_CLIENT_ANONYMOUS_CALLBACK:
117 p = _("SASL mechanism needs gsasl_client_callback_anonymous() callback (application error)");
118 break;
120 case GSASL_NEED_CLIENT_PASSWORD_CALLBACK:
121 p = _("SASL mechanism needs gsasl_client_callback_password() callback (application error)");
122 break;
124 case GSASL_NEED_CLIENT_PASSCODE_CALLBACK:
125 p = _("SASL mechanism needs gsasl_client_callback_passcode() callback (application error)");
126 break;
128 case GSASL_NEED_CLIENT_PIN_CALLBACK:
129 p = _("SASL mechanism needs gsasl_client_callback_pin() callback (application error)");
130 break;
132 case GSASL_NEED_CLIENT_AUTHORIZATION_ID_CALLBACK:
133 p = _("SASL mechanism needs gsasl_client_callback_authorization_id() callback (application error)");
134 break;
136 case GSASL_NEED_CLIENT_AUTHENTICATION_ID_CALLBACK:
137 p = _("SASL mechanism needs gsasl_client_callback_authentication_id() callback (application error)");
138 break;
140 case GSASL_NEED_CLIENT_SERVICE_CALLBACK:
141 p = _("SASL mechanism needs gsasl_client_callback_service() callback (application error)");
142 break;
144 case GSASL_NEED_SERVER_VALIDATE_CALLBACK:
145 p = _("SASL mechanism needs gsasl_server_callback_validate() callback (application error)");
146 break;
148 case GSASL_NEED_SERVER_CRAM_MD5_CALLBACK:
149 p = _("SASL mechanism needs gsasl_server_callback_cram_md5() callback (application error)");
150 break;
152 case GSASL_NEED_SERVER_DIGEST_MD5_CALLBACK:
153 p = _("SASL mechanism needs gsasl_server_callback_digest_md5() callback (application error)");
154 break;
156 case GSASL_NEED_SERVER_ANONYMOUS_CALLBACK:
157 p = _("SASL mechanism needs gsasl_server_callback_anonymous() callback (application error)");
158 break;
160 case GSASL_NEED_SERVER_EXTERNAL_CALLBACK:
161 p = _("SASL mechanism needs gsasl_server_callback_external() callback (application error)");
162 break;
164 case GSASL_NEED_SERVER_REALM_CALLBACK:
165 p = _("SASL mechanism needs gsasl_server_callback_realm() callback (application error)");
166 break;
168 case GSASL_NEED_SERVER_SECURID_CALLBACK:
169 p = _("SASL mechanism needs gsasl_server_callback_securid() callback (application error)");
170 break;
172 case GSASL_NEED_SERVER_SERVICE_CALLBACK:
173 p = _("SASL mechanism needs gsasl_server_callback_service() callback (application error)");
174 break;
176 case GSASL_NEED_SERVER_GSSAPI_CALLBACK:
177 p = _("SASL mechanism needs gsasl_server_callback_gssapi() callback (application error)");
178 break;
180 case GSASL_MECHANISM_PARSE_ERROR:
181 p = _("SASL mechanism could not parse input");
182 break;
184 case GSASL_AUTHENTICATION_ERROR:
185 p = _("Error authentication user");
186 break;
188 case GSASL_CANNOT_GET_CTX:
189 p = _("Cannot get internal library handle (library error)");
190 break;
192 case GSASL_NO_MORE_REALMS:
193 p = _("No more realms available (non-fatal)");
194 break;
196 default:
197 p = _("Libgsasl unknown error");
198 break;
201 return p;