2 * Copyright (c) 2005 Massachusetts Institute of Technology
\r
4 * Permission is hereby granted, free of charge, to any person
\r
5 * obtaining a copy of this software and associated documentation
\r
6 * files (the "Software"), to deal in the Software without
\r
7 * restriction, including without limitation the rights to use, copy,
\r
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
\r
9 * of the Software, and to permit persons to whom the Software is
\r
10 * furnished to do so, subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be
\r
13 * included in all copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
32 extern void (__cdecl *pinitialize_krb_error_func)();
\r
33 extern void (__cdecl *pinitialize_kadm_error_table)();
\r
36 khm_int32 init_error_funcs()
\r
40 /*TODO: Do something about this */
\r
41 if (plsh_LoadKrb4LeashErrorTables)
\r
42 plsh_LoadKrb4LeashErrorTables(hLeashInst, 0);
\r
44 return KHM_ERROR_SUCCESS;
\r
47 khm_int32 exit_error_funcs()
\r
49 return KHM_ERROR_SUCCESS;
\r
52 // Global Variables.
\r
53 static long lsh_errno;
\r
54 static char *err_context; /* error context */
\r
55 extern int (*Lcom_err)(LPSTR,long,LPSTR,...);
\r
56 extern LPSTR (*Lerror_message)(long);
\r
57 extern LPSTR (*Lerror_table_name)(long);
\r
60 #define UNDERSCORE "_"
\r
65 HWND GetRootParent (HWND Child)
\r
71 Child = GetParent (Child);
\r
77 LPSTR err_describe(LPSTR buf, size_t len, long code)
\r
79 LPSTR cp, com_err_msg;
\r
84 offset = (int) (code & 255);
\r
85 table_num = code - offset;
\r
86 com_err_msg = Lerror_message(code);
\r
94 StringCbCopyA(buf, len, com_err_msg);
\r
99 if (table_num == krb_err_base)
\r
102 case KDC_NAME_EXP: /* 001 Principal expired */
\r
103 case KDC_SERVICE_EXP: /* 002 Service expired */
\r
104 case KDC_AUTH_EXP: /* 003 Auth expired */
\r
105 case KDC_PKT_VER: /* 004 Protocol version unknown */
\r
106 case KDC_P_MKEY_VER: /* 005 Wrong master key version */
\r
107 case KDC_S_MKEY_VER: /* 006 Wrong master key version */
\r
108 case KDC_BYTE_ORDER: /* 007 Byte order unknown */
\r
109 case KDC_PR_N_UNIQUE: /* 009 Principal not unique */
\r
110 case KDC_NULL_KEY: /* 010 Principal has null key */
\r
111 case KDC_GEN_ERR: /* 011 Generic error from KDC */
\r
112 case INTK_W_NOTALL : /* 061 Not ALL tickets returned */
\r
113 case INTK_PROT : /* 063 Protocol Error */
\r
114 case INTK_ERR : /* 070 Other error */
\r
115 com_err_msg = "Something weird happened... try again, and if Leash"
\r
116 " continues to fail, contact Network Services as listed in the "
\r
119 case KDC_PR_UNKNOWN: /* 008 Principal unknown */
\r
120 com_err_msg = "You have entered an unknown username/instance/realm"
\r
123 case GC_TKFIL : /* 021 Can't read ticket file */
\r
124 case GC_NOTKT : /* 022 Can't find ticket or TGT */
\r
125 com_err_msg = "Something is wrong with the memory where your "
\r
126 "tickets are stored. Try exiting Windows and restarting your "
\r
129 case MK_AP_TGTEXP : /* 026 TGT Expired */
\r
130 /* no extra error msg */
\r
132 case RD_AP_TIME : /* 037 delta_t too big */
\r
133 com_err_msg = "Your computer's clock is out of sync with the "
\r
134 "Kerberos server. Please see the help file about correcting "
\r
138 case RD_AP_UNDEC : /* 031 Can't decode authenticator */
\r
139 case RD_AP_EXP : /* 032 Ticket expired */
\r
140 case RD_AP_NYV : /* 033 Ticket not yet valid */
\r
141 case RD_AP_REPEAT : /* 034 Repeated request */
\r
142 case RD_AP_NOT_US : /* 035 The ticket isn't for us */
\r
143 case RD_AP_INCON : /* 036 Request is inconsistent */
\r
144 case RD_AP_BADD : /* 038 Incorrect net address */
\r
145 case RD_AP_VERSION : /* 039 protocol version mismatch */
\r
146 case RD_AP_MSG_TYPE : /* 040 invalid msg type */
\r
147 case RD_AP_MODIFIED : /* 041 message stream modified */
\r
148 case RD_AP_ORDER : /* 042 message out of order */
\r
149 case RD_AP_UNAUTHOR : /* 043 unauthorized request */
\r
150 /* no extra error msg */
\r
152 case GT_PW_NULL: /* 51 Current PW is null */
\r
153 case GT_PW_BADPW: /* 52 Incorrect current password */
\r
154 case GT_PW_PROT: /* 53 Protocol Error */
\r
155 case GT_PW_KDCERR: /* 54 Error returned by KDC */
\r
156 case GT_PW_NULLTKT: /* 55 Null tkt returned by KDC */
\r
157 /* no error msg yet */
\r
160 /* Values returned by send_to_kdc */
\r
161 case SKDC_RETRY : /* 56 Retry count exceeded */
\r
162 case SKDC_CANT : /* 57 Can't send request */
\r
163 com_err_msg = "Cannot contact the kerberos server for the selected realm.";
\r
165 /* no error message on purpose: */
\r
166 case INTK_BADPW : /* 062 Incorrect password */
\r
169 /* no extra error msg */
\r
175 case KADM_INSECURE_PW:
\r
176 /* if( kadm_info != NULL ){
\r
177 * wsprintf(buf, "%s\n%s", com_err_msg, kadm_info);
\r
179 * wsprintf(buf, "%s\nPlease see the help file for information "
\r
180 * "about secure passwords.", com_err_msg);
\r
182 * com_err_msg = buf;
\r
185 /* The above code would be preferred since it allows site specific
\r
186 * information to be delivered from the Kerberos server. However the
\r
187 * message box is too small for VGA screens.
\r
188 * It does work well if we only have to support 1024x768
\r
191 com_err_msg = "You have entered an insecure or weak password.";
\r
194 /* no extra error msg */
\r
197 if(com_err_msg != buf) {
\r
198 StringCbCopyA(buf, len, com_err_msg);
\r
200 cp = buf + strlen(buf);
\r
202 switch(table_num) {
\r
204 etype = "Kerberos";
\r
206 case kadm_err_base:
\r
207 etype = "Kerberos supplemental";
\r
210 etype = Lerror_table_name(table_num);
\r
213 StringCbPrintfA((LPSTR) cp, len - (cp-buf), (LPSTR) "(%s error %d"
\r
214 #ifdef DEBUG_COM_ERR
\r
215 " (absolute error %ld)"
\r
218 //")\nPress F1 for help on this error.", etype, offset
\r
219 #ifdef DEBUG_COM_ERR
\r