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



commit ef61d30ffa30c9803053766d2e911f1af6fc9731
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 072909a..a6657f9 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 3dab7e3..741a1b7 100644
--- a/daemon/dbus/gkd-secret-service.c
+++ b/daemon/dbus/gkd-secret-service.c
@@ -1415,12 +1415,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]