[network-manager-applet/NETWORKMANAGER_APPLET_0_7] gconf: ensure changes to certificate and key paths get remembered



commit db17e112e77831b00157f361bea1178bd5a68f7f
Author: Dan Williams <dcbw redhat com>
Date:   Wed Dec 9 14:44:17 2009 -0800

    gconf: ensure changes to certificate and key paths get remembered
    
    Because the GConf update-event code was not checking the new connections'
    private values (which store cert and key paths) if the user only updated
    certificate or key paths in the connection editor, the change would be
    reverted the next time the applet connected to that AP since the applet
    writes the connection back out to GConf when updating the timestamp when
    the connection is active.  Unless the user logged out or rebooted before
    connecting to that AP.

 src/gconf-helpers/gconf-helpers.c        |   56 ++++++++++++++++++++++++++++++
 src/gconf-helpers/gconf-helpers.h        |    1 +
 src/gconf-helpers/nma-gconf-connection.c |    6 +++-
 3 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c
index 8ebb9ae..a2c9afc 100644
--- a/src/gconf-helpers/gconf-helpers.c
+++ b/src/gconf-helpers/gconf-helpers.c
@@ -1909,6 +1909,62 @@ nm_gconf_clear_private_connection_values (NMConnection *connection)
 	g_object_set_data (G_OBJECT (connection), NMA_PHASE2_PRIVATE_KEY_PASSWORD_TAG, NULL);
 }
 
+static gboolean
+string_compare (NMConnection *dst, NMConnection *src, const char *tag)
+{
+	const char *s1, *s2;
+
+	s1 = (const char *) g_object_get_data (G_OBJECT (src), tag);
+	s2 = (const char *) g_object_get_data (G_OBJECT (dst), tag);
+
+	if (s1 && !s2)
+		return FALSE;
+	if (!s1 && s2)
+		return FALSE;
+	if (!s1 && !s2)
+		return TRUE;
+	g_assert (s1 && s2);
+	return !strcmp (s1, s2);
+}
+
+gboolean
+nm_gconf_compare_private_connection_values (NMConnection *dst, NMConnection *src)
+{
+	gboolean val1, val2;
+
+	g_return_val_if_fail (NM_IS_CONNECTION (dst), FALSE);
+	g_return_val_if_fail (NM_IS_CONNECTION (src), FALSE);
+
+	val1 = !!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (src), NMA_CA_CERT_IGNORE_TAG));
+	val2 = !!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (dst), NMA_CA_CERT_IGNORE_TAG));
+	if (val1 != val2)
+		return FALSE;
+
+	val1 = !!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (src), NMA_PHASE2_CA_CERT_IGNORE_TAG));
+	val2 = !!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (dst), NMA_PHASE2_CA_CERT_IGNORE_TAG));
+	if (val1 != val2)
+		return FALSE;
+
+	if (!string_compare (src, dst, NMA_PATH_CLIENT_CERT_TAG))
+		return FALSE;
+	if (!string_compare (src, dst, NMA_PATH_PHASE2_CLIENT_CERT_TAG))
+		return FALSE;
+	if (!string_compare (src, dst, NMA_PATH_CA_CERT_TAG))
+		return FALSE;
+	if (!string_compare (src, dst, NMA_PATH_PHASE2_CA_CERT_TAG))
+		return FALSE;
+	if (!string_compare (src, dst, NMA_PATH_PRIVATE_KEY_TAG))
+		return FALSE;
+	if (!string_compare (src, dst, NMA_PRIVATE_KEY_PASSWORD_TAG))
+		return FALSE;
+	if (!string_compare (src, dst, NMA_PATH_PHASE2_PRIVATE_KEY_TAG))
+		return FALSE;
+	if (!string_compare (src, dst, NMA_PHASE2_PRIVATE_KEY_PASSWORD_TAG))
+		return FALSE;
+
+	return TRUE;
+}
+
 NMConnection *
 nm_gconf_connection_duplicate (NMConnection *connection)
 {
diff --git a/src/gconf-helpers/gconf-helpers.h b/src/gconf-helpers/gconf-helpers.h
index 3653c39..e306f3c 100644
--- a/src/gconf-helpers/gconf-helpers.h
+++ b/src/gconf-helpers/gconf-helpers.h
@@ -56,6 +56,7 @@ NMConnection *nm_gconf_connection_duplicate (NMConnection *connection);
 
 void nm_gconf_copy_private_connection_values (NMConnection *dst, NMConnection *src);
 void nm_gconf_clear_private_connection_values (NMConnection *connection);
+gboolean nm_gconf_compare_private_connection_values (NMConnection *dst, NMConnection *src);
 
 #define KEYRING_UUID_TAG "connection-uuid"
 #define KEYRING_SN_TAG "setting-name"
diff --git a/src/gconf-helpers/nma-gconf-connection.c b/src/gconf-helpers/nma-gconf-connection.c
index 504595f..c3c69d4 100644
--- a/src/gconf-helpers/nma-gconf-connection.c
+++ b/src/gconf-helpers/nma-gconf-connection.c
@@ -173,9 +173,13 @@ nma_gconf_connection_changed (NMAGConfConnection *self)
 	utils_clear_filled_connection_certs (gconf_connection);
 
 	/* Ignore the GConf update if nothing changed */
-	if (nm_connection_compare (wrapped_connection, gconf_connection, NM_SETTING_COMPARE_FLAG_EXACT))
+	if (   nm_connection_compare (wrapped_connection, gconf_connection, NM_SETTING_COMPARE_FLAG_EXACT)
+	    && nm_gconf_compare_private_connection_values (wrapped_connection, gconf_connection))
 		return TRUE;
 
+	/* Update private values to catch any certificate path changes */
+	nm_gconf_copy_private_connection_values (wrapped_connection, gconf_connection);
+
 	utils_fill_connection_certs (gconf_connection);
 	new_settings = nm_connection_to_hash (gconf_connection);
 	utils_clear_filled_connection_certs (gconf_connection);



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