Blame SOURCES/vinagre-3.8.2-fix-storing-passwords.patch

3274b5
From 7b301aee94c6c6e62ef5afc0c3be88735f03ba0e Mon Sep 17 00:00:00 2001
3274b5
From: David King <amigadave@amigadave.com>
3274b5
Date: Tue, 23 Jul 2013 19:50:34 +0000
3274b5
Subject: Fix credential access with libsecret, bug 704744
3274b5
3274b5
When storing attributes in libsecret, string attributes are not
3274b5
permitted to have NULL values. The existing workaround for this was
3274b5
wrong, as it removed the ability to store passwords for username-less
3274b5
connections.  Fix this by terminating the attribute list with a NULL
3274b5
attribute, thus ending the list, if there is no username.
3274b5
---
3274b5
diff --git a/plugins/vnc/vinagre-vnc-tab.c b/plugins/vnc/vinagre-vnc-tab.c
3274b5
index 7cae9f2..73a13b8 100644
3274b5
--- a/plugins/vnc/vinagre-vnc-tab.c
3274b5
+++ b/plugins/vnc/vinagre-vnc-tab.c
3274b5
@@ -492,11 +492,7 @@ vnc_authentication_cb (VncDisplay *vnc, GValueArray *credList, VinagreVncTab *vn
3274b5
 
3274b5
   if (need_password || need_username)
3274b5
     {
3274b5
-      /* libsecret does not support NULL attributes, bug 685041. */
3274b5
-      if (vinagre_connection_get_username (conn) != NULL)
3274b5
-        {
3274b5
-          vinagre_tab_find_credentials_in_keyring (tab, &username, &password);
3274b5
-        }
3274b5
+      vinagre_tab_find_credentials_in_keyring (tab, &username, &password);
3274b5
 
3274b5
       if ( (need_username && !username) || (need_password && !password) )
3274b5
 	{
3274b5
diff --git a/vinagre/vinagre-tab.c b/vinagre/vinagre-tab.c
3274b5
index 2f06e0d..284e469 100644
3274b5
--- a/vinagre/vinagre-tab.c
3274b5
+++ b/vinagre/vinagre-tab.c
3274b5
@@ -745,19 +745,21 @@ vinagre_tab_get_from_connection (VinagreConnection *conn)
3274b5
 gboolean
3274b5
 vinagre_tab_find_credentials_in_keyring (VinagreTab *tab, gchar **username, gchar **password)
3274b5
 {
3274b5
+  const gchar *conn_user = vinagre_connection_get_username (tab->priv->conn);
3274b5
   *username = NULL;
3274b5
 
3274b5
+  /* "user" goes last, to terminate the attribute list if conn_user is NULL. */
3274b5
   *password = secret_password_lookup_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL, NULL,
3274b5
-                                           "user", vinagre_connection_get_username (tab->priv->conn),
3274b5
                                            "server", vinagre_connection_get_host (tab->priv->conn),
3274b5
                                            "protocol", vinagre_connection_get_protocol (tab->priv->conn),
3274b5
                                            "port", vinagre_connection_get_port (tab->priv->conn),
3274b5
+                                           conn_user ? "user" : NULL, conn_user,
3274b5
                                            NULL);
3274b5
 
3274b5
   if (*password == NULL)
3274b5
     return FALSE;
3274b5
 
3274b5
-  *username = g_strdup (vinagre_connection_get_username (tab->priv->conn));
3274b5
+  *username = g_strdup (conn_user);
3274b5
   return TRUE;
3274b5
 }
3274b5
 
3274b5
@@ -771,18 +773,20 @@ vinagre_tab_save_credentials_in_keyring (VinagreTab *tab)
3274b5
 {
3274b5
   GError *error = NULL;
3274b5
   gchar *label;
3274b5
+  const gchar *conn_user = vinagre_connection_get_username (tab->priv->conn);
3274b5
 
3274b5
   if (!tab->priv->save_credentials)
3274b5
     return;
3274b5
 
3274b5
   label = g_strdup_printf (_("Remote desktop password: %s"), vinagre_connection_get_host (tab->priv->conn));
3274b5
+  /* "user" goes last, to terminate the attribute list if conn_user is NULL. */
3274b5
   secret_password_store_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL,
3274b5
                               label, vinagre_connection_get_password (tab->priv->conn),
3274b5
                               NULL, &error,
3274b5
-                              "user", vinagre_connection_get_username (tab->priv->conn),
3274b5
                               "server", vinagre_connection_get_host (tab->priv->conn),
3274b5
                               "protocol", vinagre_connection_get_protocol (tab->priv->conn),
3274b5
                               "port", vinagre_connection_get_port (tab->priv->conn),
3274b5
+                              conn_user ? "user" : NULL, conn_user,
3274b5
                               NULL);
3274b5
   g_free (label);
3274b5
 
3274b5
@@ -803,11 +807,13 @@ void vinagre_tab_remove_credentials_from_keyring (VinagreTab *tab)
3274b5
 {
3274b5
   if (tab->priv->saved_credentials)
3274b5
     {
3274b5
+      /* Put "user" last, to terminate the attributes if conn_user is NULL. */
3274b5
+      const gchar *conn_user = vinagre_connection_get_username (tab->priv->conn);
3274b5
       secret_password_clear_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL, NULL,
3274b5
-                                  "user", vinagre_connection_get_username (tab->priv->conn),
3274b5
                                   "server", vinagre_connection_get_host (tab->priv->conn),
3274b5
                                   "protocol", vinagre_connection_get_protocol (tab->priv->conn),
3274b5
                                   "port", vinagre_connection_get_port (tab->priv->conn),
3274b5
+                                  conn_user ? "user" : NULL, conn_user,
3274b5
                                   NULL);
3274b5
       tab->priv->saved_credentials = FALSE;
3274b5
     }
3274b5
--
3274b5
cgit v0.9.2