evolution-data-server r8815 - branches/gnome-2-22/libedataserverui



Author: mbarnes
Date: Mon May 19 14:33:15 2008
New Revision: 8815
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8815&view=rev

Log:
2008-05-19  Matthew Barnes  <mbarnes redhat com>

	** Fixes bug #531439

	* e-passwords.c (ep_keyring_uri_new):
	Prevent GPG passphrases from destroying other passwords.  GPG
	passphrases are only cached for the current session, not stored
	permanently in the keyring (mainly because those types of keys
	are not URIs with server and usernames).  We defer to third-party
	GPG agents like Seahorse for persistent storage of passphrases.



Modified:
   branches/gnome-2-22/libedataserverui/ChangeLog
   branches/gnome-2-22/libedataserverui/e-passwords.c

Modified: branches/gnome-2-22/libedataserverui/e-passwords.c
==============================================================================
--- branches/gnome-2-22/libedataserverui/e-passwords.c	(original)
+++ branches/gnome-2-22/libedataserverui/e-passwords.c	Mon May 19 14:33:15 2008
@@ -208,19 +208,29 @@
 }
 
 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;
 }
 
@@ -667,8 +677,9 @@
 		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. */
@@ -730,8 +741,9 @@
 	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.
 	 *
@@ -810,8 +822,9 @@
 	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, uri->protocol, &error);



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