[gnome-online-accounts] identity: ensure unused credential cache is cleaned up



commit 517fc9c4c88fd34764d4e4aeb063c9b7bf9419fd
Author: Ray Strode <rstrode redhat com>
Date:   Thu Jul 14 09:14:31 2016 -0400

    identity: ensure unused credential cache is cleaned up
    
    If we end up creating a temporary credential cache that we don't
    need, because a new identity wasn't successfully signed in, we
    should clean it up.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768808

 src/goaidentity/goakerberosidentitymanager.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/goaidentity/goakerberosidentitymanager.c b/src/goaidentity/goakerberosidentitymanager.c
index 13f2a42..b7d2623 100644
--- a/src/goaidentity/goakerberosidentitymanager.c
+++ b/src/goaidentity/goakerberosidentitymanager.c
@@ -813,6 +813,7 @@ sign_in_identity (GoaKerberosIdentityManager *self,
   GoaIdentity *identity;
   GError *error;
   krb5_error_code error_code;
+  gboolean is_new_identity = FALSE;
 
   g_debug ("GoaKerberosIdentityManager: signing in identity %s",
            operation->identifier);
@@ -845,15 +846,17 @@ sign_in_identity (GoaKerberosIdentityManager *self,
       identity = goa_kerberos_identity_new (self->priv->kerberos_context,
                                             credentials_cache,
                                             &error);
-      krb5_cc_close (self->priv->kerberos_context, credentials_cache);
       if (identity == NULL)
         {
+          krb5_cc_destroy (self->priv->kerberos_context, credentials_cache);
           g_simple_async_result_take_error (operation->result, error);
           g_simple_async_result_set_op_res_gpointer (operation->result,
                                                      NULL,
                                                      NULL);
           return;
         }
+      krb5_cc_close (self->priv->kerberos_context, credentials_cache);
+      is_new_identity = TRUE;
     }
   else
     {
@@ -872,6 +875,9 @@ sign_in_identity (GoaKerberosIdentityManager *self,
                                       operation->cancellable,
                                       &error))
     {
+      if (is_new_identity)
+        goa_kerberos_identity_erase (identity, NULL);
+
       g_simple_async_result_set_from_error (operation->result, error);
       g_simple_async_result_set_op_res_gpointer (operation->result,
                                                  NULL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]