[gnome-keyring/gnome-3-2] daemon: Fix ReadAlias() returning null when 'login' keyring exists



commit 1436c6bedd0fb7b0a81ab9d7d59766f24d03f745
Author: Stef Walter <stefw collabora co uk>
Date:   Wed Nov 23 17:38:09 2011 +0100

    daemon: Fix ReadAlias() returning null when 'login' keyring exists
    
     * Internally we use the 'login' keyring as the automatic default
       when no default is explicitly set.
     * However this logic was not reflected in the result of the
       ReadAlias() secret serivce API call.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664454

 daemon/dbus/gkd-secret-objects.c |   25 ++++++-------------------
 daemon/dbus/gkd-secret-service.c |    9 ++++++++-
 2 files changed, 14 insertions(+), 20 deletions(-)
---
diff --git a/daemon/dbus/gkd-secret-objects.c b/daemon/dbus/gkd-secret-objects.c
index 325ae04..bf2723f 100644
--- a/daemon/dbus/gkd-secret-objects.c
+++ b/daemon/dbus/gkd-secret-objects.c
@@ -72,26 +72,13 @@ parse_object_path (GkdSecretObjects *self, const gchar *path, gchar **collection
 	if (g_str_has_prefix (path, SECRET_ALIAS_PREFIX)) {
 		replace = gkd_secret_service_get_alias (self->service, *collection);
 		if (!replace) {
-
-			/*
-			 * TODO: As a special case, always treat login keyring as
-			 * default. This logic should be moved, once we have better
-			 * support for aliases.
-			 */
-
-			if (g_str_equal (*collection, "default")) {
-				replace = "login";
-
-			/* No such alias, return nothing */
-			} else {
-				g_free (*collection);
-				*collection = NULL;
-				if (item) {
-					g_free (*item);
-					*item = NULL;
-				}
-				return FALSE;
+			g_free (*collection);
+			*collection = NULL;
+			if (item) {
+				g_free (*item);
+				*item = NULL;
 			}
+			return FALSE;
 		}
 		g_free (*collection);
 		*collection = g_strdup (replace);
diff --git a/daemon/dbus/gkd-secret-service.c b/daemon/dbus/gkd-secret-service.c
index 599e2e5..74a60d4 100644
--- a/daemon/dbus/gkd-secret-service.c
+++ b/daemon/dbus/gkd-secret-service.c
@@ -1345,12 +1345,19 @@ gkd_secret_service_get_alias (GkdSecretService *self, const gchar *alias)
 	const gchar *identifier;
 
 	g_return_val_if_fail (GKD_SECRET_IS_SERVICE (self), NULL);
-	g_return_val_if_fail (alias, NULL);
+	g_return_val_if_fail (alias != NULL, NULL);
 
 	identifier =  g_hash_table_lookup (self->aliases, alias);
 	if (!identifier && g_str_equal (alias, "default")) {
 		update_default (self, TRUE);
 		identifier = g_hash_table_lookup (self->aliases, alias);
+
+		/* Default to to 'login' if no default keyring */
+		if (identifier == NULL) {
+			identifier = "login";
+			g_hash_table_replace (self->aliases, g_strdup (alias),
+			                      g_strdup (identifier));
+		}
 	}
 	return identifier;
 }



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