00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "internal.h"
00024
00025
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 static struct {
00040 int rc;
00041 const char *name;
00042 const char *description;
00043 } errors[] = {
00044 ERR (GSASL_OK, N_("Libgsasl success")),
00045 ERR (GSASL_NEEDS_MORE, N_("SASL mechanism needs more data")),
00046 ERR (GSASL_UNKNOWN_MECHANISM, N_("Unknown SASL mechanism")),
00047 ERR (GSASL_MECHANISM_CALLED_TOO_MANY_TIMES,
00048 N_("SASL mechanism called too many times")),
00049 OBS (4, GSASL_TOO_SMALL_BUFFER,
00050 N_("SASL function needs larger buffer (internal error)")),
00051 OBS (5, GSASL_FOPEN_ERROR, N_("Could not open file in SASL library")),
00052 OBS (6, GSASL_FCLOSE_ERROR, N_("Could not close file in SASL library")),
00053 ERR (GSASL_MALLOC_ERROR, N_("Memory allocation error in SASL library")),
00054 ERR (GSASL_BASE64_ERROR, N_("Base 64 coding error in SASL library")),
00055 ERR (GSASL_CRYPTO_ERROR, N_("Low-level crypto error in SASL library")),
00056 { 10, NULL, NULL },
00057 OBS (11, GSASL_NEED_CLIENT_ANONYMOUS_CALLBACK,
00058 N_("SASL mechanism needs gsasl_client_callback_anonymous() callback"
00059 " (application error)")),
00060 OBS (12, GSASL_NEED_CLIENT_PASSWORD_CALLBACK,
00061 N_("SASL mechanism needs gsasl_client_callback_password() callback"
00062 " (application error)")),
00063 OBS (13, GSASL_NEED_CLIENT_PASSCODE_CALLBACK,
00064 N_("SASL mechanism needs gsasl_client_callback_passcode() callback"
00065 " (application error)")),
00066 OBS (14, GSASL_NEED_CLIENT_PIN_CALLBACK,
00067 N_("SASL mechanism needs gsasl_client_callback_pin() callback"
00068 " (application error)")),
00069 OBS (15, GSASL_NEED_CLIENT_AUTHORIZATION_ID_CALLBACK,
00070 N_("SASL mechanism needs gsasl_client_callback_authorization_id() "
00071 "callback (application error)")),
00072 OBS (16, GSASL_NEED_CLIENT_AUTHENTICATION_ID_CALLBACK,
00073 N_("SASL mechanism needs gsasl_client_callback_authentication_id() "
00074 "callback (application error)")),
00075 OBS (17, GSASL_NEED_CLIENT_SERVICE_CALLBACK,
00076 N_("SASL mechanism needs gsasl_client_callback_service() callback "
00077 "(application error)")),
00078 OBS (18, GSASL_NEED_SERVER_VALIDATE_CALLBACK,
00079 N_("SASL mechanism needs gsasl_server_callback_validate() callback "
00080 "(application error)")),
00081 OBS (19, GSASL_NEED_SERVER_CRAM_MD5_CALLBACK,
00082 N_("SASL mechanism needs gsasl_server_callback_cram_md5() callback "
00083 "(application error)")),
00084 OBS (20, GSASL_NEED_SERVER_DIGEST_MD5_CALLBACK,
00085 N_("SASL mechanism needs gsasl_server_callback_digest_md5() callback "
00086 "(application error)")),
00087 OBS (21, GSASL_NEED_SERVER_EXTERNAL_CALLBACK,
00088 N_("SASL mechanism needs gsasl_server_callback_external() callback "
00089 "(application error)")),
00090 OBS (22, GSASL_NEED_SERVER_ANONYMOUS_CALLBACK,
00091 N_("SASL mechanism needs gsasl_server_callback_anonymous() callback "
00092 "(application error)")),
00093 OBS (23, GSASL_NEED_SERVER_REALM_CALLBACK,
00094 N_("SASL mechanism needs gsasl_server_callback_realm() callback "
00095 "(application error)")),
00096 OBS (24, GSASL_NEED_SERVER_SECURID_CALLBACK,
00097 N_("SASL mechanism needs gsasl_server_callback_securid() callback "
00098 "(application error)")),
00099 OBS (25, GSASL_NEED_SERVER_SERVICE_CALLBACK,
00100 N_("SASL mechanism needs gsasl_server_callback_service() callback "
00101 "(application error)")),
00102 OBS (26, GSASL_NEED_SERVER_GSSAPI_CALLBACK,
00103 N_("SASL mechanism needs gsasl_server_callback_gssapi() callback "
00104 "(application error)")),
00105 OBS (27, GSASL_NEED_SERVER_RETRIEVE_CALLBACK,
00106 N_("SASL mechanism needs gsasl_server_callback_retrieve() callback "
00107 "(application error)")),
00108 OBS (28, GSASL_UNICODE_NORMALIZATION_ERROR,
00109 N_("Failed to perform Unicode Normalization on string.")),
00110 ERR (GSASL_SASLPREP_ERROR,
00111 N_("Could not prepare internationalized (non-ASCII) string.")),
00112 ERR (GSASL_MECHANISM_PARSE_ERROR,
00113 N_("SASL mechanism could not parse input")),
00114 ERR (GSASL_AUTHENTICATION_ERROR, N_("Error authenticating user")),
00115 OBS (32, GSASL_CANNOT_GET_CTX,
00116 N_("Cannot get internal library handle (library error)")),
00117 ERR (GSASL_INTEGRITY_ERROR, N_("Integrity error in application payload")),
00118 OBS (34, GSASL_NO_MORE_REALMS, N_("No more realms available (non-fatal)")),
00119 ERR (GSASL_NO_CLIENT_CODE,
00120 N_("Client-side functionality not available in library "
00121 "(application error)")),
00122 ERR (GSASL_NO_SERVER_CODE,
00123 N_("Server-side functionality not available in library "
00124 "(application error)")),
00125 ERR (GSASL_GSSAPI_RELEASE_BUFFER_ERROR,
00126 N_("GSSAPI library could not deallocate memory in "
00127 "gss_release_buffer() in SASL library. This is a serious "
00128 "internal error.")),
00129 ERR (GSASL_GSSAPI_IMPORT_NAME_ERROR,
00130 N_("GSSAPI library could not understand a peer name in "
00131 "gss_import_name() in SASL library. This is most likely due "
00132 "to incorrect service and/or hostnames.")),
00133 ERR (GSASL_GSSAPI_INIT_SEC_CONTEXT_ERROR,
00134 N_("GSSAPI error in client while negotiating security context in "
00135 "gss_init_sec_context() in SASL library. This is most likely "
00136 "due insufficient credentials or malicious interactions.")),
00137 ERR (GSASL_GSSAPI_ACCEPT_SEC_CONTEXT_ERROR,
00138 N_("GSSAPI error in server while negotiating security context in "
00139 "gss_init_sec_context() in SASL library. This is most likely due "
00140 "insufficient credentials or malicious interactions.")),
00141 ERR (GSASL_GSSAPI_UNWRAP_ERROR,
00142 N_("GSSAPI error while decrypting or decoding data in gss_unwrap() in "
00143 "SASL library. This is most likely due to data corruption.")),
00144 ERR (GSASL_GSSAPI_WRAP_ERROR,
00145 N_("GSSAPI error while encrypting or encoding data in gss_wrap() in "
00146 "SASL library.")),
00147 ERR (GSASL_GSSAPI_ACQUIRE_CRED_ERROR,
00148 N_("GSSAPI error acquiring credentials in gss_acquire_cred() in "
00149 "SASL library. This is most likely due to not having the proper "
00150 "Kerberos key available in /etc/krb5.keytab on the server.")),
00151 ERR (GSASL_GSSAPI_DISPLAY_NAME_ERROR,
00152 N_("GSSAPI error creating a display name denoting the client in "
00153 "gss_display_name() in SASL library. This is probably because "
00154 "the client supplied bad data.")),
00155 ERR (GSASL_GSSAPI_UNSUPPORTED_PROTECTION_ERROR,
00156 N_("Other entity requested integrity or confidentiality protection "
00157 "in GSSAPI mechanism but this is currently not implemented.")),
00158 ERR (GSASL_KERBEROS_V5_INIT_ERROR,
00159 N_("Kerberos V5 initialization failure.")),
00160 ERR (GSASL_KERBEROS_V5_INTERNAL_ERROR,
00161 N_("Kerberos V5 internal error.")),
00162 ERR (GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODE,
00163 N_("SecurID needs additional passcode.")),
00164 ERR (GSASL_SECURID_SERVER_NEED_NEW_PIN,
00165 N_("SecurID needs new pin.")),
00166 OBS (50, GSASL_INVALID_HANDLE,
00167 N_("The provided library handle was invalid (application error)")),
00168 ERR (GSASL_NO_CALLBACK,
00169 N_("No callback specified by caller (application error).")),
00170 ERR (GSASL_NO_ANONYMOUS_TOKEN,
00171 N_("Authentication failed because the anonymous token was "
00172 "not provided.")),
00173 ERR (GSASL_NO_AUTHID,
00174 N_("Authentication failed because the authentication identity was "
00175 "not provided.")),
00176 ERR (GSASL_NO_AUTHZID,
00177 N_("Authentication failed because the authorization identity was "
00178 "not provided.")),
00179 ERR (GSASL_NO_PASSWORD,
00180 N_("Authentication failed because the password was not provided.")),
00181 ERR (GSASL_NO_PASSCODE,
00182 N_("Authentication failed because the passcode was not provided.")),
00183 ERR (GSASL_NO_PIN,
00184 N_("Authentication failed because the pin code was not provided.")),
00185 ERR (GSASL_NO_SERVICE,
00186 N_("Authentication failed because the service name was not provided.")),
00187 ERR (GSASL_NO_HOSTNAME,
00188 N_("Authentication failed because the host name was not provided."))
00189 };
00190
00203 const char *
00204 gsasl_strerror (int err)
00205 {
00206 static const char *unknown = N_("Libgsasl unknown error");
00207 const char *p;
00208
00209 bindtextdomain (PACKAGE, LOCALEDIR);
00210
00211 if (err < 0 || err >= (sizeof (errors) / sizeof (errors[0])))
00212 return _(unknown);
00213
00214 p = errors[err].description;
00215 if (!p)
00216 p = unknown;
00217
00218 return _(p);
00219 }
00220
00221
00238 const char *
00239 gsasl_strerror_name (int err)
00240 {
00241 if (err < 0 || err >= (sizeof (errors) / sizeof (errors[0])))
00242 return NULL;
00243
00244 return errors[err].name;
00245 }