[gnome-online-accounts/gnome-3-10] kerberos: don't crash if keyring credentials disappear



commit 0900d2e26ec4c53d15e7782849cca235a46f2f23
Author: Ray Strode <rstrode redhat com>
Date:   Wed Nov 6 16:58:43 2013 -0500

    kerberos: don't crash if keyring credentials disappear
    
    It's possible to make gnome-online-accounts crash by:
    
    1) creating a kerberos account in control-center
    2) deleting the stored credentials from gnome keyring using seahorse
    3) running kdestroy in the terminal to make the sign in button show up
    in the control-center panel
    4) clicking sign in
    
    This is because the provider makes the assumption that there will always
    be stored credentials when signing in interactively, which is incorrect
    in the above scenario (because of step 2).
    
    This commit hardens the get_ticket_sync function against credentials
    disappearing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711572

 src/goabackend/goakerberosprovider.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/src/goabackend/goakerberosprovider.c b/src/goabackend/goakerberosprovider.c
index 08914f7..02d18fb 100644
--- a/src/goabackend/goakerberosprovider.c
+++ b/src/goabackend/goakerberosprovider.c
@@ -701,7 +701,6 @@ get_ticket_sync (GoaKerberosProvider *self,
   GoaAccount          *account;
   const char          *identifier;
   const char          *password;
-  gboolean             has_password;
   SignInRequest        request;
   gboolean             ret;
 
@@ -728,16 +727,20 @@ get_ticket_sync (GoaKerberosProvider *self,
                        _("Could not find saved credentials for principal `%s' in keyring"), identifier);
       goto out;
     }
-
-  has_password = g_variant_lookup (credentials, "password", "&s", &password);
-  if (!has_password && !is_interactive)
+  else if (credentials != NULL)
     {
-      g_set_error (error,
-                   GOA_ERROR,
-                   GOA_ERROR_NOT_AUTHORIZED,
-                   _("Did not find password for principal `%s' in credentials"),
-                   identifier);
-      goto out;
+      gboolean has_password;
+
+      has_password = g_variant_lookup (credentials, "password", "&s", &password);
+      if (!has_password && !is_interactive)
+        {
+          g_set_error (error,
+                       GOA_ERROR,
+                       GOA_ERROR_NOT_AUTHORIZED,
+                       _("Did not find password for principal `%s' in credentials"),
+                       identifier);
+          goto out;
+        }
     }
 
   memset (&request, 0, sizeof (SignInRequest));


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