1 /* error.c error handling functions
2 * Copyright (C) 2002, 2003 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi 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 2 of the License, or
9 * (at your option) any later version.
11 * Shishi 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.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 shishi_strerror_details (Shishi
* handle
)
27 return handle
->error
? handle
->
29 "Internal application error: shishi_strerror() called without an "
35 * @err: shishi error code
37 * Return value: Returns a pointer to a statically allocated string
38 * containing a description of the error with the error value @err.
39 * This string can be used to output a diagnostic message to the user.
42 shishi_strerror (int err
)
49 p
= _("Shishi success");
52 case SHISHI_MALLOC_ERROR
:
53 p
= _("Memory allocation error in shishi library.");
56 case SHISHI_BASE64_ERROR
:
57 p
= _("Base64 encoding or decoding failed. This usually means the "
61 case SHISHI_FOPEN_ERROR
:
62 p
= _("Could not open file.");
65 case SHISHI_FCLOSE_ERROR
:
66 p
= _("Could not close file.");
69 case SHISHI_GCRYPT_ERROR
:
70 p
= _("Internal libgcrypt error.");
73 case SHISHI_NONCE_MISMATCH
:
76 ("Replay protection value (nonce) differ between request and reply.");
79 case SHISHI_REALM_MISMATCH
:
80 p
= _("Client realm value differ between request and reply.");
83 case SHISHI_CNAME_MISMATCH
:
84 p
= _("Client name value differ between request and reply.");
87 case SHISHI_ASN1_ERROR
:
88 p
= _("Error in ASN.1 data, probably due to corrupt data.");
91 case SHISHI_CRYPTO_ERROR
:
94 ("Low-level cryptographic primitive failed. This usually indicates "
95 "bad password or data corruption.");
98 case SHISHI_KDC_TIMEOUT
:
99 p
= _("Timedout talking to KDC. This usually indicates a network "
100 "or KDC address problem.");
103 case SHISHI_KDC_NOT_KNOWN_FOR_REALM
:
104 p
= _("No KDC for realm known.");
107 case SHISHI_SOCKET_ERROR
:
108 p
= _("The system call socket() failed. This usually indicates that "
109 "your system does not support the socket type.");
112 case SHISHI_BIND_ERROR
:
113 p
= _("The system call bind() failed. This usually indicates "
114 "insufficient permissions.");
117 case SHISHI_SENDTO_ERROR
:
118 p
= _("The system call sendto() failed.");
121 case SHISHI_CLOSE_ERROR
:
122 p
= _("The system call close() failed.");
125 case SHISHI_GOT_KRBERROR
:
126 p
= _("Server replied with an error message to request.");
129 case SHISHI_INVALID_TKTS
:
130 p
= _("Ticketset not initialized. This usually indicates an internal "
131 "application error.");
134 case SHISHI_TICKET_BAD_KEYTYPE
:
135 p
= _("Keytype used to encrypt ticket doesn't match provided key. "
136 "This usually indicates an internal application error.");
139 case SHISHI_APREQ_DECRYPT_FAILED
:
140 p
= _("Could not decrypt AP-REQ using provided key. "
141 "This usually indicates an internal application error.");
144 case SHISHI_TICKET_DECRYPT_FAILED
:
145 p
= _("Could not decrypt Ticket using provided key. "
146 "This usually indicates an internal application error.");
150 asprintf (&p
, _("Unknown shishi error (%d)"), err
);
159 shishi_error_clear (Shishi
* handle
)
161 handle
->error
[0] = '\0';
165 shishi_error_set (Shishi
* handle
, const char *error
)
168 strncpy (handle
->error
, error
, sizeof (handle
->error
));
170 shishi_error_clear (handle
);
174 shishi_error_printf (Shishi
* handle
, char *format
, ...)
178 va_start (ap
, format
);
180 vsnprintf (handle
->error
, sizeof (handle
->error
), format
, ap
);