KIM should remember options and identity if prefs indicate
authorAlexandra Ellwood <lxs@mit.edu>
Tue, 7 Oct 2008 21:12:55 +0000 (21:12 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Tue, 7 Oct 2008 21:12:55 +0000 (21:12 +0000)
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

src/kim/lib/kim_credential.c
src/kim/lib/kim_preferences.c

index 50e9e9b8cd62ebc109d8e228ce20fe7ea544b69c..ec739f98a90d8253db313b9b76cb566d432ce249 100644 (file)
@@ -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);
index 29f37cd9a3005e7e260fa3de46ea60672c9efeeb..48dd75c632488661591b383c6a554938549c9881 100644 (file)
@@ -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);