[network-manager-applet/thaller/ca-cert-ignore-save-load: 3/3] fixup! security: don't save CA cert ignore if editing is canceled



commit ad283dcb770d4430b345e89b62c1da11458d8f12
Author: Thomas Haller <thaller redhat com>
Date:   Wed Sep 11 10:16:17 2013 +0200

    fixup! security: don't save CA cert ignore if editing is canceled

 src/wireless-security/eap-method.c |   61 ++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 20 deletions(-)
---
diff --git a/src/wireless-security/eap-method.c b/src/wireless-security/eap-method.c
index 4354fd8..23bedd7 100644
--- a/src/wireless-security/eap-method.c
+++ b/src/wireless-security/eap-method.c
@@ -543,7 +543,9 @@ eap_method_ca_cert_not_required_toggled (GtkBuilder *builder, const char *id_ca_
  *
  * Updates the connection's CA cert ignore value to %TRUE if the "CA certificate
  * not required" checkbox is checked.  If @ca_cert_error is %TRUE, then the
- * connection's CA cert ignore value will always be set to %TRUE.
+ * connection's CA cert ignore value will always be set to %FALSE, because it
+ * means that the user selected an invalid certificate (thus he does not want to
+ * ignore the CA cert)..
  */
 void
 eap_method_ca_cert_ignore_set (EAPMethod *method,
@@ -595,8 +597,14 @@ _get_ca_ignore_settings (NMConnection *connection)
 {
        GSettings *settings;
        char *path = NULL;
+       const char *uuid;
 
-       path = g_strdup_printf ("/org/gnome/nm-applet/eap/%s", nm_connection_get_uuid (connection));
+       g_return_val_if_fail (connection, NULL);
+
+       uuid = nm_connection_get_uuid (connection);
+       g_return_val_if_fail (uuid && *uuid, NULL);
+
+       path = g_strdup_printf ("/org/gnome/nm-applet/eap/%s", uuid);
        settings = g_settings_new_with_path ("org.gnome.nm-applet.eap", path);
        g_free (path);
 
@@ -613,24 +621,30 @@ _get_ca_ignore_settings (NMConnection *connection)
 void
 eap_method_ca_cert_ignore_save (NMConnection *connection)
 {
-       NMSetting8021x *s_8021x = nm_connection_get_setting_802_1x (connection);
+       NMSetting8021x *s_8021x;
        GSettings *settings;
        gboolean ignore = FALSE, phase2_ignore = FALSE;
 
+       g_return_if_fail (connection);
+
+       s_8021x = nm_connection_get_setting_802_1x (connection);
        if (s_8021x) {
                ignore = !!g_object_get_data (G_OBJECT (s_8021x), IGNORE_CA_CERT_TAG);
                phase2_ignore = !!g_object_get_data (G_OBJECT (s_8021x), IGNORE_PHASE2_CA_CERT_TAG);
        }
 
        settings = _get_ca_ignore_settings (connection);
+       if (!settings)
+               return;
+
        g_settings_set_boolean (settings, IGNORE_CA_CERT_TAG, ignore);
        g_settings_set_boolean (settings, IGNORE_PHASE2_CA_CERT_TAG, phase2_ignore);
        g_object_unref (settings);
 }
 
 /**
- * eap_method_ca_cert_ignore_save:
- * @connection: the connection for which to save CA cert ignore values to GSettings
+ * eap_method_ca_cert_ignore_load:
+ * @connection: the connection for which to load CA cert ignore values to GSettings
  *
  * Reads the CA cert ignore tags from the 802.1x setting GObject data and saves
  * then to GSettings if present, using the connection UUID as the index.
@@ -638,22 +652,29 @@ eap_method_ca_cert_ignore_save (NMConnection *connection)
 void
 eap_method_ca_cert_ignore_load (NMConnection *connection)
 {
-       NMSetting8021x *s_8021x = nm_connection_get_setting_802_1x (connection);
        GSettings *settings;
+       NMSetting8021x *s_8021x;
+       gboolean ignore, phase2_ignore;
 
-       if (s_8021x) {
-               settings = _get_ca_ignore_settings (connection);
-               if (g_settings_get_boolean (settings, IGNORE_CA_CERT_TAG)) {
-                       g_object_set_data (G_OBJECT (s_8021x),
-                                          IGNORE_CA_CERT_TAG,
-                                          GUINT_TO_POINTER (TRUE));
-               }
-               if (g_settings_get_boolean (settings, IGNORE_PHASE2_CA_CERT_TAG)) {
-                       g_object_set_data (G_OBJECT (s_8021x),
-                                          IGNORE_PHASE2_CA_CERT_TAG,
-                                          GUINT_TO_POINTER (TRUE));
-               }
-               g_object_unref (settings);
-       }
+       g_return_if_fail (connection);
+
+       s_8021x = nm_connection_get_setting_802_1x (connection);
+       if (!s_8021x)
+               return;
+
+       settings = _get_ca_ignore_settings (connection);
+       if (!settings)
+               return;
+
+       ignore = g_settings_get_boolean (settings, IGNORE_CA_CERT_TAG);
+       phase2_ignore = g_settings_get_boolean (settings, IGNORE_PHASE2_CA_CERT_TAG);
+
+       g_object_set_data (G_OBJECT (s_8021x),
+                          IGNORE_CA_CERT_TAG,
+                          GUINT_TO_POINTER (ignore));
+       g_object_set_data (G_OBJECT (s_8021x),
+                          IGNORE_PHASE2_CA_CERT_TAG,
+                          GUINT_TO_POINTER (phase2_ignore));
+       g_object_unref (settings);
 }
 


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