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