SOURCES: evolution-data-server-passwords.patch (NEW) - Ported from upstream...

deejay1 deejay1 at pld-linux.org
Tue May 20 19:18:08 CEST 2008


Author: deejay1                      Date: Tue May 20 17:18:08 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- Ported from upstream branch, fixes BGO #531439 and BGO #354923
- Fixes some mail and gpg password issues

---- Files affected:
SOURCES:
   evolution-data-server-passwords.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/evolution-data-server-passwords.patch
diff -u /dev/null SOURCES/evolution-data-server-passwords.patch:1.1
--- /dev/null	Tue May 20 19:18:08 2008
+++ SOURCES/evolution-data-server-passwords.patch	Tue May 20 19:18:03 2008
@@ -0,0 +1,324 @@
+Index: libedataserverui/e-passwords.c
+===================================================================
+--- libedataserverui/e-passwords.c	(wersja 8811)
++++ libedataserverui/e-passwords.c	(wersja 8815)
+@@ -208,38 +208,50 @@
+ }
+ 
+ static EUri *
+-ep_keyring_uri_new (const gchar *string)
++ep_keyring_uri_new (const gchar *string,
++                    GError **error)
+ {
+ 	EUri *uri;
+ 
+ 	uri = e_uri_new (string);
+-	if (uri == NULL)
+-		return NULL;
++	g_return_val_if_fail (uri != NULL, NULL);
+ 
+ 	/* LDAP URIs do not have usernames, so use the URI as the username. */
+ 	if (uri->user == NULL && uri->protocol != NULL &&
+ 			(strcmp (uri->protocol, "ldap") == 0|| strcmp (uri->protocol, "google") == 0))
+ 		uri->user = g_strdelimit (g_strdup (string), "/=", '_');
+ 
++	/* Make sure the URI has the required components. */
++	if (uri->user == NULL && uri->host == NULL) {
++		g_set_error (
++			error, EP_KEYRING_ERROR,
++			GNOME_KEYRING_RESULT_BAD_ARGUMENTS,
++			_("Keyring key is unusable: no user or host name"));
++		e_uri_free (uri);
++		uri = NULL;
++	}
++
+ 	return uri;
+ }
+ 
+ static gboolean
+ ep_keyring_validate (const gchar *user,
+                      const gchar *server,
++                     const gchar *protocol,
+                      GnomeKeyringAttributeList *attributes)
+ {
+ 	const gchar *user_value = NULL;
+ 	const gchar *server_value = NULL;
++	const gchar *protocol_value = NULL;
+ 	gint ii;
+ 
+ 	g_return_val_if_fail (attributes != NULL, FALSE);
+ 
+ 	/* Is there anything to validate? */
+-	if (user == NULL && server == NULL)
++	if (user == NULL && server == NULL && protocol == NULL)
+ 		return TRUE;
+ 
+-	/* Look for "user" and "server" attributes. */
++	/* Look for "user", "server", and "protocol" attributes. */
+ 	for (ii = 0; ii < attributes->len; ii++) {
+ 		GnomeKeyringAttribute *attr;
+ 
+@@ -250,6 +262,8 @@
+ 			user_value = attr->value.string;
+ 		else if (strcmp (attr->name, "server") == 0)
+ 			server_value = attr->value.string;
++		else if (strcmp (attr->name, "protocol") == 0)
++			protocol_value = attr->value.string;
+ 	}
+ 
+ 	/* Is there a "user" attribute? */
+@@ -268,12 +282,21 @@
+ 	if (server != NULL && strcmp (server, server_value) != 0)
+ 		return FALSE;
+ 
++	/* Is there a "protocol" attribute? */
++	if (protocol != NULL && protocol_value == NULL)
++		return FALSE;
++
++	/* Does it match what we're looking for? */
++	if (protocol != NULL && strcmp (protocol, protocol_value) != 0)
++		return FALSE;
++
+ 	return TRUE;
+ }
+ 
+ static gboolean
+ ep_keyring_delete_passwords (const gchar *user,
+                              const gchar *server,
++                             const gchar *protocol,
+                              GList *passwords,
+                              GError **error)
+ {
+@@ -282,9 +305,14 @@
+ 		GnomeKeyringResult result;
+ 
+ 		/* Validate the item before deleting it. */
+-		if (!ep_keyring_validate (user, server, found->attributes)) {
+-			passwords = g_list_next (passwords);
+-			continue;
++		if (!ep_keyring_validate (user, server, protocol, found->attributes)) {
++			/* XXX We didn't always store protocols in the
++			 *     keyring, so for backward-compatibility
++			 *     try validating by user and server only. */
++			if (!ep_keyring_validate (user, server, NULL, found->attributes)) {
++				passwords = g_list_next (passwords);
++				continue;
++			}
+ 		}
+ 
+ 		result = gnome_keyring_item_delete_sync (NULL, found->item_id);
+@@ -306,6 +334,7 @@
+ static gboolean
+ ep_keyring_insert_password (const gchar *user,
+                             const gchar *server,
++                            const gchar *protocol,
+                             const gchar *display_name,
+                             const gchar *password,
+                             GError **error)
+@@ -316,6 +345,7 @@
+ 
+ 	g_return_val_if_fail (user != NULL, FALSE);
+ 	g_return_val_if_fail (server != NULL, FALSE);
++	g_return_val_if_fail (protocol != NULL, FALSE);
+ 	g_return_val_if_fail (display_name != NULL, FALSE);
+ 	g_return_val_if_fail (password != NULL, FALSE);
+ 
+@@ -326,6 +356,8 @@
+ 		attributes, "user", user);
+ 	gnome_keyring_attribute_list_append_string (
+ 		attributes, "server", server);
++	gnome_keyring_attribute_list_append_string (
++		attributes, "protocol", protocol);
+ 
+ 	/* XXX We don't use item_id but gnome-keyring doesn't allow
+ 	 *     for a NULL pointer.  In fact it doesn't even check! */
+@@ -348,6 +380,7 @@
+ static GList *
+ ep_keyring_lookup_passwords (const gchar *user,
+                              const gchar *server,
++                             const gchar *protocol,
+                              GError **error)
+ {
+ 	GnomeKeyringAttributeList *attributes;
+@@ -363,6 +396,9 @@
+ 	if (server != NULL)
+ 		gnome_keyring_attribute_list_append_string (
+ 			attributes, "server", server);
++	if (protocol != NULL)
++		gnome_keyring_attribute_list_append_string (
++			attributes, "protocol", protocol);
+ 
+ 	result = gnome_keyring_find_items_sync (
+ 		GNOME_KEYRING_ITEM_NETWORK_PASSWORD, attributes, &passwords);
+@@ -502,9 +538,9 @@
+ 	GError *error = NULL;
+ 
+ 	/* Find all Evolution passwords and delete them. */
+-	passwords = ep_keyring_lookup_passwords (NULL, NULL, &error);
++	passwords = ep_keyring_lookup_passwords (NULL, NULL, NULL, &error);
+ 	if (passwords != NULL) {
+-		ep_keyring_delete_passwords (NULL, NULL, passwords, &error);
++		ep_keyring_delete_passwords (NULL, NULL, NULL, passwords, &error);
+ 		gnome_keyring_found_list_free (passwords);
+ 	}
+ 
+@@ -532,9 +568,9 @@
+ 
+ 	/* Not finding the requested group is acceptable, but we still
+ 	 * want to leave an informational message on the terminal. */
+-        else if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
+-                g_message ("%s", error->message);
+-                g_error_free (error);
++	else if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
++		g_message ("%s", error->message);
++		g_error_free (error);
+ 
+ 	} else if (error != NULL)
+ 		g_propagate_error (&msg->error, error);
+@@ -566,9 +602,9 @@
+ 	GError *error = NULL;
+ 
+ 	/* Find all Evolution passwords and delete them. */
+-	passwords = ep_keyring_lookup_passwords (NULL, NULL, &error);
++	passwords = ep_keyring_lookup_passwords (NULL, NULL, NULL, &error);
+ 	if (passwords != NULL) {
+-		ep_keyring_delete_passwords (NULL, NULL, passwords, &error);
++		ep_keyring_delete_passwords (NULL, NULL, NULL, passwords, &error);
+ 		gnome_keyring_found_list_free (passwords);
+ 
+ 	}
+@@ -641,12 +677,13 @@
+ 		return;
+ 	}
+ 
+-	uri = ep_keyring_uri_new (msg->key);
+-	g_return_if_fail (uri != NULL);
++	uri = ep_keyring_uri_new (msg->key, &msg->error);
++	if (uri == NULL)
++		return;
+ 
+ 	/* Only remove the password from the session hash
+ 	 * if the keyring insertion was successful. */
+-	if (ep_keyring_insert_password (uri->user, uri->host, msg->key, password, &error))
++	if (ep_keyring_insert_password (uri->user, uri->host, uri->protocol, msg->key, password, &error))
+ 		g_hash_table_remove (password_cache, msg->key);
+ 
+ 	if (error != NULL)
+@@ -704,13 +741,21 @@
+ 	EUri *uri;
+ 	GError *error = NULL;
+ 
+-	uri = ep_keyring_uri_new (msg->key);
+-	g_return_if_fail (uri != NULL);
++	uri = ep_keyring_uri_new (msg->key, &msg->error);
++	if (uri == NULL)
++		return;
+ 
+-	/* Find all Evolution passwords matching the URI and delete them. */
+-	passwords = ep_keyring_lookup_passwords (uri->user, uri->host, &error);
++	/* Find all Evolution passwords matching the URI and delete them.
++	 *
++	 * XXX We didn't always store protocols in the keyring, so for
++	 *     backward-compatibility we need to lookup passwords by user
++	 *     and host only (no protocol).  But we do send the protocol
++	 *     to ep_keyring_delete_passwords(), which also knows about
++	 *     the backward-compatibility issue and will filter the list
++	 *     appropriately. */
++	passwords = ep_keyring_lookup_passwords (uri->user, uri->host, NULL, &error);
+ 	if (passwords != NULL) {
+-		ep_keyring_delete_passwords (uri->user, uri->host, passwords, &error);
++		ep_keyring_delete_passwords (uri->user, uri->host, uri->protocol, passwords, &error);
+ 		gnome_keyring_found_list_free (passwords);
+ 	}
+ 
+@@ -739,10 +784,10 @@
+ 		g_message ("%s", error->message);
+ 		g_error_free (error);
+ 
+-        /* Not finding the requested group is also acceptable. */
+-        } else if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
+-                g_message ("%s", error->message);
+-                g_error_free (error);
++	/* Not finding the requested group is also acceptable. */
++	} else if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
++		g_message ("%s", error->message);
++		g_error_free (error);
+ 
+ 	} else if (error != NULL)
+ 		g_propagate_error (&msg->error, error);
+@@ -777,18 +822,19 @@
+ 	EUri *uri;
+ 	GError *error = NULL;
+ 
+-	uri = ep_keyring_uri_new (msg->key);
+-	g_return_if_fail (uri != NULL);
++	uri = ep_keyring_uri_new (msg->key, &msg->error);
++	if (uri == NULL)
++		return;
+ 
+ 	/* Find the first Evolution password that matches the URI. */
+-	passwords = ep_keyring_lookup_passwords (uri->user, uri->host, &error);
++	passwords = ep_keyring_lookup_passwords (uri->user, uri->host, uri->protocol, &error);
+ 	if (passwords != NULL) {
+ 		GList *iter = passwords;
+ 
+ 		while (iter != NULL) {
+ 			GnomeKeyringFound *found = iter->data;
+ 
+-			if (ep_keyring_validate (uri->user, uri->host, found->attributes)) {
++			if (ep_keyring_validate (uri->user, uri->host, uri->protocol, found->attributes)) {
+ 				msg->password = g_strdup (found->secret);
+ 				break;
+ 			}
+@@ -799,6 +845,36 @@
+ 		gnome_keyring_found_list_free (passwords);
+ 	}
+ 
++	if (msg->password != NULL)
++		goto done;
++
++	/* Clear the previous error, if there was one.  If the error was
++	 * something other than NO_MATCH then it's likely to occur again. */
++	if (error != NULL)
++		g_clear_error (&error);
++
++	/* XXX We didn't always store protocols in the keyring, so for
++	 *     backward-compatibility we also need to lookup passwords
++	 *     by user and host only (no protocol). */
++	passwords = ep_keyring_lookup_passwords (uri->user, uri->host, NULL, &error);
++	if (passwords != NULL) {
++		GList *iter = passwords;
++
++		while (iter != NULL) {
++			GnomeKeyringFound *found = iter->data;
++
++			if (ep_keyring_validate (uri->user, uri->host, NULL, found->attributes)) {
++				msg->password = g_strdup (found->secret);
++				break;
++			}
++
++			iter = g_list_next (iter);
++		}
++
++		gnome_keyring_found_list_free (passwords);
++	}
++
++done:
+ 	/* Not finding the requested key is acceptable, but we still
+ 	 * want to leave an informational message on the terminal. */
+ 	if (g_error_matches (error, EP_KEYRING_ERROR, GNOME_KEYRING_RESULT_NO_MATCH)) {
+@@ -832,10 +908,10 @@
+ 		g_message ("%s", error->message);
+ 		g_error_free (error);
+ 
+-        /* Not finding the requested group is also acceptable. */
+-        } else if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
+-                g_message ("%s", error->message);
+-                g_error_free (error);
++	/* Not finding the requested group is also acceptable. */
++	} else if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
++		g_message ("%s", error->message);
++		g_error_free (error);
+ 
+ 	} else if (error != NULL)
+ 		g_propagate_error (&msg->error, error);
================================================================


More information about the pld-cvs-commit mailing list