|
gsasl
1.8.0
|
00001 /* error.c --- Error handling functionality. 00002 * Copyright (C) 2002-2012 Simon Josefsson 00003 * 00004 * This file is part of GNU SASL Library. 00005 * 00006 * GNU SASL Library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation; either version 2.1 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * GNU SASL Library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License License along with GNU SASL Library; if not, write to the 00018 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00023 #include "internal.h" 00024 00025 /* I18n of error codes. */ 00026 #include "gettext.h" 00027 #define _(String) dgettext (PACKAGE, String) 00028 #define gettext_noop(String) String 00029 #define N_(String) gettext_noop (String) 00030 00031 #define ERR(name, desc) { name, #name, desc } 00032 00033 #ifdef GSASL_NO_OBSOLETE 00034 #define OBS(i, name, desc) { i, NULL, NULL } 00035 #else 00036 #define OBS(i, name, desc) { name, #name, desc } 00037 #endif 00038 00039 /* *INDENT-OFF* */ 00040 static struct 00041 { 00042 int rc; 00043 const char *name; 00044 const char *description; 00045 } errors[] = { 00046 ERR (GSASL_OK, N_("Libgsasl success")), 00047 ERR (GSASL_NEEDS_MORE, N_("SASL mechanism needs more data")), 00048 ERR (GSASL_UNKNOWN_MECHANISM, N_("Unknown SASL mechanism")), 00049 ERR (GSASL_MECHANISM_CALLED_TOO_MANY_TIMES, 00050 N_("SASL mechanism called too many times")), 00051 OBS (4, GSASL_TOO_SMALL_BUFFER, 00052 N_("SASL function needs larger buffer (internal error)")), 00053 OBS (5, GSASL_FOPEN_ERROR, N_("Could not open file in SASL library")), 00054 OBS (6, GSASL_FCLOSE_ERROR, N_("Could not close file in SASL library")), 00055 ERR (GSASL_MALLOC_ERROR, N_("Memory allocation error in SASL library")), 00056 ERR (GSASL_BASE64_ERROR, N_("Base 64 coding error in SASL library")), 00057 ERR (GSASL_CRYPTO_ERROR, N_("Low-level crypto error in SASL library")), 00058 { 10, NULL, NULL }, 00059 OBS (11, GSASL_NEED_CLIENT_ANONYMOUS_CALLBACK, 00060 N_("SASL mechanism needs gsasl_client_callback_anonymous() callback" 00061 " (application error)")), 00062 OBS (12, GSASL_NEED_CLIENT_PASSWORD_CALLBACK, 00063 N_("SASL mechanism needs gsasl_client_callback_password() callback" 00064 " (application error)")), 00065 OBS (13, GSASL_NEED_CLIENT_PASSCODE_CALLBACK, 00066 N_("SASL mechanism needs gsasl_client_callback_passcode() callback" 00067 " (application error)")), 00068 OBS (14, GSASL_NEED_CLIENT_PIN_CALLBACK, 00069 N_("SASL mechanism needs gsasl_client_callback_pin() callback" 00070 " (application error)")), 00071 OBS (15, GSASL_NEED_CLIENT_AUTHORIZATION_ID_CALLBACK, 00072 N_("SASL mechanism needs gsasl_client_callback_authorization_id() " 00073 "callback (application error)")), 00074 OBS (16, GSASL_NEED_CLIENT_AUTHENTICATION_ID_CALLBACK, 00075 N_("SASL mechanism needs gsasl_client_callback_authentication_id() " 00076 "callback (application error)")), 00077 OBS (17, GSASL_NEED_CLIENT_SERVICE_CALLBACK, 00078 N_("SASL mechanism needs gsasl_client_callback_service() callback " 00079 "(application error)")), 00080 OBS (18, GSASL_NEED_SERVER_VALIDATE_CALLBACK, 00081 N_("SASL mechanism needs gsasl_server_callback_validate() callback " 00082 "(application error)")), 00083 OBS (19, GSASL_NEED_SERVER_CRAM_MD5_CALLBACK, 00084 N_("SASL mechanism needs gsasl_server_callback_cram_md5() callback " 00085 "(application error)")), 00086 OBS (20, GSASL_NEED_SERVER_DIGEST_MD5_CALLBACK, 00087 N_("SASL mechanism needs gsasl_server_callback_digest_md5() callback " 00088 "(application error)")), 00089 OBS (21, GSASL_NEED_SERVER_EXTERNAL_CALLBACK, 00090 N_("SASL mechanism needs gsasl_server_callback_external() callback " 00091 "(application error)")), 00092 OBS (22, GSASL_NEED_SERVER_ANONYMOUS_CALLBACK, 00093 N_("SASL mechanism needs gsasl_server_callback_anonymous() callback " 00094 "(application error)")), 00095 OBS (23, GSASL_NEED_SERVER_REALM_CALLBACK, 00096 N_("SASL mechanism needs gsasl_server_callback_realm() callback " 00097 "(application error)")), 00098 OBS (24, GSASL_NEED_SERVER_SECURID_CALLBACK, 00099 N_("SASL mechanism needs gsasl_server_callback_securid() callback " 00100 "(application error)")), 00101 OBS (25, GSASL_NEED_SERVER_SERVICE_CALLBACK, 00102 N_("SASL mechanism needs gsasl_server_callback_service() callback " 00103 "(application error)")), 00104 OBS (26, GSASL_NEED_SERVER_GSSAPI_CALLBACK, 00105 N_("SASL mechanism needs gsasl_server_callback_gssapi() callback " 00106 "(application error)")), 00107 OBS (27, GSASL_NEED_SERVER_RETRIEVE_CALLBACK, 00108 N_("SASL mechanism needs gsasl_server_callback_retrieve() callback " 00109 "(application error)")), 00110 OBS (28, GSASL_UNICODE_NORMALIZATION_ERROR, 00111 N_("Failed to perform Unicode Normalization on string.")), 00112 ERR (GSASL_SASLPREP_ERROR, 00113 N_("Could not prepare internationalized (non-ASCII) string.")), 00114 ERR (GSASL_MECHANISM_PARSE_ERROR, 00115 N_("SASL mechanism could not parse input")), 00116 ERR (GSASL_AUTHENTICATION_ERROR, N_("Error authenticating user")), 00117 OBS (32, GSASL_CANNOT_GET_CTX, 00118 N_("Cannot get internal library handle (library error)")), 00119 ERR (GSASL_INTEGRITY_ERROR, N_("Integrity error in application payload")), 00120 OBS (34, GSASL_NO_MORE_REALMS, N_("No more realms available (non-fatal)")), 00121 ERR (GSASL_NO_CLIENT_CODE, 00122 N_("Client-side functionality not available in library " 00123 "(application error)")), 00124 ERR (GSASL_NO_SERVER_CODE, 00125 N_("Server-side functionality not available in library " 00126 "(application error)")), 00127 ERR (GSASL_GSSAPI_RELEASE_BUFFER_ERROR, 00128 N_("GSSAPI library could not deallocate memory in " 00129 "gss_release_buffer() in SASL library. This is a serious " 00130 "internal error.")), 00131 ERR (GSASL_GSSAPI_IMPORT_NAME_ERROR, 00132 N_("GSSAPI library could not understand a peer name in " 00133 "gss_import_name() in SASL library. This is most likely due " 00134 "to incorrect service and/or hostnames.")), 00135 ERR (GSASL_GSSAPI_INIT_SEC_CONTEXT_ERROR, 00136 N_("GSSAPI error in client while negotiating security context in " 00137 "gss_init_sec_context() in SASL library. This is most likely " 00138 "due insufficient credentials or malicious interactions.")), 00139 ERR (GSASL_GSSAPI_ACCEPT_SEC_CONTEXT_ERROR, 00140 N_("GSSAPI error in server while negotiating security context in " 00141 "gss_accept_sec_context() in SASL library. This is most likely due " 00142 "insufficient credentials or malicious interactions.")), 00143 ERR (GSASL_GSSAPI_UNWRAP_ERROR, 00144 N_("GSSAPI error while decrypting or decoding data in gss_unwrap() in " 00145 "SASL library. This is most likely due to data corruption.")), 00146 ERR (GSASL_GSSAPI_WRAP_ERROR, 00147 N_("GSSAPI error while encrypting or encoding data in gss_wrap() in " 00148 "SASL library.")), 00149 ERR (GSASL_GSSAPI_ACQUIRE_CRED_ERROR, 00150 N_("GSSAPI error acquiring credentials in gss_acquire_cred() in " 00151 "SASL library. This is most likely due to not having the proper " 00152 "Kerberos key available in /etc/krb5.keytab on the server.")), 00153 ERR (GSASL_GSSAPI_DISPLAY_NAME_ERROR, 00154 N_("GSSAPI error creating a display name denoting the client in " 00155 "gss_display_name() in SASL library. This is probably because " 00156 "the client supplied bad data.")), 00157 ERR (GSASL_GSSAPI_UNSUPPORTED_PROTECTION_ERROR, 00158 N_("Other entity requested integrity or confidentiality protection " 00159 "in GSSAPI mechanism but this is currently not implemented.")), 00160 ERR (GSASL_KERBEROS_V5_INIT_ERROR, 00161 N_("Kerberos V5 initialization failure.")), 00162 ERR (GSASL_KERBEROS_V5_INTERNAL_ERROR, 00163 N_("Kerberos V5 internal error.")), 00164 ERR (GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODE, 00165 N_("SecurID needs additional passcode.")), 00166 ERR (GSASL_SECURID_SERVER_NEED_NEW_PIN, 00167 N_("SecurID needs new pin.")), 00168 OBS (50, GSASL_INVALID_HANDLE, 00169 N_("The provided library handle was invalid (application error)")), 00170 ERR (GSASL_NO_CALLBACK, 00171 N_("No callback specified by caller (application error).")), 00172 ERR (GSASL_NO_ANONYMOUS_TOKEN, 00173 N_("Authentication failed because the anonymous token was " 00174 "not provided.")), 00175 ERR (GSASL_NO_AUTHID, 00176 N_("Authentication failed because the authentication identity was " 00177 "not provided.")), 00178 ERR (GSASL_NO_AUTHZID, 00179 N_("Authentication failed because the authorization identity was " 00180 "not provided.")), 00181 ERR (GSASL_NO_PASSWORD, 00182 N_("Authentication failed because the password was not provided.")), 00183 ERR (GSASL_NO_PASSCODE, 00184 N_("Authentication failed because the passcode was not provided.")), 00185 ERR (GSASL_NO_PIN, 00186 N_("Authentication failed because the pin code was not provided.")), 00187 ERR (GSASL_NO_SERVICE, 00188 N_("Authentication failed because the service name was not provided.")), 00189 ERR (GSASL_NO_HOSTNAME, 00190 N_("Authentication failed because the host name was not provided.")), 00191 ERR (GSASL_GSSAPI_ENCAPSULATE_TOKEN_ERROR, 00192 N_("GSSAPI error encapsulating token.")), 00193 ERR (GSASL_GSSAPI_DECAPSULATE_TOKEN_ERROR, 00194 N_("GSSAPI error decapsulating token.")), 00195 ERR (GSASL_GSSAPI_INQUIRE_MECH_FOR_SASLNAME_ERROR, 00196 N_("GSSAPI error getting OID for SASL mechanism name.")), 00197 ERR (GSASL_GSSAPI_TEST_OID_SET_MEMBER_ERROR, 00198 N_("GSSAPI error testing for OID in OID set.")), 00199 ERR (GSASL_GSSAPI_RELEASE_OID_SET_ERROR, 00200 N_("GSSAPI error releasing OID set.")), 00201 ERR (GSASL_NO_CB_TLS_UNIQUE, 00202 N_("Authentication failed because a tls-unique CB was not provided.")), 00203 ERR (GSASL_NO_SAML20_IDP_IDENTIFIER, 00204 N_("Callback failed to provide SAML20 IdP identifier.")), 00205 ERR (GSASL_NO_SAML20_REDIRECT_URL, 00206 N_("Callback failed to provide SAML20 redirect URL.")), 00207 ERR (GSASL_NO_OPENID20_REDIRECT_URL, 00208 N_("Callback failed to provide OPENID20 redirect URL.")) 00209 }; 00210 /* *INDENT-ON* */ 00211 00227 const char * 00228 gsasl_strerror (int err) 00229 { 00230 static const char *unknown = N_("Libgsasl unknown error"); 00231 const char *p; 00232 00233 bindtextdomain (PACKAGE, LOCALEDIR); 00234 00235 if (err < 0 || err >= (sizeof (errors) / sizeof (errors[0]))) 00236 return _(unknown); 00237 00238 p = errors[err].description; 00239 if (!p) 00240 p = unknown; 00241 00242 return _(p); 00243 } 00244 00245 00265 const char * 00266 gsasl_strerror_name (int err) 00267 { 00268 if (err < 0 || err >= (sizeof (errors) / sizeof (errors[0]))) 00269 return NULL; 00270 00271 return errors[err].name; 00272 }
1.7.6.1