DWORD addressless,
DWORD publicIP,
krb5_prompter_fct prompter,
- void * p_data)
+ void * p_data,
+ char ** pp_error_message)
{
krb5_error_code code = 0;
krb5_context ctx = NULL;
goto cleanup;
}
+ pkrb5_clear_error_message(ctx);
+
if (ccache) {
_reportf(L"Using supplied ccache name %S", ccache);
code = pkrb5_cc_resolve(ctx, ccache, &cc);
if (code) goto cleanup;
cleanup:
+ if (pp_error_message) {
+ const char * em;
+
+ em = pkrb5_get_error_message(ctx, code);
+ if (em == NULL) {
+ *pp_error_message = NULL;
+ } else {
+ *pp_error_message = _strdup(em);
+ pkrb5_free_error_message(ctx, em);
+ }
+ }
+
if ( addrs ) {
for ( i=0;i<addr_count;i++ ) {
if ( addrs[i] ) {
while(TRUE)
{
if(g_fjob.command == FIBER_CMD_KINIT) {
+ char * error_msg = NULL;
+
g_fjob.state = FIBER_STATE_KINIT;
+ if (g_fjob.error_message) {
+ PFREE(g_fjob.error_message);
+ g_fjob.error_message = NULL;
+ }
+
g_fjob.prompt_set = 0;
if (k5_cached_kinit_prompter()) {
g_fjob.renewable);
retry_kinit:
+ if (error_msg) {
+ free(error_msg);
+ error_msg = NULL;
+ }
+
g_fjob.code =
khm_krb5_kinit(0,
g_fjob.principal,
g_fjob.addressless,
g_fjob.publicIP,
k5_kinit_prompter,
- &g_fjob);
+ &g_fjob,
+ &error_msg);
/* If the principal was found to be valid, and if we
restricted the options that were being passed to kinit,
g_fjob.state = FIBER_STATE_KINIT;
goto retry_kinit;
}
+
+ if (error_msg) {
+ wchar_t tmp[1024];
+
+ if (AnsiStrToUnicode(tmp, sizeof(tmp), error_msg)) {
+ g_fjob.error_message = PWCSDUP(tmp);
+ }
+
+ free(error_msg);
+ error_msg = NULL;
+ }
}
_switch_to_main:
if (g_fjob.ccache)
PFREE(g_fjob.ccache);
+ if (g_fjob.error_message)
+ PFREE(g_fjob.error_message);
+
ZeroMemory(&g_fjob, sizeof(g_fjob));
}
khm_int32 rv;
if (KHM_SUCCEEDED(kcdb_cred_get_identity(cred,
- &cident)) &&
+ &cident)) &&
cident == ident &&
KHM_SUCCEEDED(kcdb_cred_get_flags(cred, &f)) &&
(f & KCDB_CRED_FLAG_INITIAL) &&
d->cred_message = NULL;
}
+ if (g_fjob.error_message) {
+ StringCbCopy(msg, sizeof(msg), g_fjob.error_message);
+ goto have_message;
+ }
+
msg[0] = L'\0';
switch(g_fjob.code) {
}
}
+ have_message:
+
if (msg[0]) {
StringCbLength(msg, sizeof(msg), &cb);
cb += sizeof(wchar_t);
if(g_fjob.code != 0) {
wchar_t tbuf[1024];
- DWORD suggestion;
+ DWORD suggestion = 0;
kherr_suggestion suggest_code;
- khm_err_describe(g_fjob.code, tbuf, sizeof(tbuf),
- &suggestion, &suggest_code);
+ if (g_fjob.error_message) {
+ StringCbCopy(tbuf, sizeof(tbuf), g_fjob.error_message);
+ } else {
+ khm_err_describe(g_fjob.code, tbuf, sizeof(tbuf),
+ &suggestion, &suggest_code);
+ }
_report_cs0(KHERR_ERROR, tbuf);
if (suggestion != 0)
d->addressless, /* addressless */
d->publicIP, /* public IP */
NULL, /* prompter */
- NULL /* prompter data */);
+ NULL, /* prompter data */
+ NULL /* error message */);
if (code) {
rv = KHM_ERROR_UNKNOWN;