From: Alexandra Ellwood Date: Tue, 7 Oct 2008 21:12:55 +0000 (+0000) Subject: KIM should remember options and identity if prefs indicate X-Git-Tag: krb5-1.7-alpha1~335 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=edce3aed1c39f750359b7d9ce4595a4fd60c31f5;p=krb5.git KIM should remember options and identity if prefs indicate Added code to remember ticket options if settings indicate it. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20838 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kim/lib/kim_credential.c b/src/kim/lib/kim_credential.c index 50e9e9b8c..ec739f98a 100644 --- a/src/kim/lib/kim_credential.c +++ b/src/kim/lib/kim_credential.c @@ -213,6 +213,46 @@ kim_error kim_credential_create_new (kim_credential *out_credential, /* ------------------------------------------------------------------------ */ +static void kim_credential_remember_prefs (kim_identity in_identity, + kim_options in_options) +{ + kim_error err = KIM_NO_ERROR; + kim_preferences prefs = NULL; + kim_boolean remember_identity = 0; + kim_boolean remember_options = 0; + + err = kim_preferences_create (&prefs); + + if (!err && in_options) { + err = kim_preferences_get_remember_options (prefs, + &remember_options); + } + + if (!err && in_identity) { + err = kim_preferences_get_remember_client_identity (prefs, + &remember_identity); + } + + if (!err && remember_options) { + err = kim_preferences_set_options (prefs, in_options); + } + + if (!err && remember_identity) { + err = kim_preferences_set_client_identity (prefs, in_identity); + + } + + if (!err && (remember_options || remember_identity)) { + err = kim_preferences_synchronize (prefs); + } + + kim_preferences_free (&prefs); + + check_error (err); +} + +/* ------------------------------------------------------------------------ */ + kim_error kim_credential_create_new_with_password (kim_credential *out_credential, kim_identity in_identity, kim_options in_options, @@ -360,6 +400,9 @@ kim_error kim_credential_create_new_with_password (kim_credential *out_credentia /* 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); + } else { /* new creds failed, report error to user */ kim_error terr = kim_ui_handle_kim_error (&context, identity, @@ -399,13 +442,13 @@ kim_error kim_credential_create_new_with_password (kim_credential *out_credentia kim_error fini_err = kim_ui_fini (&context); if (!err) { err = check_error (fini_err); } } - + if (!err) { *out_credential = credential; credential = NULL; } - if (options != in_options ) { kim_options_free (&options); } + if (options != in_options) { kim_options_free (&options); } kim_credential_free (&credential); return check_error (err); diff --git a/src/kim/lib/kim_preferences.c b/src/kim/lib/kim_preferences.c index 29f37cd9a..48dd75c63 100644 --- a/src/kim/lib/kim_preferences.c +++ b/src/kim/lib/kim_preferences.c @@ -502,7 +502,7 @@ static kim_error kim_preferences_write (kim_preferences in_preferences) if (!err && !in_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); } - if (!err && in_preferences->remember_options && in_preferences->options_changed) { + if (!err && in_preferences->options_changed) { err = kim_os_preferences_set_options_for_key (kim_preference_key_options, in_preferences->options); } @@ -512,7 +512,7 @@ static kim_error kim_preferences_write (kim_preferences in_preferences) in_preferences->remember_options); } - if (!err && in_preferences->remember_client_identity && in_preferences->client_identity_changed) { + if (!err && in_preferences->client_identity_changed) { kim_identity default_identity = kim_default_client_identity; err = kim_os_identity_create_for_username (&default_identity);