From: Alexandra Ellwood Date: Fri, 31 Oct 2008 17:11:47 +0000 (+0000) Subject: Avoid duplicate identical dialogs in KIM X-Git-Tag: krb5-1.7-alpha1~242 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ea9c53fe741df01e6b75a4f97964f33b88e05125;p=krb5.git Avoid duplicate identical dialogs in KIM Added KIM_DUPLICATE_UI_REQUEST_ERR error so UI can indicate it cancelled its dialog due to getting multiple identical dialogs at the same time. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20942 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kim/lib/kim_credential.c b/src/kim/lib/kim_credential.c index 7b49c42dc..8d2c1ee60 100644 --- a/src/kim/lib/kim_credential.c +++ b/src/kim/lib/kim_credential.c @@ -309,7 +309,11 @@ kim_error kim_credential_create_new_with_password (kim_credential *out_credentia /* reenter enter_identity so just forget this identity * even if we got an error */ - if (err == KIM_USER_CANCELED_ERR) { err = KIM_NO_ERROR; } + if (err == KIM_USER_CANCELED_ERR || + err == KIM_DUPLICATE_UI_REQUEST_ERR) { + err = KIM_NO_ERROR; + } + kim_identity_free (&identity); } @@ -397,12 +401,31 @@ kim_error kim_credential_create_new_with_password (kim_credential *out_credentia kim_string_free (&new_password); } - if (!err || err == KIM_USER_CANCELED_ERR) { + if (!err || err == KIM_USER_CANCELED_ERR || + err == KIM_DUPLICATE_UI_REQUEST_ERR) { /* new creds obtained or the user gave up */ done_with_credentials = 1; - /* remember identity and options if the user wanted to */ - kim_credential_remember_prefs (identity, options); + if (!err) { + /* remember identity and options if the user wanted to */ + kim_credential_remember_prefs (identity, options); + } + + if (err == KIM_DUPLICATE_UI_REQUEST_ERR) { + kim_ccache ccache = NULL; + /* credential for this identity was obtained, but via a different + * dialog. Find it. */ + + err = kim_ccache_create_from_client_identity (&ccache, + identity); + + if (!err) { + err = kim_ccache_get_valid_credential (ccache, + &credential); + } + + kim_ccache_free (&ccache); + } } else if (prompt_count) { /* User was prompted and might have entered bad info diff --git a/src/kim/lib/kim_errors.et b/src/kim/lib/kim_errors.et index 415751dc5..895d05a07 100644 --- a/src/kim/lib/kim_errors.et +++ b/src/kim/lib/kim_errors.et @@ -52,6 +52,7 @@ error_code KIM_CAPS_LOCK_ERR, "Password Incorrect (check you error_code KIM_USER_CANCELED_ERR, "The user cancelled the operation" error_code KIM_NO_SERVER_ERR, "KerberosAgent is not responding" error_code KIM_NO_UI_ERR, "Unable to display a user interface from this environment" +error_code KIM_DUPLICATE_UI_REQUEST_ERR, "UI just handled this request." index 100 # Preferences Errors diff --git a/src/kim/lib/kim_identity.c b/src/kim/lib/kim_identity.c index 6592d09c8..2a1ad5e3f 100644 --- a/src/kim/lib/kim_identity.c +++ b/src/kim/lib/kim_identity.c @@ -707,7 +707,8 @@ kim_error kim_identity_change_password_common (kim_identity in_identity, rejected_message, rejected_description); - } else if (err && err != KIM_USER_CANCELED_ERR) { + } else if (err && err != KIM_USER_CANCELED_ERR && + err != KIM_DUPLICATE_UI_REQUEST_ERR) { /* New creds failed, report error to user. * Overwrite error so we loop and let the user try again. * The user always gets prompted so we always loop. */ @@ -738,6 +739,8 @@ kim_error kim_identity_change_password_common (kim_identity in_identity, kim_string_free (&saved_password); } + + if (err == KIM_DUPLICATE_UI_REQUEST_ERR) { err = KIM_NO_ERROR; } } kim_string_free (&rejected_message); diff --git a/src/kim/lib/kim_selection_hints.c b/src/kim/lib/kim_selection_hints.c index 797f70bd5..2b5742830 100644 --- a/src/kim/lib/kim_selection_hints.c +++ b/src/kim/lib/kim_selection_hints.c @@ -480,7 +480,8 @@ kim_error kim_selection_hints_get_identity (kim_selection_hints in_selection_hi /* reenter select_identity so just forget this identity * even if we got an error */ - if (err == KIM_USER_CANCELED_ERR) { err = KIM_NO_ERROR; } + if (err == KIM_USER_CANCELED_ERR || + err == KIM_DUPLICATE_UI_REQUEST_ERR) { err = KIM_NO_ERROR; } kim_identity_free (&identity); }