diff options
author | Andrew Zaborowski <andrew.zaborowski@intel.com> | 2020-11-07 04:50:47 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-11-18 16:34:07 +0100 |
commit | 3eb6da6b9f706c3cd8fc4d2e0ddbd07d3918656d (patch) | |
tree | e9cf469442cadbfc445bb62218a044970f026834 /src | |
parent | 66e9adfb8bd96df53b933c9c11b47d38d6ff9db1 (diff) | |
download | network-manager-applet-3eb6da6b9f706c3cd8fc4d2e0ddbd07d3918656d.tar.gz |
all: Remove most of wireless-security
Since only two utilities are now used from wireless-security, go ahead
and remove everything else.
Diffstat (limited to 'src')
47 files changed, 8 insertions, 6987 deletions
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c index c1582958..8e957e92 100644 --- a/src/ap-menu-item.c +++ b/src/ap-menu-item.c @@ -18,9 +18,6 @@ #include "nm-access-point.h" #include "mobile-helpers.h" -/* Only to get the NMU_SEC_SAE compat constant. */ -#include "wireless-security.h" - G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_MENU_ITEM); #define NM_NETWORK_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_NETWORK_MENU_ITEM, NMNetworkMenuItemPrivate)) @@ -297,7 +294,10 @@ nm_network_menu_item_new (NMAccessPoint *ap, #if NM_CHECK_VERSION(1,24,0) && !nm_utils_security_valid (NMU_SEC_OWE, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, ap_rsn) #endif - && !nm_utils_security_valid (NMU_SEC_SAE, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, ap_rsn)) { +#if NM_CHECK_VERSION(1,22,0) + && !nm_utils_security_valid (NMU_SEC_SAE, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, ap_rsn) +#endif + ) { gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); } diff --git a/src/connection-editor/meson.build b/src/connection-editor/meson.build index f36e0709..48e598d8 100644 --- a/src/connection-editor/meson.build +++ b/src/connection-editor/meson.build @@ -88,7 +88,8 @@ deps = [ gtk_dep, libnm_dep, libnma_dep, - m_dep + m_dep, + libutils_libnm_dep ] cflags = [ diff --git a/src/meson.build b/src/meson.build index a394068c..2d910bb2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -47,7 +47,8 @@ deps = [ libnma_dep, libnotify_dep, libsecret_dep, - m_dep + m_dep, + libutils_libnm_dep ] cflags = [ diff --git a/src/wireless-security/eap-method-fast.c b/src/wireless-security/eap-method-fast.c deleted file mode 100644 index 311371c3..00000000 --- a/src/wireless-security/eap-method-fast.c +++ /dev/null @@ -1,438 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * EAP-FAST authentication method (RFC4851) - * - * Copyright 2012 - 2017 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "eap-method.h" -#include "wireless-security.h" -#include "utils.h" -#include "helpers.h" - -#define I_NAME_COLUMN 0 -#define I_METHOD_COLUMN 1 - -struct _EAPMethodFAST { - EAPMethod parent; - - const char *password_flags_name; - GtkSizeGroup *size_group; - WirelessSecurity *sec_parent; - gboolean is_editor; -}; - -static void -destroy (EAPMethod *parent) -{ - EAPMethodFAST *method = (EAPMethodFAST *) parent; - - if (method->size_group) - g_object_unref (method->size_group); -} - -static gboolean -validate (EAPMethod *parent, GError **error) -{ - GtkWidget *widget; - GtkTreeModel *model; - GtkTreeIter iter; - EAPMethod *eap = NULL; - const char *file; - gboolean provisioning; - gboolean valid = TRUE; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton")); - g_assert (widget); - provisioning = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_button")); - g_assert (widget); - file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); - if (!provisioning && !file) { - widget_set_error (widget); - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing EAP-FAST PAC file")); - valid = FALSE; - } else - widget_unset_error (widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_combo")); - g_assert (widget); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - valid = eap_method_validate (eap, valid ? error : NULL) && valid; - eap_method_unref (eap); - return valid; -} - -static void -add_to_size_group (EAPMethod *parent, GtkSizeGroup *group) -{ - EAPMethodFAST *method = (EAPMethodFAST *) parent; - GtkWidget *widget; - GtkTreeModel *model; - GtkTreeIter iter; - EAPMethod *eap; - - if (method->size_group) - g_object_unref (method->size_group); - method->size_group = g_object_ref (group); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_anon_identity_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_combo")); - g_assert (widget); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - eap_method_add_to_size_group (eap, group); - eap_method_unref (eap); -} - -static void -fill_connection (EAPMethod *parent, NMConnection *connection) -{ - NMSetting8021x *s_8021x; - GtkWidget *widget; - const char *text; - char *filename; - EAPMethod *eap = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean enabled; - int pac_provisioning = 0; - - s_8021x = nm_connection_get_setting_802_1x (connection); - g_assert (s_8021x); - - nm_setting_802_1x_add_eap_method (s_8021x, "fast"); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_anon_identity_entry")); - g_assert (widget); - text = gtk_entry_get_text (GTK_ENTRY (widget)); - if (text && strlen (text)) - g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, text, NULL); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_button")); - g_assert (widget); - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); - g_object_set (s_8021x, NM_SETTING_802_1X_PAC_FILE, filename, NULL); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton")); - enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - - if (!enabled) - g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, "0", NULL); - else { - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_combo")); - pac_provisioning = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); - - switch (pac_provisioning) { - case 0: /* Anonymous */ - g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, "1", NULL); - break; - case 1: /* Authenticated */ - g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, "2", NULL); - break; - case 2: /* Both - anonymous and authenticated */ - g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, "3", NULL); - break; - default: /* Should not happen */ - g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, "1", NULL); - break; - } - } - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_combo")); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - - eap_method_fill_connection (eap, connection); - eap_method_unref (eap); -} - -static void -inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data) -{ - EAPMethod *parent = (EAPMethod *) user_data; - EAPMethodFAST *method = (EAPMethodFAST *) parent; - GtkWidget *vbox; - EAPMethod *eap = NULL; - GList *elt, *children; - GtkTreeModel *model; - GtkTreeIter iter; - GtkWidget *eap_widget; - - vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_vbox")); - g_assert (vbox); - - /* Remove any previous wireless security widgets */ - children = gtk_container_get_children (GTK_CONTAINER (vbox)); - for (elt = children; elt; elt = g_list_next (elt)) - gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data)); - g_list_free (children); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - - eap_widget = eap_method_get_widget (eap); - g_assert (eap_widget); - gtk_widget_unparent (eap_widget); - - if (method->size_group) - eap_method_add_to_size_group (eap, method->size_group); - gtk_container_add (GTK_CONTAINER (vbox), eap_widget); - - eap_method_unref (eap); - - wireless_security_changed_cb (combo, method->sec_parent); -} - -static GtkWidget * -inner_auth_combo_init (EAPMethodFAST *method, - NMConnection *connection, - NMSetting8021x *s_8021x, - gboolean secrets_only) -{ - EAPMethod *parent = (EAPMethod *) method; - GtkWidget *combo; - GtkListStore *auth_model; - GtkTreeIter iter; - EAPMethodSimple *em_gtc; - EAPMethodSimple *em_mschap_v2; - guint32 active = 0; - const char *phase2_auth = NULL; - EAPMethodSimpleFlags simple_flags; - - auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ()); - - if (s_8021x) { - if (nm_setting_802_1x_get_phase2_auth (s_8021x)) - phase2_auth = nm_setting_802_1x_get_phase2_auth (s_8021x); - else if (nm_setting_802_1x_get_phase2_autheap (s_8021x)) - phase2_auth = nm_setting_802_1x_get_phase2_autheap (s_8021x); - } - - simple_flags = EAP_METHOD_SIMPLE_FLAG_PHASE2; - if (method->is_editor) - simple_flags |= EAP_METHOD_SIMPLE_FLAG_IS_EDITOR; - if (secrets_only) - simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY; - - em_gtc = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_GTC, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("GTC"), - I_METHOD_COLUMN, em_gtc, - -1); - eap_method_unref (EAP_METHOD (em_gtc)); - - /* Check for defaulting to GTC */ - if (phase2_auth && !strcasecmp (phase2_auth, "gtc")) - active = 0; - - em_mschap_v2 = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("MSCHAPv2"), - I_METHOD_COLUMN, em_mschap_v2, - -1); - eap_method_unref (EAP_METHOD (em_mschap_v2)); - - /* Check for defaulting to MSCHAPv2 */ - if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2")) - active = 1; - - combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_combo")); - g_assert (combo); - - gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); - g_object_unref (G_OBJECT (auth_model)); - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active); - - g_signal_connect (G_OBJECT (combo), "changed", - (GCallback) inner_auth_combo_changed_cb, - method); - return combo; -} - -static void -update_secrets (EAPMethod *parent, NMConnection *connection) -{ - eap_method_phase2_update_secrets_helper (parent, - connection, - "eap_fast_inner_auth_combo", - I_METHOD_COLUMN); -} - -static void -pac_toggled_cb (GtkWidget *widget, gpointer user_data) -{ - EAPMethod *parent = (EAPMethod *) user_data; - EAPMethodFAST *method = (EAPMethodFAST *) parent; - gboolean enabled = FALSE; - GtkWidget *provision_combo; - - provision_combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_combo")); - g_return_if_fail (provision_combo); - - enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - - gtk_widget_set_sensitive (provision_combo, enabled); - - wireless_security_changed_cb (widget, method->sec_parent); -} - -EAPMethodFAST * -eap_method_fast_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean is_editor, - gboolean secrets_only) -{ - EAPMethod *parent; - EAPMethodFAST *method; - GtkWidget *widget; - GtkFileFilter *filter; - NMSetting8021x *s_8021x = NULL; - const char *filename; - gboolean provisioning_enabled = TRUE; - - parent = eap_method_init (sizeof (EAPMethodFAST), - validate, - add_to_size_group, - fill_connection, - update_secrets, - destroy, - "/org/freedesktop/network-manager-applet/eap-method-fast.ui", - "eap_fast_notebook", - "eap_fast_anon_identity_entry", - FALSE); - if (!parent) - return NULL; - - method = (EAPMethodFAST *) parent; - method->password_flags_name = NM_SETTING_802_1X_PASSWORD; - method->sec_parent = ws_parent; - method->is_editor = is_editor; - - if (connection) - s_8021x = nm_connection_get_setting_802_1x (connection); - - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_combo")); - g_assert (widget); - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); - if (s_8021x) { - const char *fast_prov; - - fast_prov = nm_setting_802_1x_get_phase1_fast_provisioning (s_8021x); - if (fast_prov) { - if (!strcmp (fast_prov, "0")) - provisioning_enabled = FALSE; - else if (!strcmp (fast_prov, "1")) - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); - else if (!strcmp (fast_prov, "2")) - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1); - else if (!strcmp (fast_prov, "3")) - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2); - } - } - gtk_widget_set_sensitive (widget, provisioning_enabled); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), provisioning_enabled); - g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (pac_toggled_cb), parent); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_anon_identity_entry")); - if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x)) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x)); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_button")); - g_assert (widget); - gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), TRUE); - gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (widget), - _("Choose a PAC file")); - g_signal_connect (G_OBJECT (widget), "selection-changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - filter = gtk_file_filter_new (); - gtk_file_filter_add_pattern (filter, "*.pac"); - gtk_file_filter_set_name (filter, _("PAC files (*.pac)")); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter); - filter = gtk_file_filter_new (); - gtk_file_filter_add_pattern (filter, "*"); - gtk_file_filter_set_name (filter, _("All files")); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter); - - if (connection && s_8021x) { - filename = nm_setting_802_1x_get_pac_file (s_8021x); - if (filename) - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename); - } - - widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only); - inner_auth_combo_changed_cb (widget, (gpointer) method); - - if (secrets_only) { - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_anon_identity_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_anon_identity_entry")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_combo")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_button")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_combo")); - gtk_widget_hide (widget); - } - - return method; -} - diff --git a/src/wireless-security/eap-method-fast.h b/src/wireless-security/eap-method-fast.h deleted file mode 100644 index 0948eb1d..00000000 --- a/src/wireless-security/eap-method-fast.h +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* vim: set ft=c ts=4 sts=4 sw=4 noexpandtab smartindent: */ - -/* EAP-FAST authentication method (RFC4851) - * - * (C) Copyright 2012 Red Hat, Inc. - */ - -#ifndef EAP_METHOD_FAST_H -#define EAP_METHOD_FAST_H - -#include "wireless-security.h" - -typedef struct _EAPMethodFAST EAPMethodFAST; - -EAPMethodFAST *eap_method_fast_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean is_editor, - gboolean secrets_only); - -#endif /* EAP_METHOD_FAST_H */ - diff --git a/src/wireless-security/eap-method-fast.ui b/src/wireless-security/eap-method-fast.ui deleted file mode 100644 index 774a0921..00000000 --- a/src/wireless-security/eap-method-fast.ui +++ /dev/null @@ -1,183 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkListStore" id="model8"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0"> </col> - </row> - </data> - </object> - <object class="GtkListStore" id="model9"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">Anonymous</col> - </row> - <row> - <col id="0" translatable="yes">Authenticated</col> - </row> - <row> - <col id="0" translatable="yes">Both</col> - </row> - </data> - </object> - <object class="GtkNotebook" id="eap_fast_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="table13"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="eap_fast_anon_identity_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Anony_mous identity</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_fast_anon_identity_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_fast_anon_identity_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_fast_pac_file_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">PAC _file</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_fast_pac_file_button</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkFileChooserButton" id="eap_fast_pac_file_button"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkBox" id="eap_fast_inner_auth_vbox"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> - <property name="width">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_fast_inner_auth_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Inner authentication</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_fast_inner_auth_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="eap_fast_inner_auth_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="model">model8</property> - <child> - <object class="GtkCellRendererText" id="renderer8"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="eap_fast_pac_provision_checkbutton"> - <property name="label" translatable="yes">Allow automatic PAC pro_visioning</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="eap_fast_pac_provision_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="model">model9</property> - <child> - <object class="GtkCellRendererText" id="renderer9"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="label61"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/eap-method-leap.c b/src/wireless-security/eap-method-leap.c deleted file mode 100644 index 2f43ab85..00000000 --- a/src/wireless-security/eap-method-leap.c +++ /dev/null @@ -1,250 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "eap-method.h" -#include "wireless-security.h" -#include "helpers.h" -#include "nma-ui-utils.h" -#include "utils.h" - -struct _EAPMethodLEAP { - EAPMethod parent; - - WirelessSecurity *ws_parent; - - gboolean editing_connection; - - const char *password_flags_name; - GtkEntry *username_entry; - GtkEntry *password_entry; - GtkToggleButton *show_password; -}; - -static void -show_toggled_cb (GtkToggleButton *button, EAPMethodLEAP *method) -{ - gboolean visible; - - visible = gtk_toggle_button_get_active (button); - gtk_entry_set_visibility (method->password_entry, visible); -} - -static gboolean -validate (EAPMethod *parent, GError **error) -{ - EAPMethodLEAP *method = (EAPMethodLEAP *)parent; - const char *text; - gboolean ret = TRUE; - - text = gtk_entry_get_text (method->username_entry); - if (!text || !strlen (text)) { - widget_set_error (GTK_WIDGET (method->username_entry)); - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing EAP-LEAP username")); - ret = FALSE; - } else - widget_unset_error (GTK_WIDGET (method->username_entry)); - - text = gtk_entry_get_text (method->password_entry); - if (!text || !strlen (text)) { - widget_set_error (GTK_WIDGET (method->password_entry)); - if (ret) { - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing EAP-LEAP password")); - ret = FALSE; - } - } else - widget_unset_error (GTK_WIDGET (method->password_entry)); - - return ret; -} - -static void -add_to_size_group (EAPMethod *parent, GtkSizeGroup *group) -{ - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_username_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_password_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); -} - -static void -fill_connection (EAPMethod *parent, NMConnection *connection) -{ - EAPMethodLEAP *method = (EAPMethodLEAP *) parent; - NMSetting8021x *s_8021x; - NMSettingSecretFlags secret_flags; - GtkWidget *passwd_entry; - - s_8021x = nm_connection_get_setting_802_1x (connection); - g_assert (s_8021x); - - nm_setting_802_1x_add_eap_method (s_8021x, "leap"); - - g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (method->username_entry), NULL); - g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, gtk_entry_get_text (method->password_entry), NULL); - - passwd_entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_password_entry")); - g_assert (passwd_entry); - - /* Save 802.1X password flags to the connection */ - secret_flags = nma_utils_menu_to_secret_flags (passwd_entry); - nm_setting_set_secret_flags (NM_SETTING (s_8021x), method->password_flags_name, - secret_flags, NULL); - - /* Update secret flags and popup when editing the connection */ - if (method->editing_connection) - nma_utils_update_password_storage (passwd_entry, secret_flags, - NM_SETTING (s_8021x), method->password_flags_name); -} - -static void -update_secrets (EAPMethod *parent, NMConnection *connection) -{ - helper_fill_secret_entry (connection, - parent->builder, - "eap_leap_password_entry", - NM_TYPE_SETTING_802_1X, - (HelperSecretFunc) nm_setting_802_1x_get_password); -} - -/* Set the UI fields for user, password and show_password to the - * values as provided by method->ws_parent. */ -static void -set_userpass_ui (EAPMethodLEAP *method) -{ - if (method->ws_parent->username) - gtk_entry_set_text (method->username_entry, method->ws_parent->username); - else - gtk_entry_set_text (method->username_entry, ""); - - if (method->ws_parent->password && !method->ws_parent->always_ask) - gtk_entry_set_text (method->password_entry, method->ws_parent->password); - else - gtk_entry_set_text (method->password_entry, ""); - - gtk_toggle_button_set_active (method->show_password, method->ws_parent->show_password); -} - -static void -widgets_realized (GtkWidget *widget, EAPMethodLEAP *method) -{ - set_userpass_ui (method); -} - -static void -widgets_unrealized (GtkWidget *widget, EAPMethodLEAP *method) -{ - wireless_security_set_userpass (method->ws_parent, - gtk_entry_get_text (method->username_entry), - gtk_entry_get_text (method->password_entry), - (gboolean) -1, - gtk_toggle_button_get_active (method->show_password)); -} - -static void -destroy (EAPMethod *parent) -{ - EAPMethodLEAP *method = (EAPMethodLEAP *) parent; - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_notebook")); - g_assert (widget); - g_signal_handlers_disconnect_by_data (widget, method); - - g_signal_handlers_disconnect_by_data (method->username_entry, method->ws_parent); - g_signal_handlers_disconnect_by_data (method->password_entry, method->ws_parent); - g_signal_handlers_disconnect_by_data (method->show_password, method); -} - -EAPMethodLEAP * -eap_method_leap_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean secrets_only) -{ - EAPMethodLEAP *method; - EAPMethod *parent; - GtkWidget *widget; - NMSetting8021x *s_8021x = NULL; - - parent = eap_method_init (sizeof (EAPMethodLEAP), - validate, - add_to_size_group, - fill_connection, - update_secrets, - destroy, - "/org/freedesktop/network-manager-applet/eap-method-leap.ui", - "eap_leap_notebook", - "eap_leap_username_entry", - FALSE); - if (!parent) - return NULL; - - method = (EAPMethodLEAP *) parent; - method->password_flags_name = NM_SETTING_802_1X_PASSWORD; - method->editing_connection = secrets_only ? FALSE : TRUE; - method->ws_parent = ws_parent; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_notebook")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "realize", - (GCallback) widgets_realized, - method); - g_signal_connect (G_OBJECT (widget), "unrealize", - (GCallback) widgets_unrealized, - method); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_username_entry")); - g_assert (widget); - method->username_entry = GTK_ENTRY (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - if (secrets_only) - gtk_widget_set_sensitive (widget, FALSE); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_password_entry")); - g_assert (widget); - method->password_entry = GTK_ENTRY (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - /* Create password-storage popup menu for password entry under entry's secondary icon */ - if (connection) - s_8021x = nm_connection_get_setting_802_1x (connection); - nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, method->password_flags_name, - FALSE, secrets_only); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapleap")); - g_assert (widget); - method->show_password = GTK_TOGGLE_BUTTON (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) show_toggled_cb, - parent); - - /* Initialize the UI fields with the security settings from method->ws_parent. - * This will be done again when the widget gets realized. It must be done here as well, - * because the outer dialog will ask to 'validate' the connection before the security tab - * is shown/realized (to enable the 'Apply' button). - * As 'validate' accesses the contents of the UI fields, they must be initialized now, even - * if the widgets are not yet visible. */ - set_userpass_ui (method); - - return method; -} - diff --git a/src/wireless-security/eap-method-leap.h b/src/wireless-security/eap-method-leap.h deleted file mode 100644 index 457d13ca..00000000 --- a/src/wireless-security/eap-method-leap.h +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * (C) Copyright 2007 - 2010 Red Hat, Inc. - */ - -#ifndef EAP_METHOD_LEAP_H -#define EAP_METHOD_LEAP_H - -#include "wireless-security.h" - -typedef struct _EAPMethodLEAP EAPMethodLEAP; - -EAPMethodLEAP *eap_method_leap_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean secrets_only); - -#endif /* EAP_METHOD_LEAP_H */ - diff --git a/src/wireless-security/eap-method-leap.ui b/src/wireless-security/eap-method-leap.ui deleted file mode 100644 index 8b33b820..00000000 --- a/src/wireless-security/eap-method-leap.ui +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkNotebook" id="eap_leap_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="table9"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="valign">start</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="eap_leap_username_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Username</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_leap_username_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_leap_password_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Password</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_leap_password_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_leap_password_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="visibility">False</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="show_checkbutton_eapleap"> - <property name="label" translatable="yes">Sho_w password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_leap_username_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="label43"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/eap-method-peap.c b/src/wireless-security/eap-method-peap.c deleted file mode 100644 index 8b51f11b..00000000 --- a/src/wireless-security/eap-method-peap.c +++ /dev/null @@ -1,486 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2017 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "eap-method.h" -#include "wireless-security.h" -#include "nma-cert-chooser.h" -#include "utils.h" - -#define I_NAME_COLUMN 0 -#define I_METHOD_COLUMN 1 - -struct _EAPMethodPEAP { - EAPMethod parent; - - const char *password_flags_name; - GtkSizeGroup *size_group; - WirelessSecurity *sec_parent; - gboolean is_editor; - GtkWidget *ca_cert_chooser; -}; - -static void -destroy (EAPMethod *parent) -{ - EAPMethodPEAP *method = (EAPMethodPEAP *) parent; - - if (method->size_group) - g_object_unref (method->size_group); -} - -static gboolean -validate (EAPMethod *parent, GError **error) -{ - EAPMethodPEAP *method = (EAPMethodPEAP *) parent; - GtkWidget *widget; - GtkTreeModel *model; - GtkTreeIter iter; - EAPMethod *eap = NULL; - gboolean valid = FALSE; - - if ( gtk_widget_get_sensitive (method->ca_cert_chooser) - && !nma_cert_chooser_validate (NMA_CERT_CHOOSER (method->ca_cert_chooser), error)) - return FALSE; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo")); - g_assert (widget); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - valid = eap_method_validate (eap, error); - eap_method_unref (eap); - return valid; -} - -static void -ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data) -{ - EAPMethodPEAP *method = (EAPMethodPEAP *) user_data; - - gtk_widget_set_sensitive (method->ca_cert_chooser, - !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))); -} - -static void -add_to_size_group (EAPMethod *parent, GtkSizeGroup *group) -{ - EAPMethodPEAP *method = (EAPMethodPEAP *) parent; - GtkWidget *widget; - GtkTreeModel *model; - GtkTreeIter iter; - EAPMethod *eap; - - if (method->size_group) - g_object_unref (method->size_group); - method->size_group = g_object_ref (group); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_domain_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - nma_cert_chooser_add_to_size_group (NMA_CERT_CHOOSER (method->ca_cert_chooser), group); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo")); - g_assert (widget); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - eap_method_add_to_size_group (eap, group); - eap_method_unref (eap); -} - -static void -fill_connection (EAPMethod *parent, NMConnection *connection) -{ - EAPMethodPEAP *method = (EAPMethodPEAP *) parent; - NMSetting8021x *s_8021x; - NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GtkWidget *widget; - const char *text; - char *value = NULL; - EAPMethod *eap = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - int peapver_active = 0; - GError *error = NULL; - gboolean ca_cert_error = FALSE; - NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_UNKNOWN; - NMSettingSecretFlags secret_flags; - - s_8021x = nm_connection_get_setting_802_1x (connection); - g_assert (s_8021x); - - nm_setting_802_1x_add_eap_method (s_8021x, "peap"); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_entry")); - g_assert (widget); - text = gtk_entry_get_text (GTK_ENTRY (widget)); - if (text && strlen (text)) - g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, text, NULL); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_domain_entry")); - g_assert (widget); - text = gtk_entry_get_text (GTK_ENTRY (widget)); - if (text && strlen (text)) - g_object_set (s_8021x, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, text, NULL); - - /* Save CA certificate PIN and its flags to the connection */ - secret_flags = nma_cert_chooser_get_cert_password_flags (NMA_CERT_CHOOSER (method->ca_cert_chooser)); - nm_setting_set_secret_flags (NM_SETTING (s_8021x), NM_SETTING_802_1X_CA_CERT_PASSWORD, - secret_flags, NULL); - if (method->is_editor) { - /* Update secret flags and popup when editing the connection */ - nma_cert_chooser_update_cert_password_storage (NMA_CERT_CHOOSER (method->ca_cert_chooser), - secret_flags, NM_SETTING (s_8021x), - NM_SETTING_802_1X_CA_CERT_PASSWORD); - g_object_set (s_8021x, NM_SETTING_802_1X_CA_CERT_PASSWORD, - nma_cert_chooser_get_cert_password (NMA_CERT_CHOOSER (method->ca_cert_chooser)), - NULL); - } - - /* TLS CA certificate */ - if (gtk_widget_get_sensitive (method->ca_cert_chooser)) - value = nma_cert_chooser_get_cert (NMA_CERT_CHOOSER (method->ca_cert_chooser), &scheme); - format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - if (!nm_setting_802_1x_set_ca_cert (s_8021x, value, scheme, &format, &error)) { - g_warning ("Couldn't read CA certificate '%s': %s", value, error ? error->message : "(unknown)"); - g_clear_error (&error); - ca_cert_error = TRUE; - } - eap_method_ca_cert_ignore_set (parent, connection, value, ca_cert_error); - g_free (value); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo")); - peapver_active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); - switch (peapver_active) { - case 1: /* PEAP v0 */ - g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_PEAPVER, "0", NULL); - break; - case 2: /* PEAP v1 */ - g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_PEAPVER, "1", NULL); - break; - default: /* Automatic */ - g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_PEAPVER, NULL, NULL); - break; - } - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo")); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - - eap_method_fill_connection (eap, connection); - eap_method_unref (eap); -} -static void -inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data) -{ - EAPMethod *parent = (EAPMethod *) user_data; - EAPMethodPEAP *method = (EAPMethodPEAP *) parent; - GtkWidget *vbox; - EAPMethod *eap = NULL; - GList *elt, *children; - GtkTreeModel *model; - GtkTreeIter iter; - GtkWidget *eap_widget; - - vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_vbox")); - g_assert (vbox); - - /* Remove any previous wireless security widgets */ - children = gtk_container_get_children (GTK_CONTAINER (vbox)); - for (elt = children; elt; elt = g_list_next (elt)) - gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data)); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - - eap_widget = eap_method_get_widget (eap); - g_assert (eap_widget); - gtk_widget_unparent (eap_widget); - - if (method->size_group) - eap_method_add_to_size_group (eap, method->size_group); - gtk_container_add (GTK_CONTAINER (vbox), eap_widget); - - eap_method_unref (eap); - - wireless_security_changed_cb (combo, method->sec_parent); -} - -static GtkWidget * -inner_auth_combo_init (EAPMethodPEAP *method, - NMConnection *connection, - NMSetting8021x *s_8021x, - gboolean secrets_only) -{ - EAPMethod *parent = (EAPMethod *) method; - GtkWidget *combo; - GtkListStore *auth_model; - GtkTreeIter iter; - EAPMethodSimple *em_mschap_v2; - EAPMethodSimple *em_md5; - EAPMethodSimple *em_gtc; - guint32 active = 0; - const char *phase2_auth = NULL; - EAPMethodSimpleFlags simple_flags; - - auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ()); - - if (s_8021x) { - if (nm_setting_802_1x_get_phase2_auth (s_8021x)) - phase2_auth = nm_setting_802_1x_get_phase2_auth (s_8021x); - else if (nm_setting_802_1x_get_phase2_autheap (s_8021x)) - phase2_auth = nm_setting_802_1x_get_phase2_autheap (s_8021x); - } - - simple_flags = EAP_METHOD_SIMPLE_FLAG_PHASE2; - if (method->is_editor) - simple_flags |= EAP_METHOD_SIMPLE_FLAG_IS_EDITOR; - if (secrets_only) - simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY; - - em_mschap_v2 = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("MSCHAPv2"), - I_METHOD_COLUMN, em_mschap_v2, - -1); - eap_method_unref (EAP_METHOD (em_mschap_v2)); - - /* Check for defaulting to MSCHAPv2 */ - if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2")) - active = 0; - - em_md5 = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_MD5, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("MD5"), - I_METHOD_COLUMN, em_md5, - -1); - eap_method_unref (EAP_METHOD (em_md5)); - - /* Check for defaulting to MD5 */ - if (phase2_auth && !strcasecmp (phase2_auth, "md5")) - active = 1; - - em_gtc = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_GTC, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("GTC"), - I_METHOD_COLUMN, em_gtc, - -1); - eap_method_unref (EAP_METHOD (em_gtc)); - - /* Check for defaulting to GTC */ - if (phase2_auth && !strcasecmp (phase2_auth, "gtc")) - active = 2; - - combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo")); - g_assert (combo); - - gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); - g_object_unref (G_OBJECT (auth_model)); - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active); - - g_signal_connect (G_OBJECT (combo), "changed", - (GCallback) inner_auth_combo_changed_cb, - method); - return combo; -} - -static void -update_secrets (EAPMethod *parent, NMConnection *connection) -{ - eap_method_phase2_update_secrets_helper (parent, - connection, - "eap_peap_inner_auth_combo", - I_METHOD_COLUMN); -} - -EAPMethodPEAP * -eap_method_peap_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean is_editor, - gboolean secrets_only) -{ - EAPMethod *parent; - EAPMethodPEAP *method; - GtkWidget *widget; - NMSetting8021x *s_8021x = NULL; - gboolean ca_not_required = FALSE; - - parent = eap_method_init (sizeof (EAPMethodPEAP), - validate, - add_to_size_group, - fill_connection, - update_secrets, - destroy, - "/org/freedesktop/network-manager-applet/eap-method-peap.ui", - "eap_peap_notebook", - "eap_peap_anon_identity_entry", - FALSE); - if (!parent) - return NULL; - - method = (EAPMethodPEAP *) parent; - method->password_flags_name = NM_SETTING_802_1X_PASSWORD; - method->sec_parent = ws_parent; - method->is_editor = is_editor; - - if (connection) - s_8021x = nm_connection_get_setting_802_1x (connection); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_grid")); - g_assert (widget); - - method->ca_cert_chooser = nma_cert_chooser_new ("CA", - NMA_CERT_CHOOSER_FLAG_CERT - | (secrets_only ? NMA_CERT_CHOOSER_FLAG_PASSWORDS : 0)); - gtk_grid_attach (GTK_GRID (widget), method->ca_cert_chooser, 0, 2, 2, 1); - gtk_widget_show (method->ca_cert_chooser); - - g_signal_connect (method->ca_cert_chooser, - "cert-validate", - G_CALLBACK (eap_method_ca_cert_validate_cb), - NULL); - g_signal_connect (method->ca_cert_chooser, - "changed", - G_CALLBACK (wireless_security_changed_cb), - ws_parent); - - eap_method_setup_cert_chooser (NMA_CERT_CHOOSER (method->ca_cert_chooser), s_8021x, - nm_setting_802_1x_get_ca_cert_scheme, - nm_setting_802_1x_get_ca_cert_path, - nm_setting_802_1x_get_ca_cert_uri, - nm_setting_802_1x_get_ca_cert_password, - NULL, - NULL, - NULL, - NULL); - - if (connection && eap_method_ca_cert_ignore_get (parent, connection)) { - gchar *ca_cert; - NMSetting8021xCKScheme scheme; - - ca_cert = nma_cert_chooser_get_cert (NMA_CERT_CHOOSER (method->ca_cert_chooser), &scheme); - if (ca_cert) - g_free (ca_cert); - else - ca_not_required = TRUE; - } - - if (secrets_only) - ca_not_required = TRUE; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_not_required_checkbox")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) ca_cert_not_required_toggled, - parent); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) wireless_security_changed_cb, - ws_parent); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), ca_not_required); - - widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only); - inner_auth_combo_changed_cb (widget, (gpointer) method); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo")); - g_assert (widget); - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); - if (s_8021x) { - const char *peapver; - - peapver = nm_setting_802_1x_get_phase1_peapver (s_8021x); - if (peapver) { - /* Index 0 is "Automatic" */ - if (!strcmp (peapver, "0")) - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1); - else if (!strcmp (peapver, "1")) - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2); - } - } - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_entry")); - if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x)) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x)); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_domain_entry")); - if (s_8021x && nm_setting_802_1x_get_domain_suffix_match (s_8021x)) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_domain_suffix_match (s_8021x)); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - if (secrets_only) { - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_entry")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_domain_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_domain_entry")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_not_required_checkbox")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo")); - gtk_widget_hide (widget); - } - - return method; -} - diff --git a/src/wireless-security/eap-method-peap.h b/src/wireless-security/eap-method-peap.h deleted file mode 100644 index 812d5b70..00000000 --- a/src/wireless-security/eap-method-peap.h +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * (C) Copyright 2007 - 2010 Red Hat, Inc. - */ - -#ifndef EAP_METHOD_PEAP_H -#define EAP_METHOD_PEAP_H - -#include "wireless-security.h" - -typedef struct _EAPMethodPEAP EAPMethodPEAP; - -EAPMethodPEAP *eap_method_peap_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean is_editor, - gboolean secrets_only); - -#endif /* EAP_METHOD_PEAP_H */ - diff --git a/src/wireless-security/eap-method-peap.ui b/src/wireless-security/eap-method-peap.ui deleted file mode 100644 index cdbdac8a..00000000 --- a/src/wireless-security/eap-method-peap.ui +++ /dev/null @@ -1,215 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkListStore" id="model8"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0"> </col> - </row> - </data> - </object> - <object class="GtkListStore" id="model9"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">Automatic</col> - </row> - <row> - <col id="0" translatable="yes">Version 0</col> - </row> - <row> - <col id="0" translatable="yes">Version 1</col> - </row> - </data> - </object> - <object class="GtkNotebook" id="eap_peap_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="eap_peap_grid"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="eap_peap_anon_identity_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Anony_mous identity</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_peap_anon_identity_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_peap_anon_identity_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="eap_peap_ca_cert_not_required_checkbox"> - <property name="label" translatable="yes">No CA certificate is _required</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_peap_version_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">PEAP _version</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_peap_version_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="eap_peap_version_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="model">model9</property> - <child> - <object class="GtkCellRendererText" id="renderer9"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_peap_inner_auth_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Inner authentication</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_peap_inner_auth_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="eap_peap_inner_auth_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="model">model8</property> - <child> - <object class="GtkCellRendererText" id="renderer8"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">5</property> - </packing> - </child> - <child> - <object class="GtkBox" id="eap_peap_inner_auth_vbox"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">6</property> - <property name="width">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_peap_domain_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="tooltip_text" translatable="yes">Suffix of the server certificate name.</property> - <property name="label" translatable="yes">_Domain</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_peap_domain_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_peap_domain_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="menu_label">eap_peap_grid</property> - </packing> - </child> - <child type="tab"> - <object class="GtkLabel" id="label61"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/eap-method-simple.c b/src/wireless-security/eap-method-simple.c deleted file mode 100644 index 20322868..00000000 --- a/src/wireless-security/eap-method-simple.c +++ /dev/null @@ -1,474 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "eap-method.h" -#include "wireless-security.h" -#include "helpers.h" -#include "nma-ui-utils.h" -#include "utils.h" - -struct _EAPMethodSimple { - EAPMethod parent; - - WirelessSecurity *ws_parent; - - const char *password_flags_name; - EAPMethodSimpleType type; - EAPMethodSimpleFlags flags; - - gboolean username_requested; - gboolean password_requested; - gboolean pkey_passphrase_requested; - GtkEntry *username_entry; - GtkEntry *password_entry; - GtkToggleButton *show_password; - GtkEntry *pkey_passphrase_entry; - GtkToggleButton *show_pkey_passphrase; - guint idle_func_id; -}; - -static void -show_password_toggled_cb (GtkToggleButton *button, EAPMethodSimple *method) -{ - gboolean visible; - - visible = gtk_toggle_button_get_active (button); - gtk_entry_set_visibility (method->password_entry, visible); -} - -static void -show_pkey_passphrase_toggled_cb (GtkToggleButton *button, EAPMethodSimple *method) -{ - gboolean visible; - - visible = gtk_toggle_button_get_active (button); - gtk_entry_set_visibility (method->pkey_passphrase_entry, visible); -} - -static gboolean -always_ask_selected (GtkEntry *passwd_entry) -{ - return !!( nma_utils_menu_to_secret_flags (GTK_WIDGET (passwd_entry)) - & NM_SETTING_SECRET_FLAG_NOT_SAVED); -} - -static gboolean -validate (EAPMethod *parent, GError **error) -{ - EAPMethodSimple *method = (EAPMethodSimple *)parent; - const char *text; - gboolean ret = TRUE; - - if (method->username_requested) { - text = gtk_entry_get_text (method->username_entry); - if (!text || !strlen (text)) { - widget_set_error (GTK_WIDGET (method->username_entry)); - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing EAP username")); - ret = FALSE; - } else - widget_unset_error (GTK_WIDGET (method->username_entry)); - } - - /* Check if the password should always be requested */ - if (method->password_requested) { - if (always_ask_selected (method->password_entry)) - widget_unset_error (GTK_WIDGET (method->password_entry)); - else { - text = gtk_entry_get_text (method->password_entry); - if (!text || !strlen (text)) { - widget_set_error (GTK_WIDGET (method->password_entry)); - if (ret) { - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, - _("missing EAP password")); - ret = FALSE; - } - } else - widget_unset_error (GTK_WIDGET (method->password_entry)); - } - } - - if (method->pkey_passphrase_requested) { - text = gtk_entry_get_text (method->pkey_passphrase_entry); - if (!text || !strlen (text)) { - widget_set_error (GTK_WIDGET (method->pkey_passphrase_entry)); - if (ret) { - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, - _("missing EAP client Private Key passphrase")); - ret = FALSE; - } - } else - widget_unset_error (GTK_WIDGET (method->pkey_passphrase_entry)); - } - - return ret; -} - -static void -add_to_size_group (EAPMethod *parent, GtkSizeGroup *group) -{ - EAPMethodSimple *method = (EAPMethodSimple *) parent; - GtkWidget *widget; - - if (method->username_requested) { - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_username_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - } - - if (method->password_requested) { - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - } - - if (method->pkey_passphrase_requested) { - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_pkey_passphrase_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - } -} - -typedef struct { - const char *name; - gboolean autheap_allowed; -} EapType; - -/* Indexed by EAP_METHOD_SIMPLE_TYPE_* */ -static const EapType eap_table[EAP_METHOD_SIMPLE_TYPE_LAST] = { - [EAP_METHOD_SIMPLE_TYPE_PAP] = { "pap", FALSE }, - [EAP_METHOD_SIMPLE_TYPE_MSCHAP] = { "mschap", FALSE }, - [EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2] = { "mschapv2", TRUE }, - [EAP_METHOD_SIMPLE_TYPE_PLAIN_MSCHAP_V2] = { "mschapv2", FALSE }, - [EAP_METHOD_SIMPLE_TYPE_MD5] = { "md5", TRUE }, - [EAP_METHOD_SIMPLE_TYPE_PWD] = { "pwd", TRUE }, - [EAP_METHOD_SIMPLE_TYPE_CHAP] = { "chap", FALSE }, - [EAP_METHOD_SIMPLE_TYPE_GTC] = { "gtc", TRUE }, - [EAP_METHOD_SIMPLE_TYPE_UNKNOWN] = { "unknown", TRUE }, -}; - -static void -fill_connection (EAPMethod *parent, NMConnection *connection) -{ - EAPMethodSimple *method = (EAPMethodSimple *) parent; - NMSetting8021x *s_8021x; - gboolean not_saved = FALSE; - NMSettingSecretFlags flags; - const EapType *eap_type; - - s_8021x = nm_connection_get_setting_802_1x (connection); - g_assert (s_8021x); - - if (!(method->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY)) { - /* If this is the main EAP method, clear any existing methods because the - * user-selected one will replace it. - */ - if (parent->phase2 == FALSE) - nm_setting_802_1x_clear_eap_methods (s_8021x); - - eap_type = &eap_table[method->type]; - if (parent->phase2) { - /* If the outer EAP method (TLS, TTLS, PEAP, etc) allows inner/phase2 - * EAP methods (which only TTLS allows) *and* the inner/phase2 method - * supports being an inner EAP method, then set PHASE2_AUTHEAP. - * Otherwise the inner/phase2 method goes into PHASE2_AUTH. - */ - if ((method->flags & EAP_METHOD_SIMPLE_FLAG_AUTHEAP_ALLOWED) && eap_type->autheap_allowed) { - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, eap_type->name, NULL); - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, NULL, NULL); - } else { - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, eap_type->name, NULL); - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, NULL, NULL); - } - } else - nm_setting_802_1x_add_eap_method (s_8021x, eap_type->name); - } - - if (method->username_requested) - g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (method->username_entry), NULL); - - if (method->password_requested) { - /* Save the password always ask setting */ - not_saved = always_ask_selected (method->password_entry); - flags = nma_utils_menu_to_secret_flags (GTK_WIDGET (method->password_entry)); - nm_setting_set_secret_flags (NM_SETTING (s_8021x), method->password_flags_name, flags, NULL); - - /* Fill the connection's password if we're in the applet so that it'll get - * back to NM. From the editor though, since the connection isn't going - * back to NM in response to a GetSecrets() call, we don't save it if the - * user checked "Always Ask". - */ - if (!(method->flags & EAP_METHOD_SIMPLE_FLAG_IS_EDITOR) || not_saved == FALSE) { - g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, - gtk_entry_get_text (method->password_entry), NULL); - } - - /* Update secret flags and popup when editing the connection */ - if (!(method->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY)) { - GtkWidget *passwd_entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, - "eap_simple_password_entry")); - g_assert (passwd_entry); - - nma_utils_update_password_storage (passwd_entry, flags, - NM_SETTING (s_8021x), method->password_flags_name); - } - } - - if (method->pkey_passphrase_requested) { - g_object_set (s_8021x, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD, - gtk_entry_get_text (method->pkey_passphrase_entry), NULL); - } -} - -static void -update_secrets (EAPMethod *parent, NMConnection *connection) -{ - helper_fill_secret_entry (connection, - parent->builder, - "eap_simple_password_entry", - NM_TYPE_SETTING_802_1X, - (HelperSecretFunc) nm_setting_802_1x_get_password); - helper_fill_secret_entry (connection, - parent->builder, - "eap_simple_pkey_passphrase_entry", - NM_TYPE_SETTING_802_1X, - (HelperSecretFunc) nm_setting_802_1x_get_private_key_password); -} - -static gboolean -stuff_changed (EAPMethodSimple *method) -{ - wireless_security_changed_cb (NULL, method->ws_parent); - method->idle_func_id = 0; - return FALSE; -} - -static void -password_storage_changed (GObject *entry, - GParamSpec *pspec, - EAPMethodSimple *method) -{ - gboolean always_ask; - gboolean secrets_only = method->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY; - - always_ask = always_ask_selected (method->password_entry); - - if (always_ask && !secrets_only) { - /* we always clear this button and do not restore it - * (because we want to hide the password). */ - gtk_toggle_button_set_active (method->show_password, FALSE); - } - - gtk_widget_set_sensitive (GTK_WIDGET (method->show_password), - !always_ask || secrets_only); - - if (!method->idle_func_id) - method->idle_func_id = g_idle_add ((GSourceFunc) stuff_changed, method); -} - -/* Set the UI fields for user, password, always_ask and show_password to the - * values as provided by method->ws_parent. */ -static void -set_userpass_ui (EAPMethodSimple *method) -{ - if (method->ws_parent->username) - gtk_entry_set_text (method->username_entry, method->ws_parent->username); - else - gtk_entry_set_text (method->username_entry, ""); - - if (method->ws_parent->password && !method->ws_parent->always_ask) - gtk_entry_set_text (method->password_entry, method->ws_parent->password); - else - gtk_entry_set_text (method->password_entry, ""); - - gtk_toggle_button_set_active (method->show_password, method->ws_parent->show_password); - password_storage_changed (NULL, NULL, method); -} - -static void -widgets_realized (GtkWidget *widget, EAPMethodSimple *method) -{ - set_userpass_ui (method); -} - -static void -widgets_unrealized (GtkWidget *widget, EAPMethodSimple *method) -{ - wireless_security_set_userpass (method->ws_parent, - gtk_entry_get_text (method->username_entry), - gtk_entry_get_text (method->password_entry), - always_ask_selected (method->password_entry), - gtk_toggle_button_get_active (method->show_password)); -} - -static void -destroy (EAPMethod *parent) -{ - EAPMethodSimple *method = (EAPMethodSimple *) parent; - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_notebook")); - g_assert (widget); - g_signal_handlers_disconnect_by_data (widget, method); - - g_signal_handlers_disconnect_by_data (method->username_entry, method->ws_parent); - g_signal_handlers_disconnect_by_data (method->password_entry, method->ws_parent); - g_signal_handlers_disconnect_by_data (method->password_entry, method); - g_signal_handlers_disconnect_by_data (method->show_password, method); - g_signal_handlers_disconnect_by_data (method->pkey_passphrase_entry, method->ws_parent); - g_signal_handlers_disconnect_by_data (method->show_pkey_passphrase, method); - - nm_clear_g_source (&method->idle_func_id); -} - -static void -hide_row (GtkWidget **widgets, size_t num) -{ - while (num--) - gtk_widget_hide (*widgets++); -} - -EAPMethodSimple * -eap_method_simple_new (WirelessSecurity *ws_parent, - NMConnection *connection, - EAPMethodSimpleType type, - EAPMethodSimpleFlags flags, - const char *const*hints) -{ - EAPMethod *parent; - EAPMethodSimple *method; - GtkWidget *widget; - NMSetting8021x *s_8021x = NULL; - GtkWidget *widget_row[10]; - - parent = eap_method_init (sizeof (EAPMethodSimple), - validate, - add_to_size_group, - fill_connection, - update_secrets, - destroy, - "/org/freedesktop/network-manager-applet/eap-method-simple.ui", - "eap_simple_notebook", - "eap_simple_username_entry", - flags & EAP_METHOD_SIMPLE_FLAG_PHASE2); - if (!parent) - return NULL; - - method = (EAPMethodSimple *) parent; - method->password_flags_name = NM_SETTING_802_1X_PASSWORD; - method->ws_parent = ws_parent; - method->flags = flags; - method->type = type; - g_assert (type < EAP_METHOD_SIMPLE_TYPE_LAST); - g_assert ( type != EAP_METHOD_SIMPLE_TYPE_UNKNOWN - || hints); - - if (hints) { - for (; *hints; hints++) { - if (!strcmp (*hints, NM_SETTING_802_1X_IDENTITY)) - method->username_requested = TRUE; - else if (!strcmp (*hints, NM_SETTING_802_1X_PASSWORD)) { - method->password_requested = TRUE; - method->password_flags_name = NM_SETTING_802_1X_PASSWORD; - } else if (!strcmp (*hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD)) - method->pkey_passphrase_requested = TRUE; - } - } else { - method->username_requested = TRUE; - method->password_requested = TRUE; - } - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_notebook")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "realize", - (GCallback) widgets_realized, - method); - g_signal_connect (G_OBJECT (widget), "unrealize", - (GCallback) widgets_unrealized, - method); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_username_entry")); - g_assert (widget); - method->username_entry = GTK_ENTRY (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - if ( (method->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY) - && !method->username_requested) - gtk_widget_set_sensitive (widget, FALSE); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_entry")); - g_assert (widget); - method->password_entry = GTK_ENTRY (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - /* Create password-storage popup menu for password entry under entry's secondary icon */ - if (connection) - s_8021x = nm_connection_get_setting_802_1x (connection); - nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, method->password_flags_name, - FALSE, flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY); - - g_signal_connect (method->password_entry, "notify::secondary-icon-name", - G_CALLBACK (password_storage_changed), - method); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapsimple")); - g_assert (widget); - method->show_password = GTK_TOGGLE_BUTTON (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) show_password_toggled_cb, - method); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_pkey_passphrase_entry")); - g_assert (widget); - method->pkey_passphrase_entry = GTK_ENTRY (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_show_pkey_passphrase_checkbutton")); - g_assert (widget); - method->show_pkey_passphrase = GTK_TOGGLE_BUTTON (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) show_pkey_passphrase_toggled_cb, - method); - - widget_row[0] = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_username_label")); - widget_row[1] = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_username_entry")); - if (!method->username_requested) - hide_row (widget_row, 2); - - widget_row[0] = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_label")); - widget_row[1] = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_entry")); - widget_row[2] = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapsimple")); - if (!method->password_requested) - hide_row (widget_row, 3); - - widget_row[0] = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_pkey_passphrase_label")); - widget_row[1] = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_pkey_passphrase_entry")); - widget_row[2] = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_show_pkey_passphrase_checkbutton")); - if (!method->pkey_passphrase_requested) - hide_row (widget_row, 3); - - /* Initialize the UI fields with the security settings from method->ws_parent. - * This will be done again when the widget gets realized. It must be done here as well, - * because the outer dialog will ask to 'validate' the connection before the security tab - * is shown/realized (to enable the 'Apply' button). - * As 'validate' accesses the contents of the UI fields, they must be initialized now, even - * if the widgets are not yet visible. */ - set_userpass_ui (method); - - return method; -} diff --git a/src/wireless-security/eap-method-simple.h b/src/wireless-security/eap-method-simple.h deleted file mode 100644 index 2c93ab9a..00000000 --- a/src/wireless-security/eap-method-simple.h +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * (C) Copyright 2007 - 2010 Red Hat, Inc. - */ - -#ifndef EAP_METHOD_SIMPLE_H -#define EAP_METHOD_SIMPLE_H - -#include "wireless-security.h" - -typedef enum { - /* NOTE: when updating this table, also update eap_methods[] */ - EAP_METHOD_SIMPLE_TYPE_PAP = 0, - EAP_METHOD_SIMPLE_TYPE_MSCHAP, - EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2, - EAP_METHOD_SIMPLE_TYPE_PLAIN_MSCHAP_V2, - EAP_METHOD_SIMPLE_TYPE_MD5, - EAP_METHOD_SIMPLE_TYPE_PWD, - EAP_METHOD_SIMPLE_TYPE_CHAP, - EAP_METHOD_SIMPLE_TYPE_GTC, - EAP_METHOD_SIMPLE_TYPE_UNKNOWN, - - /* Boundary value, do not use */ - EAP_METHOD_SIMPLE_TYPE_LAST -} EAPMethodSimpleType; - -typedef enum { - EAP_METHOD_SIMPLE_FLAG_NONE = 0x00, - /* Indicates the EAP method is an inner/phase2 method */ - EAP_METHOD_SIMPLE_FLAG_PHASE2 = 0x01, - /* Set by TTLS to indicate that inner/phase2 EAP is allowed */ - EAP_METHOD_SIMPLE_FLAG_AUTHEAP_ALLOWED = 0x02, - /* Set from nm-connection-editor or the GNOME network panel */ - EAP_METHOD_SIMPLE_FLAG_IS_EDITOR = 0x04, - /* Set to indicate that this request is only for secrets */ - EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY = 0x08 -} EAPMethodSimpleFlags; - -typedef struct _EAPMethodSimple EAPMethodSimple; - -EAPMethodSimple *eap_method_simple_new (WirelessSecurity *ws_parent, - NMConnection *connection, - EAPMethodSimpleType type, - EAPMethodSimpleFlags flags, - const char *const*hints); - -#endif /* EAP_METHOD_SIMPLE_H */ - diff --git a/src/wireless-security/eap-method-simple.ui b/src/wireless-security/eap-method-simple.ui deleted file mode 100644 index c0206eb2..00000000 --- a/src/wireless-security/eap-method-simple.ui +++ /dev/null @@ -1,158 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkNotebook" id="eap_simple_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="table11"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="valign">start</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="eap_simple_username_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Username</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_simple_username_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_simple_password_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Password</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_simple_password_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_simple_password_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="visibility">False</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_simple_username_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkBox" id="vbox5"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkCheckButton" id="show_checkbutton_eapsimple"> - <property name="label" translatable="yes">Sho_w password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_simple_pkey_passphrase_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">P_rivate Key Passphrase</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_simple_pkey_passphrase_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_simple_pkey_passphrase_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="visibility">False</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="eap_simple_show_pkey_passphrase_checkbutton"> - <property name="label" translatable="yes">Sh_ow passphrase</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="label53"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/eap-method-tls.c b/src/wireless-security/eap-method-tls.c deleted file mode 100644 index bd8b57a8..00000000 --- a/src/wireless-security/eap-method-tls.c +++ /dev/null @@ -1,497 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * Lubomir Rintel <lkundrak@v3.sk> - * - * Copyright 2007 - 2017 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "eap-method.h" -#include "wireless-security.h" -#include "helpers.h" -#include "nma-ui-utils.h" -#include "nma-cert-chooser.h" -#include "utils.h" - -struct _EAPMethodTLS { - EAPMethod parent; - - const char *ca_cert_password_flags_name; - const char *client_cert_password_flags_name; - const char *client_key_password_flags_name; - - gboolean editing_connection; - GtkWidget *ca_cert_chooser; - GtkWidget *client_cert_chooser; -}; - - -static gboolean -validate (EAPMethod *parent, GError **error) -{ - EAPMethodTLS *method = (EAPMethodTLS *) parent; - GtkWidget *widget; - const char *identity; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry")); - g_assert (widget); - identity = gtk_entry_get_text (GTK_ENTRY (widget)); - if (!identity || !strlen (identity)) { - widget_set_error (widget); - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing EAP-TLS identity")); - return FALSE; - } else { - widget_unset_error (widget); - } - - if ( gtk_widget_get_sensitive (method->ca_cert_chooser) - && !nma_cert_chooser_validate (NMA_CERT_CHOOSER (method->ca_cert_chooser), error)) - return FALSE; - - if (!nma_cert_chooser_validate (NMA_CERT_CHOOSER (method->client_cert_chooser), error)) - return FALSE; - - return TRUE; -} - -static void -ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data) -{ - EAPMethodTLS *method = (EAPMethodTLS *) user_data; - - gtk_widget_set_sensitive (method->ca_cert_chooser, - !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))); -} - -static void -add_to_size_group (EAPMethod *parent, GtkSizeGroup *group) -{ - EAPMethodTLS *method = (EAPMethodTLS *) parent; - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_domain_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - nma_cert_chooser_add_to_size_group (NMA_CERT_CHOOSER (method->client_cert_chooser), group); - nma_cert_chooser_add_to_size_group (NMA_CERT_CHOOSER (method->ca_cert_chooser), group); -} - -static void -fill_connection (EAPMethod *parent, NMConnection *connection) -{ - EAPMethodTLS *method = (EAPMethodTLS *) parent; - NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - NMSetting8021x *s_8021x; - NMSettingSecretFlags secret_flags; - GtkWidget *widget; - char *value = NULL; - const char *password = NULL; - GError *error = NULL; - gboolean ca_cert_error = FALSE; - NMSetting8021xCKScheme scheme; - - s_8021x = nm_connection_get_setting_802_1x (connection); - g_assert (s_8021x); - - if (parent->phase2) - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, "tls", NULL); - else - nm_setting_802_1x_add_eap_method (s_8021x, "tls"); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry")); - g_assert (widget); - g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (GTK_ENTRY (widget)), NULL); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_domain_entry")); - g_assert (widget); - g_object_set (s_8021x, - parent->phase2 ? NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH : NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, - gtk_entry_get_text (GTK_ENTRY (widget)), NULL); - - /* TLS private key */ - password = nma_cert_chooser_get_key_password (NMA_CERT_CHOOSER (method->client_cert_chooser)); - value = nma_cert_chooser_get_key (NMA_CERT_CHOOSER (method->client_cert_chooser), &scheme); - - if (parent->phase2) { - if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, value, password, scheme, &format, &error)) { - g_warning ("Couldn't read phase2 private key '%s': %s", value, error ? error->message : "(unknown)"); - g_clear_error (&error); - } - } else { - if (!nm_setting_802_1x_set_private_key (s_8021x, value, password, scheme, &format, &error)) { - g_warning ("Couldn't read private key '%s': %s", value, error ? error->message : "(unknown)"); - g_clear_error (&error); - } - } - g_free (value); - - /* Save CA certificate PIN and its flags to the connection */ - secret_flags = nma_cert_chooser_get_cert_password_flags (NMA_CERT_CHOOSER (method->ca_cert_chooser)); - nm_setting_set_secret_flags (NM_SETTING (s_8021x), method->ca_cert_password_flags_name, - secret_flags, NULL); - if (method->editing_connection) { - /* Update secret flags and popup when editing the connection */ - nma_cert_chooser_update_cert_password_storage (NMA_CERT_CHOOSER (method->ca_cert_chooser), - secret_flags, NM_SETTING (s_8021x), - method->ca_cert_password_flags_name); - g_object_set (s_8021x, method->ca_cert_password_flags_name, - nma_cert_chooser_get_cert_password (NMA_CERT_CHOOSER (method->ca_cert_chooser)), - NULL); - } - - /* Save user certificate PIN and its flags flags to the connection */ - secret_flags = nma_cert_chooser_get_cert_password_flags (NMA_CERT_CHOOSER (method->client_cert_chooser)); - nm_setting_set_secret_flags (NM_SETTING (s_8021x), method->client_cert_password_flags_name, - secret_flags, NULL); - if (method->editing_connection) { - nma_cert_chooser_update_cert_password_storage (NMA_CERT_CHOOSER (method->client_cert_chooser), - secret_flags, NM_SETTING (s_8021x), - method->client_cert_password_flags_name); - g_object_set (s_8021x, method->client_cert_password_flags_name, - nma_cert_chooser_get_cert_password (NMA_CERT_CHOOSER (method->client_cert_chooser)), - NULL); - } - - /* Save user private key password flags to the connection */ - secret_flags = nma_cert_chooser_get_key_password_flags (NMA_CERT_CHOOSER (method->client_cert_chooser)); - nm_setting_set_secret_flags (NM_SETTING (s_8021x), method->client_key_password_flags_name, - secret_flags, NULL); - if (method->editing_connection) { - nma_cert_chooser_update_key_password_storage (NMA_CERT_CHOOSER (method->client_cert_chooser), - secret_flags, NM_SETTING (s_8021x), - method->client_key_password_flags_name); - } - - /* TLS client certificate */ - if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) { - /* If the key is pkcs#12 nm_setting_802_1x_set_private_key() already - * set the client certificate for us. - */ - value = nma_cert_chooser_get_cert (NMA_CERT_CHOOSER (method->client_cert_chooser), &scheme); - format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - if (parent->phase2) { - if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, value, scheme, &format, &error)) { - g_warning ("Couldn't read phase2 client certificate '%s': %s", value, error ? error->message : "(unknown)"); - g_clear_error (&error); - } - } else { - if (!nm_setting_802_1x_set_client_cert (s_8021x, value, scheme, &format, &error)) { - g_warning ("Couldn't read client certificate '%s': %s", value, error ? error->message : "(unknown)"); - g_clear_error (&error); - } - } - g_free (value); - } - - /* TLS CA certificate */ - if (gtk_widget_get_sensitive (method->ca_cert_chooser)) - value = nma_cert_chooser_get_cert (NMA_CERT_CHOOSER (method->ca_cert_chooser), &scheme); - else - value = NULL; - format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - if (parent->phase2) { - if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, value, scheme, &format, &error)) { - g_warning ("Couldn't read phase2 CA certificate '%s': %s", value, error ? error->message : "(unknown)"); - g_clear_error (&error); - ca_cert_error = TRUE; - } - } else { - if (!nm_setting_802_1x_set_ca_cert (s_8021x, value, scheme, &format, &error)) { - g_warning ("Couldn't read CA certificate '%s': %s", value, error ? error->message : "(unknown)"); - g_clear_error (&error); - ca_cert_error = TRUE; - } - } - eap_method_ca_cert_ignore_set (parent, connection, value, ca_cert_error); - g_free (value); -} - -static GError * -client_cert_validate_cb (NMACertChooser *cert_chooser, gpointer user_data) -{ - NMSetting8021xCKScheme scheme; - NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - gs_unref_object NMSetting8021x *setting = NULL; - gs_free char *value = NULL; - GError *local = NULL; - - setting = (NMSetting8021x *) nm_setting_802_1x_new (); - - value = nma_cert_chooser_get_cert (cert_chooser, &scheme); - if (!value) { - return g_error_new_literal (NMA_ERROR, NMA_ERROR_GENERIC, - _("no user certificate selected")); - } - if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) { - if (!g_file_test (value, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - return g_error_new_literal (NMA_ERROR, NMA_ERROR_GENERIC, - _("selected user certificate file does not exist")); - } - } - - if (!nm_setting_802_1x_set_client_cert (setting, value, scheme, &format, &local)) - return local; - - return NULL; -} - -static GError * -client_key_validate_cb (NMACertChooser *cert_chooser, gpointer user_data) -{ - NMSetting8021xCKScheme scheme; - gs_free char *value = NULL; - - - value = nma_cert_chooser_get_key (cert_chooser, &scheme); - if (!value) { - return g_error_new_literal (NMA_ERROR, NMA_ERROR_GENERIC, - _("no key selected")); - } - if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) { - if (!g_file_test (value, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - return g_error_new_literal (NMA_ERROR, NMA_ERROR_GENERIC, - _("selected key file does not exist")); - } - } - - return NULL; -} - -static GError * -client_key_password_validate_cb (NMACertChooser *cert_chooser, gpointer user_data) -{ - NMSetting8021xCKScheme scheme; - NMSettingSecretFlags secret_flags; - gs_unref_object NMSetting8021x *setting = NULL; - gs_free char *value = NULL; - const char *password = NULL; - GError *local = NULL; - - secret_flags = nma_cert_chooser_get_key_password_flags (cert_chooser); - if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED - || secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) - return NULL; - - setting = (NMSetting8021x *) nm_setting_802_1x_new (); - - value = nma_cert_chooser_get_key (cert_chooser, &scheme); - password = nma_cert_chooser_get_key_password (cert_chooser); - if (!nm_setting_802_1x_set_private_key (setting, value, password, scheme, NULL, &local)) - return local; - - return NULL; -} - -static void -client_cert_fixup_pkcs12 (NMACertChooser *cert_chooser, gpointer user_data) -{ - NMSetting8021xCKScheme cert_scheme, key_scheme; - NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - gs_free char *cert_value = NULL; - gs_free char *key_value = NULL; - gs_unref_object NMSetting8021x *setting = NULL; - - setting = (NMSetting8021x *) nm_setting_802_1x_new (); - - cert_value = nma_cert_chooser_get_cert (cert_chooser, &cert_scheme); - key_value = nma_cert_chooser_get_key (cert_chooser, &key_scheme); - - if ( !cert_value || key_value - || !nm_setting_802_1x_set_client_cert (setting, cert_value, cert_scheme, &format, NULL)) - return; - - if (format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) - nma_cert_chooser_set_key (cert_chooser, cert_value, cert_scheme); -} - -static void -update_secrets (EAPMethod *parent, NMConnection *connection) -{ - EAPMethodTLS *method = (EAPMethodTLS *) parent; - - eap_method_setup_cert_chooser (NMA_CERT_CHOOSER (method->client_cert_chooser), - nm_connection_get_setting_802_1x (connection), - NULL, - NULL, - NULL, - parent->phase2 ? nm_setting_802_1x_get_phase2_client_cert_password : nm_setting_802_1x_get_client_cert_password, - parent->phase2 ? nm_setting_802_1x_get_phase2_private_key_scheme : nm_setting_802_1x_get_private_key_scheme, - parent->phase2 ? nm_setting_802_1x_get_phase2_private_key_path : nm_setting_802_1x_get_private_key_path, - parent->phase2 ? nm_setting_802_1x_get_phase2_private_key_uri : nm_setting_802_1x_get_private_key_uri, - parent->phase2 ? nm_setting_802_1x_get_phase2_private_key_password : nm_setting_802_1x_get_private_key_password); -} - -EAPMethodTLS * -eap_method_tls_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean phase2, - gboolean secrets_only) -{ - EAPMethodTLS *method; - EAPMethod *parent; - GtkWidget *widget; - NMSetting8021x *s_8021x = NULL; - gboolean ca_not_required = FALSE; - - parent = eap_method_init (sizeof (EAPMethodTLS), - validate, - add_to_size_group, - fill_connection, - update_secrets, - NULL, - "/org/freedesktop/network-manager-applet/eap-method-tls.ui", - "eap_tls_notebook", - "eap_tls_identity_entry", - phase2); - if (!parent) - return NULL; - - method = (EAPMethodTLS *) parent; - method->ca_cert_password_flags_name = phase2 - ? NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD - : NM_SETTING_802_1X_CA_CERT_PASSWORD; - method->client_cert_password_flags_name = phase2 - ? NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD - : NM_SETTING_802_1X_CLIENT_CERT_PASSWORD; - method->client_key_password_flags_name = phase2 - ? NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD - : NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD; - method->editing_connection = secrets_only ? FALSE : TRUE; - - if (connection) - s_8021x = nm_connection_get_setting_802_1x (connection); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_not_required_checkbox")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) ca_cert_not_required_toggled, - parent); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) wireless_security_changed_cb, - ws_parent); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - if (s_8021x && nm_setting_802_1x_get_identity (s_8021x)) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_identity (s_8021x)); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_domain_entry")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - if (phase2) { - if (s_8021x && nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x)) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x)); - } else { - if (s_8021x && nm_setting_802_1x_get_domain_suffix_match (s_8021x)) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_domain_suffix_match (s_8021x)); - } - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_grid")); - g_assert (widget); - - method->ca_cert_chooser = nma_cert_chooser_new ("CA", - NMA_CERT_CHOOSER_FLAG_CERT - | (secrets_only ? NMA_CERT_CHOOSER_FLAG_PASSWORDS : 0)); - gtk_grid_attach (GTK_GRID (widget), method->ca_cert_chooser, 0, 2, 2, 1); - gtk_widget_show (method->ca_cert_chooser); - - g_signal_connect (method->ca_cert_chooser, - "cert-validate", - G_CALLBACK (eap_method_ca_cert_validate_cb), - NULL); - g_signal_connect (method->ca_cert_chooser, - "changed", - G_CALLBACK (wireless_security_changed_cb), - ws_parent); - - eap_method_setup_cert_chooser (NMA_CERT_CHOOSER (method->ca_cert_chooser), s_8021x, - phase2 ? nm_setting_802_1x_get_phase2_ca_cert_scheme : nm_setting_802_1x_get_ca_cert_scheme, - phase2 ? nm_setting_802_1x_get_phase2_ca_cert_path : nm_setting_802_1x_get_ca_cert_path, - phase2 ? nm_setting_802_1x_get_phase2_ca_cert_uri : nm_setting_802_1x_get_ca_cert_uri, - phase2 ? nm_setting_802_1x_get_phase2_ca_cert_password : nm_setting_802_1x_get_ca_cert_password, - NULL, - NULL, - NULL, - NULL); - - if (connection && eap_method_ca_cert_ignore_get (parent, connection)) { - gchar *ca_cert; - NMSetting8021xCKScheme scheme; - - ca_cert = nma_cert_chooser_get_cert (NMA_CERT_CHOOSER (method->ca_cert_chooser), &scheme); - if (ca_cert) - g_free (ca_cert); - else - ca_not_required = TRUE; - } - - if (secrets_only) - ca_not_required = TRUE; - - method->client_cert_chooser = nma_cert_chooser_new ("User", - secrets_only ? NMA_CERT_CHOOSER_FLAG_PASSWORDS : 0); - gtk_grid_attach (GTK_GRID (widget), method->client_cert_chooser, 0, 4, 2, 1); - gtk_widget_show (method->client_cert_chooser); - - g_signal_connect (method->client_cert_chooser, "cert-validate", - G_CALLBACK (client_cert_validate_cb), - NULL); - g_signal_connect (method->client_cert_chooser, - "key-validate", - G_CALLBACK (client_key_validate_cb), - NULL); - g_signal_connect (method->client_cert_chooser, - "key-password-validate", - G_CALLBACK (client_key_password_validate_cb), - NULL); - g_signal_connect (method->client_cert_chooser, - "changed", - G_CALLBACK (client_cert_fixup_pkcs12), - ws_parent); - g_signal_connect (method->client_cert_chooser, - "changed", - G_CALLBACK (wireless_security_changed_cb), - ws_parent); - - eap_method_setup_cert_chooser (NMA_CERT_CHOOSER (method->client_cert_chooser), s_8021x, - phase2 ? nm_setting_802_1x_get_phase2_client_cert_scheme : nm_setting_802_1x_get_client_cert_scheme, - phase2 ? nm_setting_802_1x_get_phase2_client_cert_path : nm_setting_802_1x_get_client_cert_path, - phase2 ? nm_setting_802_1x_get_phase2_client_cert_uri : nm_setting_802_1x_get_client_cert_uri, - phase2 ? nm_setting_802_1x_get_phase2_client_cert_password : nm_setting_802_1x_get_client_cert_password, - phase2 ? nm_setting_802_1x_get_phase2_private_key_scheme : nm_setting_802_1x_get_private_key_scheme, - phase2 ? nm_setting_802_1x_get_phase2_private_key_path : nm_setting_802_1x_get_private_key_path, - phase2 ? nm_setting_802_1x_get_phase2_private_key_uri : nm_setting_802_1x_get_private_key_uri, - phase2 ? nm_setting_802_1x_get_phase2_private_key_password : nm_setting_802_1x_get_private_key_password); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_not_required_checkbox")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), ca_not_required); - - /* Create password-storage popup menus for password entries under their secondary icon */ - nma_cert_chooser_setup_cert_password_storage (NMA_CERT_CHOOSER (method->ca_cert_chooser), - 0, (NMSetting *) s_8021x, method->ca_cert_password_flags_name, - FALSE, secrets_only); - nma_cert_chooser_setup_cert_password_storage (NMA_CERT_CHOOSER (method->client_cert_chooser), - 0, (NMSetting *) s_8021x, method->client_cert_password_flags_name, - FALSE, secrets_only); - nma_cert_chooser_setup_key_password_storage (NMA_CERT_CHOOSER (method->client_cert_chooser), - 0, (NMSetting *) s_8021x, method->client_key_password_flags_name, - FALSE, secrets_only); - - return method; -} diff --git a/src/wireless-security/eap-method-tls.h b/src/wireless-security/eap-method-tls.h deleted file mode 100644 index 03d3a1fa..00000000 --- a/src/wireless-security/eap-method-tls.h +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * (C) Copyright 2007 - 2010 Red Hat, Inc. - */ - -#ifndef EAP_METHOD_TLS_H -#define EAP_METHOD_TLS_H - -#include "wireless-security.h" - -typedef struct _EAPMethodTLS EAPMethodTLS; - -EAPMethodTLS *eap_method_tls_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean phase2, - gboolean secrets_only); - -#endif /* EAP_METHOD_TLS_H */ - diff --git a/src/wireless-security/eap-method-tls.ui b/src/wireless-security/eap-method-tls.ui deleted file mode 100644 index acca95cd..00000000 --- a/src/wireless-security/eap-method-tls.ui +++ /dev/null @@ -1,106 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkNotebook" id="eap_tls_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="eap_tls_grid"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="eap_tls_identity_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">I_dentity</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_tls_identity_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_tls_identity_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="eap_tls_ca_cert_not_required_checkbox"> - <property name="label" translatable="yes">No CA certificate is _required</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="halign">start</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_tls_domain_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="tooltip_text" translatable="yes">Suffix of the server certificate name.</property> - <property name="label" translatable="yes">_Domain</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_tls_domain_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_tls_domain_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="label34"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/eap-method-ttls.c b/src/wireless-security/eap-method-ttls.c deleted file mode 100644 index 1cad3a53..00000000 --- a/src/wireless-security/eap-method-ttls.c +++ /dev/null @@ -1,521 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2017 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "eap-method.h" -#include "wireless-security.h" -#include "nma-cert-chooser.h" -#include "utils.h" - -#define I_NAME_COLUMN 0 -#define I_METHOD_COLUMN 1 - -struct _EAPMethodTTLS { - EAPMethod parent; - - const char *password_flags_name; - GtkSizeGroup *size_group; - WirelessSecurity *sec_parent; - gboolean is_editor; - - GtkWidget *ca_cert_chooser; -}; - -static void -destroy (EAPMethod *parent) -{ - EAPMethodTTLS *method = (EAPMethodTTLS *) parent; - - if (method->size_group) - g_object_unref (method->size_group); -} - -static gboolean -validate (EAPMethod *parent, GError **error) -{ - EAPMethodTTLS *method = (EAPMethodTTLS *) parent; - GtkWidget *widget; - GtkTreeModel *model; - GtkTreeIter iter; - EAPMethod *eap = NULL; - gboolean valid = FALSE; - - if ( gtk_widget_get_sensitive (method->ca_cert_chooser) - && !nma_cert_chooser_validate (NMA_CERT_CHOOSER (method->ca_cert_chooser), error)) - return FALSE; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_combo")); - g_assert (widget); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - valid = eap_method_validate (eap, error); - eap_method_unref (eap); - return valid; -} - -static void -ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data) -{ - EAPMethodTTLS *method = (EAPMethodTTLS *) user_data; - - gtk_widget_set_sensitive (method->ca_cert_chooser, - !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))); -} - -static void -add_to_size_group (EAPMethod *parent, GtkSizeGroup *group) -{ - EAPMethodTTLS *method = (EAPMethodTTLS *) parent; - GtkWidget *widget; - GtkTreeModel *model; - GtkTreeIter iter; - EAPMethod *eap; - - if (method->size_group) - g_object_unref (method->size_group); - method->size_group = g_object_ref (group); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_anon_identity_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_domain_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - nma_cert_chooser_add_to_size_group (NMA_CERT_CHOOSER (method->ca_cert_chooser), group); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_label")); - g_assert (widget); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_combo")); - g_assert (widget); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - eap_method_add_to_size_group (eap, group); - eap_method_unref (eap); -} - -static void -fill_connection (EAPMethod *parent, NMConnection *connection) -{ - EAPMethodTTLS *method = (EAPMethodTTLS *) parent; - NMSetting8021x *s_8021x; - NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - NMSettingSecretFlags secret_flags; - GtkWidget *widget; - const char *text; - char *value = NULL; - EAPMethod *eap = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - GError *error = NULL; - NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_UNKNOWN; - gboolean ca_cert_error = FALSE; - - s_8021x = nm_connection_get_setting_802_1x (connection); - g_assert (s_8021x); - - nm_setting_802_1x_add_eap_method (s_8021x, "ttls"); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_anon_identity_entry")); - g_assert (widget); - text = gtk_entry_get_text (GTK_ENTRY (widget)); - if (text && strlen (text)) - g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, text, NULL); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_domain_entry")); - g_assert (widget); - text = gtk_entry_get_text (GTK_ENTRY (widget)); - if (text && strlen (text)) - g_object_set (s_8021x, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, text, NULL); - - /* Save CA certificate PIN and its flags to the connection */ - secret_flags = nma_cert_chooser_get_cert_password_flags (NMA_CERT_CHOOSER (method->ca_cert_chooser)); - nm_setting_set_secret_flags (NM_SETTING (s_8021x), NM_SETTING_802_1X_CA_CERT_PASSWORD, - secret_flags, NULL); - if (method->is_editor) { - /* Update secret flags and popup when editing the connection */ - nma_cert_chooser_update_cert_password_storage (NMA_CERT_CHOOSER (method->ca_cert_chooser), - secret_flags, NM_SETTING (s_8021x), - NM_SETTING_802_1X_CA_CERT_PASSWORD); - g_object_set (s_8021x, NM_SETTING_802_1X_CA_CERT_PASSWORD, - nma_cert_chooser_get_cert_password (NMA_CERT_CHOOSER (method->ca_cert_chooser)), - NULL); - } - - /* TLS CA certificate */ - if (gtk_widget_get_sensitive (method->ca_cert_chooser)) - value = nma_cert_chooser_get_cert (NMA_CERT_CHOOSER (method->ca_cert_chooser), &scheme); - format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - if (!nm_setting_802_1x_set_ca_cert (s_8021x, value, scheme, &format, &error)) { - g_warning ("Couldn't read CA certificate '%s': %s", value, error ? error->message : "(unknown)"); - g_clear_error (&error); - ca_cert_error = TRUE; - } - eap_method_ca_cert_ignore_set (parent, connection, value, ca_cert_error); - g_free (value); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_combo")); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - - eap_method_fill_connection (eap, connection); - eap_method_unref (eap); -} - -static void -inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data) -{ - EAPMethod *parent = (EAPMethod *) user_data; - EAPMethodTTLS *method = (EAPMethodTTLS *) parent; - GtkWidget *vbox; - EAPMethod *eap = NULL; - GList *elt, *children; - GtkTreeModel *model; - GtkTreeIter iter; - GtkWidget *eap_widget; - - vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_vbox")); - g_assert (vbox); - - /* Remove any previous wireless security widgets */ - children = gtk_container_get_children (GTK_CONTAINER (vbox)); - for (elt = children; elt; elt = g_list_next (elt)) - gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data)); - g_list_free (children); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter); - gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); - g_assert (eap); - - eap_widget = eap_method_get_widget (eap); - g_assert (eap_widget); - gtk_widget_unparent (eap_widget); - - if (method->size_group) - eap_method_add_to_size_group (eap, method->size_group); - gtk_container_add (GTK_CONTAINER (vbox), eap_widget); - - eap_method_unref (eap); - - wireless_security_changed_cb (combo, method->sec_parent); -} - -static GtkWidget * -inner_auth_combo_init (EAPMethodTTLS *method, - NMConnection *connection, - NMSetting8021x *s_8021x, - gboolean secrets_only) -{ - EAPMethod *parent = (EAPMethod *) method; - GtkWidget *combo; - GtkListStore *auth_model; - GtkTreeIter iter; - EAPMethodSimple *em_pap; - EAPMethodSimple *em_mschap; - EAPMethodSimple *em_mschap_v2; - EAPMethodSimple *em_plain_mschap_v2; - EAPMethodSimple *em_chap; - EAPMethodSimple *em_md5; - EAPMethodSimple *em_gtc; - guint32 active = 0; - const char *phase2_auth = NULL; - EAPMethodSimpleFlags simple_flags; - - auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ()); - - if (s_8021x) { - if (nm_setting_802_1x_get_phase2_auth (s_8021x)) - phase2_auth = nm_setting_802_1x_get_phase2_auth (s_8021x); - else if (nm_setting_802_1x_get_phase2_autheap (s_8021x)) - phase2_auth = nm_setting_802_1x_get_phase2_autheap (s_8021x); - } - - simple_flags = EAP_METHOD_SIMPLE_FLAG_PHASE2 | EAP_METHOD_SIMPLE_FLAG_AUTHEAP_ALLOWED; - if (method->is_editor) - simple_flags |= EAP_METHOD_SIMPLE_FLAG_IS_EDITOR; - if (secrets_only) - simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY; - - em_pap = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_PAP, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("PAP"), - I_METHOD_COLUMN, em_pap, - -1); - eap_method_unref (EAP_METHOD (em_pap)); - - /* Check for defaulting to PAP */ - if (phase2_auth && !strcasecmp (phase2_auth, "pap")) - active = 0; - - em_mschap = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_MSCHAP, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("MSCHAP"), - I_METHOD_COLUMN, em_mschap, - -1); - eap_method_unref (EAP_METHOD (em_mschap)); - - /* Check for defaulting to MSCHAP */ - if (phase2_auth && !strcasecmp (phase2_auth, "mschap")) - active = 1; - - em_mschap_v2 = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("MSCHAPv2"), - I_METHOD_COLUMN, em_mschap_v2, - -1); - eap_method_unref (EAP_METHOD (em_mschap_v2)); - - /* Check for defaulting to MSCHAPv2 */ - if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2") && - nm_setting_802_1x_get_phase2_autheap (s_8021x) != NULL) - active = 2; - - em_plain_mschap_v2 = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_PLAIN_MSCHAP_V2, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("MSCHAPv2 (no EAP)"), - I_METHOD_COLUMN, em_plain_mschap_v2, - -1); - eap_method_unref (EAP_METHOD (em_plain_mschap_v2)); - - /* Check for defaulting to plain MSCHAPv2 */ - if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2") && - nm_setting_802_1x_get_phase2_auth (s_8021x) != NULL) - active = 3; - - em_chap = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_CHAP, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("CHAP"), - I_METHOD_COLUMN, em_chap, - -1); - eap_method_unref (EAP_METHOD (em_chap)); - - /* Check for defaulting to CHAP */ - if (phase2_auth && !strcasecmp (phase2_auth, "chap")) - active = 4; - - em_md5 = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_MD5, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("MD5"), - I_METHOD_COLUMN, em_md5, - -1); - eap_method_unref (EAP_METHOD (em_md5)); - - /* Check for defaulting to MD5 */ - if (phase2_auth && !strcasecmp (phase2_auth, "md5")) - active = 5; - - em_gtc = eap_method_simple_new (method->sec_parent, - connection, - EAP_METHOD_SIMPLE_TYPE_GTC, - simple_flags, - NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - I_NAME_COLUMN, _("GTC"), - I_METHOD_COLUMN, em_gtc, - -1); - eap_method_unref (EAP_METHOD (em_gtc)); - - /* Check for defaulting to GTC */ - if (phase2_auth && !strcasecmp (phase2_auth, "gtc")) - active = 6; - - combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_combo")); - g_assert (combo); - - gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); - g_object_unref (G_OBJECT (auth_model)); - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active); - - g_signal_connect (G_OBJECT (combo), "changed", - (GCallback) inner_auth_combo_changed_cb, - method); - return combo; -} - -static void -update_secrets (EAPMethod *parent, NMConnection *connection) -{ - eap_method_phase2_update_secrets_helper (parent, - connection, - "eap_ttls_inner_auth_combo", - I_METHOD_COLUMN); -} - -EAPMethodTTLS * -eap_method_ttls_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean is_editor, - gboolean secrets_only) -{ - EAPMethod *parent; - EAPMethodTTLS *method; - GtkWidget *widget; - NMSetting8021x *s_8021x = NULL; - gboolean ca_not_required = FALSE; - - parent = eap_method_init (sizeof (EAPMethodTTLS), - validate, - add_to_size_group, - fill_connection, - update_secrets, - destroy, - "/org/freedesktop/network-manager-applet/eap-method-ttls.ui", - "eap_ttls_notebook", - "eap_ttls_anon_identity_entry", - FALSE); - if (!parent) - return NULL; - - method = (EAPMethodTTLS *) parent; - method->password_flags_name = NM_SETTING_802_1X_PASSWORD; - method->sec_parent = ws_parent; - method->is_editor = is_editor; - - if (connection) - s_8021x = nm_connection_get_setting_802_1x (connection); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_grid")); - g_assert (widget); - - method->ca_cert_chooser = nma_cert_chooser_new ("CA", - NMA_CERT_CHOOSER_FLAG_CERT - | (secrets_only ? NMA_CERT_CHOOSER_FLAG_PASSWORDS : 0)); - gtk_grid_attach (GTK_GRID (widget), method->ca_cert_chooser, 0, 2, 2, 1); - gtk_widget_show (method->ca_cert_chooser); - - g_signal_connect (method->ca_cert_chooser, - "cert-validate", - G_CALLBACK (eap_method_ca_cert_validate_cb), - NULL); - g_signal_connect (method->ca_cert_chooser, - "changed", - G_CALLBACK (wireless_security_changed_cb), - ws_parent); - - eap_method_setup_cert_chooser (NMA_CERT_CHOOSER (method->ca_cert_chooser), s_8021x, - nm_setting_802_1x_get_ca_cert_scheme, - nm_setting_802_1x_get_ca_cert_path, - nm_setting_802_1x_get_ca_cert_uri, - nm_setting_802_1x_get_ca_cert_password, - NULL, - NULL, - NULL, - NULL); - - if (connection && eap_method_ca_cert_ignore_get (parent, connection)) { - gchar *ca_cert; - NMSetting8021xCKScheme scheme; - - ca_cert = nma_cert_chooser_get_cert (NMA_CERT_CHOOSER (method->ca_cert_chooser), &scheme); - if (ca_cert) - g_free (ca_cert); - else - ca_not_required = TRUE; - } - - if (secrets_only) - ca_not_required = TRUE; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_ca_cert_not_required_checkbox")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) ca_cert_not_required_toggled, - parent); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) wireless_security_changed_cb, - ws_parent); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), ca_not_required); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_anon_identity_entry")); - if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x)) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x)); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_domain_entry")); - if (s_8021x && nm_setting_802_1x_get_domain_suffix_match (s_8021x)) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_domain_suffix_match (s_8021x)); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - ws_parent); - - widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only); - inner_auth_combo_changed_cb (widget, (gpointer) method); - - if (secrets_only) { - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_anon_identity_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_anon_identity_entry")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_domain_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_domain_entry")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_ca_cert_not_required_checkbox")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_label")); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_combo")); - gtk_widget_hide (widget); - } - - nma_cert_chooser_setup_cert_password_storage (NMA_CERT_CHOOSER (method->ca_cert_chooser), - 0, (NMSetting *) s_8021x, NM_SETTING_802_1X_CA_CERT_PASSWORD, - FALSE, secrets_only); - - return method; -} - diff --git a/src/wireless-security/eap-method-ttls.h b/src/wireless-security/eap-method-ttls.h deleted file mode 100644 index a1899c12..00000000 --- a/src/wireless-security/eap-method-ttls.h +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * (C) Copyright 2007 - 2010 Red Hat, Inc. - */ - -#ifndef EAP_METHOD_TTLS_H -#define EAP_METHOD_TTLS_H - -#include "wireless-security.h" - -typedef struct _EAPMethodTTLS EAPMethodTTLS; - -EAPMethodTTLS *eap_method_ttls_new (WirelessSecurity *ws_parent, - NMConnection *connection, - gboolean is_editor, - gboolean secrets_only); - -#endif /* EAP_METHOD_TLS_H */ - diff --git a/src/wireless-security/eap-method-ttls.ui b/src/wireless-security/eap-method-ttls.ui deleted file mode 100644 index 8cb2b56a..00000000 --- a/src/wireless-security/eap-method-ttls.ui +++ /dev/null @@ -1,165 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkListStore" id="model6"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0"> </col> - </row> - </data> - </object> - <object class="GtkNotebook" id="eap_ttls_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="eap_ttls_grid"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkEntry" id="eap_ttls_anon_identity_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkBox" id="eap_ttls_inner_auth_vbox"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">6</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - <property name="width">2</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="eap_ttls_inner_auth_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="model">model6</property> - <child> - <object class="GtkCellRendererText" id="renderer6"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_ttls_inner_auth_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Inner authentication</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_ttls_inner_auth_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="eap_ttls_ca_cert_not_required_checkbox"> - <property name="label" translatable="yes">No CA certificate is _required</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="halign">start</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="eap_ttls_domain_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_ttls_anon_identity_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Anony_mous identity</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_ttls_anon_identity_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="eap_ttls_domain_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="tooltip_text" translatable="yes">Suffix of the server certificate name.</property> - <property name="label" translatable="yes">_Domain</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">eap_ttls_domain_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="label49"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/eap-method.c b/src/wireless-security/eap-method.c index b7c1a82e..b874072b 100644 --- a/src/wireless-security/eap-method.c +++ b/src/wireless-security/eap-method.c @@ -9,245 +9,12 @@ #include "nm-default.h" -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> - #include "eap-method.h" -#include "nm-utils.h" -#include "utils.h" -#include "helpers.h" - -G_DEFINE_BOXED_TYPE (EAPMethod, eap_method, eap_method_ref, eap_method_unref) - -GtkWidget * -eap_method_get_widget (EAPMethod *method) -{ - g_return_val_if_fail (method != NULL, NULL); - - return method->ui_widget; -} - -gboolean -eap_method_validate (EAPMethod *method, GError **error) -{ - gboolean result; - - g_return_val_if_fail (method != NULL, FALSE); - - g_assert (method->validate); - result = (*(method->validate)) (method, error); - if (!result && error && !*error) - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("undefined error in 802.1X security (wpa-eap)")); - return result; -} - -void -eap_method_add_to_size_group (EAPMethod *method, GtkSizeGroup *group) -{ - g_return_if_fail (method != NULL); - g_return_if_fail (group != NULL); - - g_assert (method->add_to_size_group); - return (*(method->add_to_size_group)) (method, group); -} - -void -eap_method_fill_connection (EAPMethod *method, - NMConnection *connection) -{ - g_return_if_fail (method != NULL); - g_return_if_fail (connection != NULL); - - g_assert (method->fill_connection); - return (*(method->fill_connection)) (method, connection); -} - -void -eap_method_update_secrets (EAPMethod *method, NMConnection *connection) -{ - g_return_if_fail (method != NULL); - g_return_if_fail (connection != NULL); - - if (method->update_secrets) - method->update_secrets (method, connection); -} - -void -eap_method_phase2_update_secrets_helper (EAPMethod *method, - NMConnection *connection, - const char *combo_name, - guint32 column) -{ - GtkWidget *combo; - GtkTreeIter iter; - GtkTreeModel *model; - - g_return_if_fail (method != NULL); - g_return_if_fail (connection != NULL); - g_return_if_fail (combo_name != NULL); - - combo = GTK_WIDGET (gtk_builder_get_object (method->builder, combo_name)); - g_assert (combo); - - /* Let each EAP phase2 method try to update its secrets */ - model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); - if (gtk_tree_model_get_iter_first (model, &iter)) { - do { - EAPMethod *eap = NULL; - - gtk_tree_model_get (model, &iter, column, &eap, -1); - if (eap) { - eap_method_update_secrets (eap, connection); - eap_method_unref (eap); - } - } while (gtk_tree_model_iter_next (model, &iter)); - } -} - -EAPMethod * -eap_method_init (gsize obj_size, - EMValidateFunc validate, - EMAddToSizeGroupFunc add_to_size_group, - EMFillConnectionFunc fill_connection, - EMUpdateSecretsFunc update_secrets, - EMDestroyFunc destroy, - const char *ui_resource, - const char *ui_widget_name, - const char *default_field, - gboolean phase2) -{ - EAPMethod *method; - GError *error = NULL; - - g_return_val_if_fail (obj_size > 0, NULL); - g_return_val_if_fail (ui_resource != NULL, NULL); - g_return_val_if_fail (ui_widget_name != NULL, NULL); - - method = g_slice_alloc0 (obj_size); - g_assert (method); - - method->refcount = 1; - method->obj_size = obj_size; - method->validate = validate; - method->add_to_size_group = add_to_size_group; - method->fill_connection = fill_connection; - method->update_secrets = update_secrets; - method->default_field = default_field; - method->phase2 = phase2; - - method->builder = gtk_builder_new (); - if (!gtk_builder_add_from_resource (method->builder, ui_resource, &error)) { - g_warning ("Couldn't load UI builder resource %s: %s", - ui_resource, error->message); - eap_method_unref (method); - return NULL; - } - - method->ui_widget = GTK_WIDGET (gtk_builder_get_object (method->builder, ui_widget_name)); - if (!method->ui_widget) { - g_warning ("Couldn't load UI widget '%s' from UI file %s", - ui_widget_name, ui_resource); - eap_method_unref (method); - return NULL; - } - g_object_ref_sink (method->ui_widget); - - method->destroy = destroy; - - return method; -} - - -EAPMethod * -eap_method_ref (EAPMethod *method) -{ - g_return_val_if_fail (method != NULL, NULL); - g_return_val_if_fail (method->refcount > 0, NULL); - - method->refcount++; - return method; -} - -void -eap_method_unref (EAPMethod *method) -{ - g_return_if_fail (method != NULL); - g_return_if_fail (method->refcount > 0); - - method->refcount--; - if (method->refcount == 0) { - if (method->destroy) - method->destroy (method); - - if (method->builder) - g_object_unref (method->builder); - if (method->ui_widget) - g_object_unref (method->ui_widget); - - g_slice_free1 (method->obj_size, method); - } -} /* Used as both GSettings keys and GObject data tags */ #define IGNORE_CA_CERT_TAG "ignore-ca-cert" #define IGNORE_PHASE2_CA_CERT_TAG "ignore-phase2-ca-cert" -/** - * eap_method_ca_cert_ignore_set: - * @method: the #EAPMethod object - * @connection: the #NMConnection - * @filename: the certificate file, if any - * @ca_cert_error: %TRUE if an error was encountered loading the given CA - * certificate, %FALSE if not or if a CA certificate is not present - * - * 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 %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, - NMConnection *connection, - const char *filename, - gboolean ca_cert_error) -{ - NMSetting8021x *s_8021x; - gboolean ignore; - - s_8021x = nm_connection_get_setting_802_1x (connection); - if (s_8021x) { - ignore = !ca_cert_error && filename == NULL; - g_object_set_data (G_OBJECT (s_8021x), - method->phase2 ? IGNORE_PHASE2_CA_CERT_TAG : IGNORE_CA_CERT_TAG, - GUINT_TO_POINTER (ignore)); - } -} - -/** - * eap_method_ca_cert_ignore_get: - * @method: the #EAPMethod object - * @connection: the #NMConnection - * - * Returns: %TRUE if a missing CA certificate can be ignored, %FALSE if a CA - * certificate should be required for the connection to be valid. - */ -gboolean -eap_method_ca_cert_ignore_get (EAPMethod *method, NMConnection *connection) -{ - NMSetting8021x *s_8021x; - - s_8021x = nm_connection_get_setting_802_1x (connection); - if (s_8021x) { - return !!g_object_get_data (G_OBJECT (s_8021x), - method->phase2 ? IGNORE_PHASE2_CA_CERT_TAG : IGNORE_CA_CERT_TAG); - } - return FALSE; -} - static GSettings * _get_ca_ignore_settings (NMConnection *connection) { @@ -333,95 +100,3 @@ eap_method_ca_cert_ignore_load (NMConnection *connection) GUINT_TO_POINTER (phase2_ignore)); g_object_unref (settings); } - -GError * -eap_method_ca_cert_validate_cb (NMACertChooser *cert_chooser, gpointer user_data) -{ - NMSetting8021xCKScheme scheme; - NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - gs_unref_object NMSetting8021x *setting = NULL; - gs_free char *value = NULL; - GError *local = NULL; - - setting = (NMSetting8021x *) nm_setting_802_1x_new (); - - value = nma_cert_chooser_get_cert (cert_chooser, &scheme); - if (!value) { - return g_error_new_literal (NMA_ERROR, NMA_ERROR_GENERIC, - _("no CA certificate selected")); - } - if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) { - if (!g_file_test (value, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - return g_error_new_literal (NMA_ERROR, NMA_ERROR_GENERIC, - _("selected CA certificate file does not exist")); - } - } - - if (!nm_setting_802_1x_set_ca_cert (setting, value, scheme, &format, &local)) - return local; - - return NULL; -} - -void -eap_method_setup_cert_chooser (NMACertChooser *cert_chooser, - NMSetting8021x *s_8021x, - NMSetting8021xCKScheme (*cert_scheme_func) (NMSetting8021x *setting), - const char *(*cert_path_func) (NMSetting8021x *setting), - const char *(*cert_uri_func) (NMSetting8021x *setting), - const char *(*cert_password_func) (NMSetting8021x *setting), - NMSetting8021xCKScheme (*key_scheme_func) (NMSetting8021x *setting), - const char *(*key_path_func) (NMSetting8021x *setting), - const char *(*key_uri_func) (NMSetting8021x *setting), - const char *(*key_password_func) (NMSetting8021x *setting)) -{ - NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_UNKNOWN; - const char *value = NULL; - const char *password = NULL; - - - if (s_8021x && cert_path_func && cert_uri_func && cert_scheme_func) { - scheme = cert_scheme_func (s_8021x); - switch (scheme) { - case NM_SETTING_802_1X_CK_SCHEME_PATH: - value = cert_path_func (s_8021x); - break; - case NM_SETTING_802_1X_CK_SCHEME_PKCS11: - value = cert_uri_func (s_8021x); - password = cert_password_func ? cert_password_func (s_8021x) : NULL; - if (password) - nma_cert_chooser_set_cert_password (cert_chooser, password); - break; - case NM_SETTING_802_1X_CK_SCHEME_UNKNOWN: - /* No CA set. */ - break; - default: - g_warning ("unhandled certificate scheme %d", scheme); - } - - } - nma_cert_chooser_set_cert (cert_chooser, value, scheme); - - if (s_8021x && key_path_func && key_uri_func && key_scheme_func) { - scheme = key_scheme_func (s_8021x); - switch (scheme) { - case NM_SETTING_802_1X_CK_SCHEME_PATH: - value = key_path_func (s_8021x); - break; - case NM_SETTING_802_1X_CK_SCHEME_PKCS11: - value = key_uri_func (s_8021x); - break; - case NM_SETTING_802_1X_CK_SCHEME_UNKNOWN: - /* No certificate set. */ - break; - default: - g_warning ("unhandled key scheme %d", scheme); - } - - nma_cert_chooser_set_key (cert_chooser, value, scheme); - } - - password = s_8021x && key_password_func ? key_password_func (s_8021x) : NULL; - if (password) - nma_cert_chooser_set_key_password (cert_chooser, key_password_func (s_8021x)); -} diff --git a/src/wireless-security/eap-method.h b/src/wireless-security/eap-method.h index ed9e1ac8..3cc9da03 100644 --- a/src/wireless-security/eap-method.h +++ b/src/wireless-security/eap-method.h @@ -9,99 +9,7 @@ #ifndef EAP_METHOD_H #define EAP_METHOD_H -typedef struct _EAPMethod EAPMethod; - -typedef void (*EMAddToSizeGroupFunc) (EAPMethod *method, GtkSizeGroup *group); -typedef void (*EMFillConnectionFunc) (EAPMethod *method, NMConnection *connection); -typedef void (*EMUpdateSecretsFunc) (EAPMethod *method, NMConnection *connection); -typedef void (*EMDestroyFunc) (EAPMethod *method); -typedef gboolean (*EMValidateFunc) (EAPMethod *method, GError **error); - -struct _EAPMethod { - guint32 refcount; - gsize obj_size; - - GtkBuilder *builder; - GtkWidget *ui_widget; - - const char *default_field; - - gboolean phase2; - gboolean secrets_only; - - EMAddToSizeGroupFunc add_to_size_group; - EMFillConnectionFunc fill_connection; - EMUpdateSecretsFunc update_secrets; - EMValidateFunc validate; - EMDestroyFunc destroy; -}; - -#define EAP_METHOD(x) ((EAPMethod *) x) - - -GtkWidget *eap_method_get_widget (EAPMethod *method); - -gboolean eap_method_validate (EAPMethod *method, GError **error); - -void eap_method_add_to_size_group (EAPMethod *method, GtkSizeGroup *group); - -void eap_method_fill_connection (EAPMethod *method, - NMConnection *connection); - -void eap_method_update_secrets (EAPMethod *method, NMConnection *connection); - -EAPMethod *eap_method_ref (EAPMethod *method); - -void eap_method_unref (EAPMethod *method); - -GType eap_method_get_type (void); - -/* Below for internal use only */ - -#include "nma-cert-chooser.h" -#include "eap-method-tls.h" -#include "eap-method-leap.h" -#include "eap-method-fast.h" -#include "eap-method-ttls.h" -#include "eap-method-peap.h" -#include "eap-method-simple.h" - -EAPMethod *eap_method_init (gsize obj_size, - EMValidateFunc validate, - EMAddToSizeGroupFunc add_to_size_group, - EMFillConnectionFunc fill_connection, - EMUpdateSecretsFunc update_secrets, - EMDestroyFunc destroy, - const char *ui_resource, - const char *ui_widget_name, - const char *default_field, - gboolean phase2); - -void eap_method_phase2_update_secrets_helper (EAPMethod *method, - NMConnection *connection, - const char *combo_name, - guint32 column); - -void eap_method_ca_cert_ignore_set (EAPMethod *method, - NMConnection *connection, - const char *filename, - gboolean ca_cert_error); -gboolean eap_method_ca_cert_ignore_get (EAPMethod *method, NMConnection *connection); - void eap_method_ca_cert_ignore_save (NMConnection *connection); void eap_method_ca_cert_ignore_load (NMConnection *connection); -GError *eap_method_ca_cert_validate_cb (NMACertChooser *cert_chooser, gpointer user_data); - -void eap_method_setup_cert_chooser (NMACertChooser *cert_chooser, - NMSetting8021x *s_8021x, - NMSetting8021xCKScheme (*cert_scheme_func) (NMSetting8021x *setting), - const char *(*cert_path_func) (NMSetting8021x *setting), - const char *(*cert_uri_func) (NMSetting8021x *setting), - const char *(*cert_password_func) (NMSetting8021x *setting), - NMSetting8021xCKScheme (*key_scheme_func) (NMSetting8021x *setting), - const char *(*key_path_func) (NMSetting8021x *setting), - const char *(*key_uri_func) (NMSetting8021x *setting), - const char *(*key_password_func) (NMSetting8021x *setting)); - #endif /* EAP_METHOD_H */ diff --git a/src/wireless-security/helpers.c b/src/wireless-security/helpers.c deleted file mode 100644 index 5cb86377..00000000 --- a/src/wireless-security/helpers.c +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2009 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "helpers.h" - -void -helper_fill_secret_entry (NMConnection *connection, - GtkBuilder *builder, - const char *entry_name, - GType setting_type, - HelperSecretFunc func) -{ - GtkWidget *widget; - NMSetting *setting; - const char *tmp; - - g_return_if_fail (connection != NULL); - g_return_if_fail (builder != NULL); - g_return_if_fail (entry_name != NULL); - g_return_if_fail (func != NULL); - - setting = nm_connection_get_setting (connection, setting_type); - if (setting) { - tmp = (*func) (setting); - if (tmp) { - widget = GTK_WIDGET (gtk_builder_get_object (builder, entry_name)); - g_assert (widget); - gtk_entry_set_text (GTK_ENTRY (widget), tmp); - } - } -} - diff --git a/src/wireless-security/helpers.h b/src/wireless-security/helpers.h deleted file mode 100644 index 8326cc18..00000000 --- a/src/wireless-security/helpers.h +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2009 - 2014 Red Hat, Inc. - */ - -#ifndef _HELPERS_H_ -#define _HELPERS_H_ - -typedef const char * (*HelperSecretFunc)(NMSetting *); - -void helper_fill_secret_entry (NMConnection *connection, - GtkBuilder *builder, - const char *entry_name, - GType setting_type, - HelperSecretFunc func); - -#endif /* _HELPERS_H_ */ - diff --git a/src/wireless-security/meson.build b/src/wireless-security/meson.build index 288f341e..36acf3b6 100644 --- a/src/wireless-security/meson.build +++ b/src/wireless-security/meson.build @@ -2,41 +2,6 @@ wireless_security_inc = include_directories('.') sources = files( 'eap-method.c', - 'eap-method-fast.c', - 'eap-method-leap.c', - 'eap-method-peap.c', - 'eap-method-simple.c', - 'eap-method-tls.c', - 'eap-method-ttls.c', - 'helpers.c', - 'wireless-security.c', - 'ws-dynamic-wep.c', - 'ws-leap.c', - 'ws-sae.c', - 'ws-wep-key.c', - 'ws-wpa-eap.c', - 'ws-wpa-psk.c' -) - -resource_data = files( - 'eap-method-fast.ui', - 'eap-method-leap.ui', - 'eap-method-peap.ui', - 'eap-method-simple.ui', - 'eap-method-tls.ui', - 'eap-method-ttls.ui', - 'ws-dynamic-wep.ui', - 'ws-leap.ui', - 'ws-sae.ui', - 'ws-wep-key.ui', - 'ws-wpa-eap.ui', - 'ws-wpa-psk.ui' -) - -sources += gnome.compile_resources( - 'ws-resources', - 'ws.gresource.xml', - dependencies: resource_data ) incs = [ @@ -48,8 +13,6 @@ incs = [ deps = [ gtk_dep, libnm_dep, - libnma_dep, - libutils_libnm_dep ] libwireless_security_libnm = static_library( diff --git a/src/wireless-security/wireless-security.c b/src/wireless-security/wireless-security.c deleted file mode 100644 index 5fc110f1..00000000 --- a/src/wireless-security/wireless-security.c +++ /dev/null @@ -1,594 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <string.h> - -#include "wireless-security.h" -#include "eap-method.h" -#include "utils.h" - -G_DEFINE_BOXED_TYPE (WirelessSecurity, wireless_security, wireless_security_ref, wireless_security_unref) - -GtkWidget * -wireless_security_get_widget (WirelessSecurity *sec) -{ - g_return_val_if_fail (sec != NULL, NULL); - - return sec->ui_widget; -} - -void -wireless_security_set_changed_notify (WirelessSecurity *sec, - WSChangedFunc func, - gpointer user_data) -{ - g_return_if_fail (sec != NULL); - - sec->changed_notify = func; - sec->changed_notify_data = user_data; -} - -void -wireless_security_changed_cb (GtkWidget *ignored, gpointer user_data) -{ - WirelessSecurity *sec = WIRELESS_SECURITY (user_data); - - if (sec->changed_notify) - (*(sec->changed_notify)) (sec, sec->changed_notify_data); -} - -gboolean -wireless_security_validate (WirelessSecurity *sec, GError **error) -{ - gboolean result; - - g_return_val_if_fail (sec != NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - g_assert (sec->validate); - result = (*(sec->validate)) (sec, error); - if (!result && error && !*error) - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Unknown error validating 802.1X security")); - return result; -} - -void -wireless_security_add_to_size_group (WirelessSecurity *sec, GtkSizeGroup *group) -{ - g_return_if_fail (sec != NULL); - g_return_if_fail (group != NULL); - - g_assert (sec->add_to_size_group); - return (*(sec->add_to_size_group)) (sec, group); -} - -void -wireless_security_fill_connection (WirelessSecurity *sec, - NMConnection *connection) -{ - g_return_if_fail (sec != NULL); - g_return_if_fail (connection != NULL); - - g_assert (sec->fill_connection); - return (*(sec->fill_connection)) (sec, connection); -} - -void -wireless_security_update_secrets (WirelessSecurity *sec, NMConnection *connection) -{ - g_return_if_fail (sec != NULL); - g_return_if_fail (connection != NULL); - - if (sec->update_secrets) - sec->update_secrets (sec, connection); -} - -WirelessSecurity * -wireless_security_ref (WirelessSecurity *sec) -{ - g_return_val_if_fail (sec != NULL, NULL); - g_return_val_if_fail (sec->refcount > 0, NULL); - - sec->refcount++; - return sec; -} - -void -wireless_security_unref (WirelessSecurity *sec) -{ - g_return_if_fail (sec != NULL); - g_return_if_fail (sec->refcount > 0); - - sec->refcount--; - if (sec->refcount == 0) { - if (sec->destroy) - sec->destroy (sec); - - g_free (sec->username); - if (sec->password) { - memset (sec->password, 0, strlen (sec->password)); - g_free (sec->password); - } - - if (sec->builder) - g_object_unref (sec->builder); - if (sec->ui_widget) - g_object_unref (sec->ui_widget); - g_slice_free1 (sec->obj_size, sec); - } -} - -WirelessSecurity * -wireless_security_init (gsize obj_size, - WSValidateFunc validate, - WSAddToSizeGroupFunc add_to_size_group, - WSFillConnectionFunc fill_connection, - WSUpdateSecretsFunc update_secrets, - WSDestroyFunc destroy, - const char *ui_resource, - const char *ui_widget_name, - const char *default_field) -{ - WirelessSecurity *sec; - GError *error = NULL; - - g_return_val_if_fail (obj_size > 0, NULL); - g_return_val_if_fail (ui_resource != NULL, NULL); - g_return_val_if_fail (ui_widget_name != NULL, NULL); - - sec = g_slice_alloc0 (obj_size); - g_assert (sec); - - sec->refcount = 1; - sec->obj_size = obj_size; - - sec->validate = validate; - sec->add_to_size_group = add_to_size_group; - sec->fill_connection = fill_connection; - sec->update_secrets = update_secrets; - sec->default_field = default_field; - - sec->builder = gtk_builder_new (); - if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) { - g_warning ("Couldn't load UI builder resource %s: %s", - ui_resource, error->message); - g_error_free (error); - wireless_security_unref (sec); - return NULL; - } - - sec->ui_widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, ui_widget_name)); - if (!sec->ui_widget) { - g_warning ("Couldn't load UI widget '%s' from UI file %s", - ui_widget_name, ui_resource); - wireless_security_unref (sec); - return NULL; - } - g_object_ref_sink (sec->ui_widget); - - sec->destroy = destroy; - sec->adhoc_compatible = TRUE; - sec->hotspot_compatible = TRUE; - - return sec; -} - -gboolean -wireless_security_adhoc_compatible (WirelessSecurity *sec) -{ - g_return_val_if_fail (sec != NULL, FALSE); - - return sec->adhoc_compatible; -} - -gboolean -wireless_security_hotspot_compatible (WirelessSecurity *sec) -{ - g_return_val_if_fail (sec != NULL, FALSE); - - return sec->hotspot_compatible; -} - -void -wireless_security_set_userpass (WirelessSecurity *sec, - const char *user, - const char *password, - gboolean always_ask, - gboolean show_password) -{ - g_free (sec->username); - sec->username = g_strdup (user); - - if (sec->password) { - memset (sec->password, 0, strlen (sec->password)); - g_free (sec->password); - } - sec->password = g_strdup (password); - - if (always_ask != (gboolean) -1) - sec->always_ask = always_ask; - sec->show_password = show_password; -} - -void -wireless_security_set_userpass_802_1x (WirelessSecurity *sec, - NMConnection *connection) -{ - const char *user = NULL, *password = NULL; - gboolean always_ask = FALSE, show_password = FALSE; - NMSetting8021x *setting; - NMSettingSecretFlags flags; - - if (!connection) - goto set; - - setting = nm_connection_get_setting_802_1x (connection); - if (!setting) - goto set; - - user = nm_setting_802_1x_get_identity (setting); - password = nm_setting_802_1x_get_password (setting); - - if (nm_setting_get_secret_flags (NM_SETTING (setting), NM_SETTING_802_1X_PASSWORD, &flags, NULL)) - always_ask = !!(flags & NM_SETTING_SECRET_FLAG_NOT_SAVED); - -set: - wireless_security_set_userpass (sec, user, password, always_ask, show_password); -} - -void -wireless_security_clear_ciphers (NMConnection *connection) -{ - NMSettingWirelessSecurity *s_wireless_sec; - - g_return_if_fail (connection != NULL); - - s_wireless_sec = nm_connection_get_setting_wireless_security (connection); - g_assert (s_wireless_sec); - - nm_setting_wireless_security_clear_protos (s_wireless_sec); - nm_setting_wireless_security_clear_pairwise (s_wireless_sec); - nm_setting_wireless_security_clear_groups (s_wireless_sec); -} - -void -ws_802_1x_add_to_size_group (WirelessSecurity *sec, - GtkSizeGroup *size_group, - const char *label_name, - const char *combo_name) -{ - GtkWidget *widget; - GtkTreeModel *model; - GtkTreeIter iter; - EAPMethod *eap; - - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, label_name)); - g_assert (widget); - gtk_size_group_add_widget (size_group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name)); - g_assert (widget); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1); - g_assert (eap); - eap_method_add_to_size_group (eap, size_group); - eap_method_unref (eap); -} - -gboolean -ws_802_1x_validate (WirelessSecurity *sec, const char *combo_name, GError **error) -{ - GtkWidget *widget; - GtkTreeModel *model; - GtkTreeIter iter; - EAPMethod *eap = NULL; - gboolean valid = FALSE; - - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name)); - g_assert (widget); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1); - g_assert (eap); - valid = eap_method_validate (eap, error); - eap_method_unref (eap); - return valid; -} - -void -ws_802_1x_auth_combo_changed (GtkWidget *combo, - WirelessSecurity *sec, - const char *vbox_name, - GtkSizeGroup *size_group) -{ - GtkWidget *vbox; - EAPMethod *eap = NULL; - GList *elt, *children; - GtkTreeModel *model; - GtkTreeIter iter; - GtkWidget *eap_widget; - GtkWidget *eap_default_widget = NULL; - - vbox = GTK_WIDGET (gtk_builder_get_object (sec->builder, vbox_name)); - g_assert (vbox); - - /* Remove any previous wireless security widgets */ - children = gtk_container_get_children (GTK_CONTAINER (vbox)); - for (elt = children; elt; elt = g_list_next (elt)) - gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data)); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter); - gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1); - g_assert (eap); - - eap_widget = eap_method_get_widget (eap); - g_assert (eap_widget); - gtk_widget_unparent (eap_widget); - - if (size_group) - eap_method_add_to_size_group (eap, size_group); - gtk_container_add (GTK_CONTAINER (vbox), eap_widget); - - /* Refocus the EAP method's default widget */ - if (eap->default_field) { - eap_default_widget = GTK_WIDGET (gtk_builder_get_object (eap->builder, eap->default_field)); - if (eap_default_widget) - gtk_widget_grab_focus (eap_default_widget); - } - - eap_method_unref (eap); - - wireless_security_changed_cb (combo, WIRELESS_SECURITY (sec)); -} - -GtkWidget * -ws_802_1x_auth_combo_init (WirelessSecurity *sec, - const char *combo_name, - const char *combo_label, - GCallback auth_combo_changed_cb, - NMConnection *connection, - gboolean is_editor, - gboolean secrets_only, - const char *const*secrets_hints) -{ - GtkWidget *combo, *widget; - GtkListStore *auth_model; - GtkTreeIter iter; - EAPMethodSimple *em_md5; - EAPMethodTLS *em_tls; - EAPMethodLEAP *em_leap; - EAPMethodSimple *em_pwd; - EAPMethodFAST *em_fast; - EAPMethodTTLS *em_ttls; - EAPMethodPEAP *em_peap; - const char *default_method = NULL, *ctype = NULL; - int active = -1, item = 0; - gboolean wired = FALSE; - EAPMethodSimpleFlags simple_flags = EAP_METHOD_SIMPLE_FLAG_NONE; - - /* Grab the default EAP method out of the security object */ - if (connection) { - NMSettingConnection *s_con; - NMSetting8021x *s_8021x; - - s_con = nm_connection_get_setting_connection (connection); - if (s_con) - ctype = nm_setting_connection_get_connection_type (s_con); - if ( (g_strcmp0 (ctype, NM_SETTING_WIRED_SETTING_NAME) == 0) - || nm_connection_get_setting_wired (connection)) - wired = TRUE; - - s_8021x = nm_connection_get_setting_802_1x (connection); - if (s_8021x && nm_setting_802_1x_get_num_eap_methods (s_8021x)) - default_method = nm_setting_802_1x_get_eap_method (s_8021x, 0); - } - - /* initialize WirelessSecurity userpass from connection (clear if no connection) */ - wireless_security_set_userpass_802_1x (sec, connection); - - auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_type ()); - - if (is_editor) - simple_flags |= EAP_METHOD_SIMPLE_FLAG_IS_EDITOR; - if (secrets_only) - simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY; - - if (wired) { - em_md5 = eap_method_simple_new (sec, connection, EAP_METHOD_SIMPLE_TYPE_MD5, simple_flags, NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("MD5"), - AUTH_METHOD_COLUMN, em_md5, - -1); - eap_method_unref (EAP_METHOD (em_md5)); - if (default_method && (active < 0) && !strcmp (default_method, "md5")) - active = item; - item++; - } - - em_tls = eap_method_tls_new (sec, connection, FALSE, secrets_only); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("TLS"), - AUTH_METHOD_COLUMN, em_tls, - -1); - eap_method_unref (EAP_METHOD (em_tls)); - if (default_method && (active < 0) && !strcmp (default_method, "tls")) - active = item; - item++; - - if (!wired) { - em_leap = eap_method_leap_new (sec, connection, secrets_only); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("LEAP"), - AUTH_METHOD_COLUMN, em_leap, - -1); - eap_method_unref (EAP_METHOD (em_leap)); - if (default_method && (active < 0) && !strcmp (default_method, "leap")) - active = item; - item++; - } - - em_pwd = eap_method_simple_new (sec, connection, EAP_METHOD_SIMPLE_TYPE_PWD, simple_flags, NULL); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("PWD"), - AUTH_METHOD_COLUMN, em_pwd, - -1); - eap_method_unref (EAP_METHOD (em_pwd)); - if (default_method && (active < 0) && !strcmp (default_method, "pwd")) - active = item; - item++; - - em_fast = eap_method_fast_new (sec, connection, is_editor, secrets_only); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("FAST"), - AUTH_METHOD_COLUMN, em_fast, - -1); - eap_method_unref (EAP_METHOD (em_fast)); - if (default_method && (active < 0) && !strcmp (default_method, "fast")) - active = item; - item++; - - em_ttls = eap_method_ttls_new (sec, connection, is_editor, secrets_only); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("Tunneled TLS"), - AUTH_METHOD_COLUMN, em_ttls, - -1); - eap_method_unref (EAP_METHOD (em_ttls)); - if (default_method && (active < 0) && !strcmp (default_method, "ttls")) - active = item; - item++; - - em_peap = eap_method_peap_new (sec, connection, is_editor, secrets_only); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("Protected EAP (PEAP)"), - AUTH_METHOD_COLUMN, em_peap, - -1); - eap_method_unref (EAP_METHOD (em_peap)); - if (default_method && (active < 0) && !strcmp (default_method, "peap")) - active = item; - item++; - - if (secrets_hints && secrets_hints[0]) { - EAPMethodSimple *em_hints; - - em_hints = eap_method_simple_new (sec, connection, EAP_METHOD_SIMPLE_TYPE_UNKNOWN, - simple_flags, secrets_hints); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("Unknown"), - AUTH_METHOD_COLUMN, em_hints, - -1); - eap_method_unref (EAP_METHOD (em_hints)); - active = item; - item++; - } else if (default_method && !strcmp (default_method, "external")) { - EAPMethodSimple *em_extern; - const char *empty_hints[] = { NULL }; - - em_extern = eap_method_simple_new (sec, connection, EAP_METHOD_SIMPLE_TYPE_UNKNOWN, - simple_flags, empty_hints); - gtk_list_store_append (auth_model, &iter); - gtk_list_store_set (auth_model, &iter, - AUTH_NAME_COLUMN, _("Externally configured"), - AUTH_METHOD_COLUMN, em_extern, - -1); - eap_method_unref (EAP_METHOD (em_extern)); - active = item; - item++; - } - - combo = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name)); - g_assert (combo); - - gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); - g_object_unref (G_OBJECT (auth_model)); - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active < 0 ? 0 : (guint32) active); - - g_signal_connect (G_OBJECT (combo), "changed", auth_combo_changed_cb, sec); - - if (secrets_only) { - gtk_widget_hide (combo); - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_label)); - gtk_widget_hide (widget); - } - - return combo; -} - -void -ws_802_1x_fill_connection (WirelessSecurity *sec, - const char *combo_name, - NMConnection *connection) -{ - GtkWidget *widget; - NMSettingWirelessSecurity *s_wireless_sec; - NMSetting8021x *s_8021x; - EAPMethod *eap = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - - /* Get the EAPMethod object */ - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name)); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter); - gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1); - g_assert (eap); - - /* Blow away the old wireless security setting by adding a clear one */ - s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec); - - /* Blow away the old 802.1x setting by adding a clear one */ - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - nm_connection_add_setting (connection, (NMSetting *) s_8021x); - - eap_method_fill_connection (eap, connection); - eap_method_unref (eap); -} - -void -ws_802_1x_update_secrets (WirelessSecurity *sec, - const char *combo_name, - NMConnection *connection) -{ - GtkWidget *widget; - EAPMethod *eap = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - - g_return_if_fail (sec != NULL); - g_return_if_fail (combo_name != NULL); - g_return_if_fail (connection != NULL); - - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name)); - g_return_if_fail (widget != NULL); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - - /* Let each EAP method try to update its secrets */ - if (gtk_tree_model_get_iter_first (model, &iter)) { - do { - gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1); - if (eap) { - eap_method_update_secrets (eap, connection); - eap_method_unref (eap); - } - } while (gtk_tree_model_iter_next (model, &iter)); - } -} diff --git a/src/wireless-security/wireless-security.h b/src/wireless-security/wireless-security.h deleted file mode 100644 index 49289812..00000000 --- a/src/wireless-security/wireless-security.h +++ /dev/null @@ -1,137 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#ifndef WIRELESS_SECURITY_H -#define WIRELESS_SECURITY_H - -typedef struct _WirelessSecurity WirelessSecurity; -GType wireless_security_get_type (void); - -#define WIRELESS_TYPE_SECURITY (wireless_security_get_type ()) -#define WIRELESS_SECURITY(x) ((WirelessSecurity *) x) - -typedef void (*WSChangedFunc) (WirelessSecurity *sec, gpointer user_data); - -typedef void (*WSAddToSizeGroupFunc) (WirelessSecurity *sec, GtkSizeGroup *group); -typedef void (*WSFillConnectionFunc) (WirelessSecurity *sec, NMConnection *connection); -typedef void (*WSUpdateSecretsFunc) (WirelessSecurity *sec, NMConnection *connection); -typedef void (*WSDestroyFunc) (WirelessSecurity *sec); -typedef gboolean (*WSValidateFunc) (WirelessSecurity *sec, GError **error); -typedef GtkWidget * (*WSNagUserFunc) (WirelessSecurity *sec); - -struct _WirelessSecurity { - guint32 refcount; - gsize obj_size; - GtkBuilder *builder; - GtkWidget *ui_widget; - WSChangedFunc changed_notify; - gpointer changed_notify_data; - const char *default_field; - gboolean adhoc_compatible; - gboolean hotspot_compatible; - - char *username, *password; - gboolean always_ask, show_password; - - WSAddToSizeGroupFunc add_to_size_group; - WSFillConnectionFunc fill_connection; - WSUpdateSecretsFunc update_secrets; - WSValidateFunc validate; - WSDestroyFunc destroy; -}; - -GtkWidget *wireless_security_get_widget (WirelessSecurity *sec); - -void wireless_security_set_changed_notify (WirelessSecurity *sec, - WSChangedFunc func, - gpointer user_data); - -gboolean wireless_security_validate (WirelessSecurity *sec, GError **error); - -void wireless_security_add_to_size_group (WirelessSecurity *sec, - GtkSizeGroup *group); - -void wireless_security_fill_connection (WirelessSecurity *sec, - NMConnection *connection); - -void wireless_security_update_secrets (WirelessSecurity *sec, - NMConnection *connection); - -gboolean wireless_security_adhoc_compatible (WirelessSecurity *sec); - -gboolean wireless_security_hotspot_compatible (WirelessSecurity *sec); - -void wireless_security_set_userpass (WirelessSecurity *sec, - const char *user, - const char *password, - gboolean always_ask, - gboolean show_password); -void wireless_security_set_userpass_802_1x (WirelessSecurity *sec, - NMConnection *connection); - -WirelessSecurity *wireless_security_ref (WirelessSecurity *sec); - -void wireless_security_unref (WirelessSecurity *sec); - -/* Below for internal use only */ - -#include "ws-sae.h" -#include "ws-wep-key.h" -#include "ws-wpa-psk.h" -#include "ws-leap.h" -#include "ws-wpa-eap.h" -#include "ws-dynamic-wep.h" - -WirelessSecurity *wireless_security_init (gsize obj_size, - WSValidateFunc validate, - WSAddToSizeGroupFunc add_to_size_group, - WSFillConnectionFunc fill_connection, - WSUpdateSecretsFunc update_secrets, - WSDestroyFunc destroy, - const char *ui_resource, - const char *ui_widget_name, - const char *default_field); - -void wireless_security_changed_cb (GtkWidget *entry, gpointer user_data); - -void wireless_security_clear_ciphers (NMConnection *connection); - -#define AUTH_NAME_COLUMN 0 -#define AUTH_METHOD_COLUMN 1 - -GtkWidget *ws_802_1x_auth_combo_init (WirelessSecurity *sec, - const char *combo_name, - const char *combo_label, - GCallback auth_combo_changed_cb, - NMConnection *connection, - gboolean is_editor, - gboolean secrets_only, - const char *const*secrets_hints); - -void ws_802_1x_auth_combo_changed (GtkWidget *combo, - WirelessSecurity *sec, - const char *vbox_name, - GtkSizeGroup *size_group); - -gboolean ws_802_1x_validate (WirelessSecurity *sec, const char *combo_name, GError **error); - -void ws_802_1x_add_to_size_group (WirelessSecurity *sec, - GtkSizeGroup *size_group, - const char *label_name, - const char *combo_name); - -void ws_802_1x_fill_connection (WirelessSecurity *sec, - const char *combo_name, - NMConnection *connection); - -void ws_802_1x_update_secrets (WirelessSecurity *sec, - const char *combo_name, - NMConnection *connection); - -#endif /* WIRELESS_SECURITY_H */ - diff --git a/src/wireless-security/ws-dynamic-wep.c b/src/wireless-security/ws-dynamic-wep.c deleted file mode 100644 index 855e44d8..00000000 --- a/src/wireless-security/ws-dynamic-wep.c +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "wireless-security.h" -#include "eap-method.h" - -struct _WirelessSecurityDynamicWEP { - WirelessSecurity parent; - - GtkSizeGroup *size_group; -}; - -static void -destroy (WirelessSecurity *parent) -{ - WirelessSecurityDynamicWEP *sec = (WirelessSecurityDynamicWEP *) parent; - - if (sec->size_group) - g_object_unref (sec->size_group); -} - -static gboolean -validate (WirelessSecurity *parent, GError **error) -{ - return ws_802_1x_validate (parent, "dynamic_wep_auth_combo", error); -} - -static void -add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) -{ - WirelessSecurityDynamicWEP *sec = (WirelessSecurityDynamicWEP *) parent; - - if (sec->size_group) - g_object_unref (sec->size_group); - sec->size_group = g_object_ref (group); - - ws_802_1x_add_to_size_group (parent, - sec->size_group, - "dynamic_wep_auth_label", - "dynamic_wep_auth_combo"); -} - -static void -fill_connection (WirelessSecurity *parent, NMConnection *connection) -{ - NMSettingWirelessSecurity *s_wireless_sec; - - ws_802_1x_fill_connection (parent, "dynamic_wep_auth_combo", connection); - - s_wireless_sec = nm_connection_get_setting_wireless_security (connection); - g_assert (s_wireless_sec); - - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL); -} - -static void -auth_combo_changed_cb (GtkWidget *combo, gpointer user_data) -{ - WirelessSecurity *parent = WIRELESS_SECURITY (user_data); - WirelessSecurityDynamicWEP *sec = (WirelessSecurityDynamicWEP *) parent; - - ws_802_1x_auth_combo_changed (combo, - parent, - "dynamic_wep_method_vbox", - sec->size_group); -} - -static void -update_secrets (WirelessSecurity *parent, NMConnection *connection) -{ - ws_802_1x_update_secrets (parent, "dynamic_wep_auth_combo", connection); -} - -WirelessSecurityDynamicWEP * -ws_dynamic_wep_new (NMConnection *connection, - gboolean is_editor, - gboolean secrets_only) -{ - WirelessSecurity *parent; - GtkWidget *widget; - - parent = wireless_security_init (sizeof (WirelessSecurityDynamicWEP), - validate, - add_to_size_group, - fill_connection, - update_secrets, - destroy, - "/org/freedesktop/network-manager-applet/ws-dynamic-wep.ui", - "dynamic_wep_notebook", - NULL); - if (!parent) - return NULL; - - parent->adhoc_compatible = FALSE; - parent->hotspot_compatible = FALSE; - - widget = ws_802_1x_auth_combo_init (parent, - "dynamic_wep_auth_combo", - "dynamic_wep_auth_label", - (GCallback) auth_combo_changed_cb, - connection, - is_editor, - secrets_only, - NULL); - auth_combo_changed_cb (widget, (gpointer) parent); - - return (WirelessSecurityDynamicWEP *) parent; -} - diff --git a/src/wireless-security/ws-dynamic-wep.h b/src/wireless-security/ws-dynamic-wep.h deleted file mode 100644 index 9bac4ad9..00000000 --- a/src/wireless-security/ws-dynamic-wep.h +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#ifndef WS_DYNAMIC_WEP_H -#define WS_DYNAMIC_WEP_H - -typedef struct _WirelessSecurityDynamicWEP WirelessSecurityDynamicWEP; - -WirelessSecurityDynamicWEP *ws_dynamic_wep_new (NMConnection *connection, - gboolean is_editor, - gboolean secrets_only); - -#endif /* WS_DYNAMIC_WEP_H */ diff --git a/src/wireless-security/ws-dynamic-wep.ui b/src/wireless-security/ws-dynamic-wep.ui deleted file mode 100644 index a538f107..00000000 --- a/src/wireless-security/ws-dynamic-wep.ui +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkListStore" id="model7"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0"> </col> - </row> - </data> - </object> - <object class="GtkNotebook" id="dynamic_wep_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="table12"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="dynamic_wep_auth_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Au_thentication</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">dynamic_wep_auth_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="dynamic_wep_auth_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="model">model7</property> - <child> - <object class="GtkCellRendererText" id="renderer7"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkBox" id="dynamic_wep_method_vbox"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">6</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">2</property> - </packing> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="label55"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/ws-leap.c b/src/wireless-security/ws-leap.c deleted file mode 100644 index f102fc6a..00000000 --- a/src/wireless-security/ws-leap.c +++ /dev/null @@ -1,206 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <string.h> - -#include "wireless-security.h" -#include "helpers.h" -#include "nma-ui-utils.h" -#include "utils.h" - -struct _WirelessSecurityLEAP { - WirelessSecurity parent; - gboolean editing_connection; - const char *password_flags_name; -}; - -static void -show_toggled_cb (GtkCheckButton *button, WirelessSecurity *sec) -{ - GtkWidget *widget; - gboolean visible; - - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "leap_password_entry")); - g_assert (widget); - - visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - gtk_entry_set_visibility (GTK_ENTRY (widget), visible); -} - -static gboolean -validate (WirelessSecurity *parent, GError **error) -{ - GtkWidget *entry; - NMSettingSecretFlags secret_flags; - const char *text; - gboolean ret = TRUE; - - entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_entry")); - g_assert (entry); - text = gtk_entry_get_text (GTK_ENTRY (entry)); - if (!text || !strlen (text)) { - widget_set_error (entry); - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing leap-username")); - ret = FALSE; - } else - widget_unset_error (entry); - - entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_entry")); - g_assert (entry); - - secret_flags = nma_utils_menu_to_secret_flags (entry); - text = gtk_entry_get_text (GTK_ENTRY (entry)); - - if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED - || secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED - || (text && strlen (text))) { - widget_unset_error (entry); - } else { - widget_set_error (entry); - if (ret) { - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing leap-password")); - ret = FALSE; - } - } - - return ret; -} - -static void -add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) -{ - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_label")); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_label")); - gtk_size_group_add_widget (group, widget); -} - -static void -fill_connection (WirelessSecurity *parent, NMConnection *connection) -{ - WirelessSecurityLEAP *sec = (WirelessSecurityLEAP *) parent; - NMSettingWirelessSecurity *s_wireless_sec; - NMSettingSecretFlags secret_flags; - GtkWidget *widget, *passwd_entry; - const char *leap_password = NULL, *leap_username = NULL; - - /* Blow away the old security setting by adding a clear one */ - s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_entry")); - leap_username = gtk_entry_get_text (GTK_ENTRY (widget)); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_entry")); - passwd_entry = widget; - leap_password = gtk_entry_get_text (GTK_ENTRY (widget)); - - g_object_set (s_wireless_sec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", - NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, - NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, leap_password, - NULL); - - /* Save LEAP_PASSWORD_FLAGS to the connection */ - secret_flags = nma_utils_menu_to_secret_flags (passwd_entry); - nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), sec->password_flags_name, - secret_flags, NULL); - - /* Update secret flags and popup when editing the connection */ - if (sec->editing_connection) - nma_utils_update_password_storage (passwd_entry, secret_flags, - NM_SETTING (s_wireless_sec), sec->password_flags_name); -} - -static void -update_secrets (WirelessSecurity *parent, NMConnection *connection) -{ - helper_fill_secret_entry (connection, - parent->builder, - "leap_password_entry", - NM_TYPE_SETTING_WIRELESS_SECURITY, - (HelperSecretFunc) nm_setting_wireless_security_get_leap_password); -} - -WirelessSecurityLEAP * -ws_leap_new (NMConnection *connection, gboolean secrets_only) -{ - WirelessSecurity *parent; - WirelessSecurityLEAP *sec; - GtkWidget *widget; - NMSettingWirelessSecurity *wsec = NULL; - - parent = wireless_security_init (sizeof (WirelessSecurityLEAP), - validate, - add_to_size_group, - fill_connection, - update_secrets, - NULL, - "/org/freedesktop/network-manager-applet/ws-leap.ui", - "leap_notebook", - "leap_username_entry"); - if (!parent) - return NULL; - - if (connection) { - wsec = nm_connection_get_setting_wireless_security (connection); - if (wsec) { - const char *auth_alg; - - /* Ignore if wireless security doesn't specify LEAP */ - auth_alg = nm_setting_wireless_security_get_auth_alg (wsec); - if (!auth_alg || strcmp (auth_alg, "leap")) - wsec = NULL; - } - } - - parent->adhoc_compatible = FALSE; - parent->hotspot_compatible = FALSE; - sec = (WirelessSecurityLEAP *) parent; - sec->editing_connection = secrets_only ? FALSE : TRUE; - sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_entry")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - sec); - - /* Create password-storage popup menu for password entry under entry's secondary icon */ - nma_utils_setup_password_storage (widget, 0, (NMSetting *) wsec, sec->password_flags_name, - FALSE, secrets_only); - - if (wsec) - update_secrets (WIRELESS_SECURITY (sec), connection); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_entry")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - sec); - if (wsec) - gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_wireless_security_get_leap_username (wsec)); - - if (secrets_only) - gtk_widget_hide (widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_leap")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) show_toggled_cb, - sec); - - return sec; -} - diff --git a/src/wireless-security/ws-leap.h b/src/wireless-security/ws-leap.h deleted file mode 100644 index f0221bd9..00000000 --- a/src/wireless-security/ws-leap.h +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#ifndef WS_LEAP_H -#define WS_LEAP_H - -typedef struct _WirelessSecurityLEAP WirelessSecurityLEAP; - -WirelessSecurityLEAP * ws_leap_new (NMConnection *connection, gboolean secrets_only); - -#endif /* WS_LEAP_H */ diff --git a/src/wireless-security/ws-leap.ui b/src/wireless-security/ws-leap.ui deleted file mode 100644 index a93121d6..00000000 --- a/src/wireless-security/ws-leap.ui +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkNotebook" id="leap_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="table5"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="valign">start</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="leap_username_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Username</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">leap_username_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="leap_password_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Password</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">leap_password_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="leap_password_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="visibility">False</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="show_checkbutton_leap"> - <property name="label" translatable="yes">Sho_w password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="leap_username_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="GtkLabel1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/ws-sae.c b/src/wireless-security/ws-sae.c deleted file mode 100644 index 7fa95c68..00000000 --- a/src/wireless-security/ws-sae.c +++ /dev/null @@ -1,202 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2007 - 2019 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "wireless-security.h" -#include "helpers.h" -#include "nma-ui-utils.h" -#include "utils.h" - -#define WPA_PMK_LEN 32 - -struct _WirelessSecuritySAE { - WirelessSecurity parent; - - gboolean editing_connection; - const char *password_flags_name; -}; - -static void -show_toggled_cb (GtkCheckButton *button, WirelessSecurity *sec) -{ - GtkWidget *widget; - gboolean visible; - - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "psk_entry")); - g_assert (widget); - - visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - gtk_entry_set_visibility (GTK_ENTRY (widget), visible); -} - -static gboolean -validate (WirelessSecurity *parent, GError **error) -{ - GtkWidget *entry; - NMSettingSecretFlags secret_flags; - const char *key; - - entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "psk_entry")); - g_assert (entry); - - secret_flags = nma_utils_menu_to_secret_flags (entry); - key = gtk_entry_get_text (GTK_ENTRY (entry)); - - if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED - || secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) { - /* All good. */ - } else if (key == NULL || key[0] == '\0') { - widget_set_error (entry); - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing password")); - return FALSE; - } - widget_unset_error (entry); - - return TRUE; -} - -static void -add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) -{ - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "sae_type_label")); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "sae_label")); - gtk_size_group_add_widget (group, widget); -} - -static void -fill_connection (WirelessSecurity *parent, NMConnection *connection) -{ - WirelessSecuritySAE *sae = (WirelessSecuritySAE *) parent; - GtkWidget *widget, *passwd_entry; - const char *key; - NMSettingWireless *s_wireless; - NMSettingWirelessSecurity *s_wireless_sec; - NMSettingSecretFlags secret_flags; - const char *mode; - gboolean is_adhoc = FALSE; - - s_wireless = nm_connection_get_setting_wireless (connection); - g_assert (s_wireless); - - mode = nm_setting_wireless_get_mode (s_wireless); - if (mode && !strcmp (mode, "adhoc")) - is_adhoc = TRUE; - - /* Blow away the old security setting by adding a clear one */ - s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "psk_entry")); - passwd_entry = widget; - key = gtk_entry_get_text (GTK_ENTRY (widget)); - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL); - - /* Save PSK_FLAGS to the connection */ - secret_flags = nma_utils_menu_to_secret_flags (passwd_entry); - nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), NM_SETTING_WIRELESS_SECURITY_PSK, - secret_flags, NULL); - - /* Update secret flags and popup when editing the connection */ - if (sae->editing_connection) - nma_utils_update_password_storage (passwd_entry, secret_flags, - NM_SETTING (s_wireless_sec), sae->password_flags_name); - - wireless_security_clear_ciphers (connection); - if (is_adhoc) { - /* Ad-Hoc settings as specified by the supplicant */ - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "sae", NULL); - nm_setting_wireless_security_add_proto (s_wireless_sec, "rsn"); - nm_setting_wireless_security_add_pairwise (s_wireless_sec, "ccmp"); - nm_setting_wireless_security_add_group (s_wireless_sec, "ccmp"); - } else { - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "sae", NULL); - - /* Just leave ciphers and protocol empty, the supplicant will - * figure that out magically based on the AP IEs and card capabilities. - */ - } -} - -static void -update_secrets (WirelessSecurity *parent, NMConnection *connection) -{ - helper_fill_secret_entry (connection, - parent->builder, - "psk_entry", - NM_TYPE_SETTING_WIRELESS_SECURITY, - (HelperSecretFunc) nm_setting_wireless_security_get_psk); -} - -WirelessSecuritySAE * -ws_sae_new (NMConnection *connection, gboolean secrets_only) -{ - WirelessSecurity *parent; - WirelessSecuritySAE *sec; - NMSetting *setting = NULL; - GtkWidget *widget; - - parent = wireless_security_init (sizeof (WirelessSecuritySAE), - validate, - add_to_size_group, - fill_connection, - update_secrets, - NULL, - "/org/freedesktop/network-manager-applet/ws-sae.ui", - "sae_notebook", - "psk_entry"); - if (!parent) - return NULL; - - parent->adhoc_compatible = TRUE; - sec = (WirelessSecuritySAE *) parent; - sec->editing_connection = secrets_only ? FALSE : TRUE; - sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "psk_entry")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - sec); - gtk_entry_set_width_chars (GTK_ENTRY (widget), 28); - - /* Create password-storage popup menu for password entry under entry's secondary icon */ - if (connection) - setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection); - nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name, - FALSE, secrets_only); - - /* Fill secrets, if any */ - if (connection) - update_secrets (WIRELESS_SECURITY (sec), connection); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_sae")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) show_toggled_cb, - sec); - - /* Hide WPA/RSN for now since this can be autodetected by NM and the - * supplicant when connecting to the AP. - */ - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "sae_type_combo")); - g_assert (widget); - gtk_widget_hide (widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "sae_type_label")); - g_assert (widget); - gtk_widget_hide (widget); - - return sec; -} - diff --git a/src/wireless-security/ws-sae.h b/src/wireless-security/ws-sae.h deleted file mode 100644 index e864d90d..00000000 --- a/src/wireless-security/ws-sae.h +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2007 - 2019 Red Hat, Inc. - */ - -#ifndef WS_SAE_H -#define WS_SAE_H - -/* For compatibility with NetworkManager-1.20 and earlier. */ -#define NMU_SEC_SAE 9 - -typedef struct _WirelessSecuritySAE WirelessSecuritySAE; - -WirelessSecuritySAE * ws_sae_new (NMConnection *connection, gboolean secrets_only); - -#endif /* WS_SAE_H */ diff --git a/src/wireless-security/ws-sae.ui b/src/wireless-security/ws-sae.ui deleted file mode 100644 index 8f0d0413..00000000 --- a/src/wireless-security/ws-sae.ui +++ /dev/null @@ -1,98 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkNotebook" id="sae_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="sae_table"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="sae_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Password</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">psk_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="psk_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="max_length">64</property> - <property name="visibility">False</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="sae_type_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Type</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">sae_type_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="show_checkbutton_sae"> - <property name="label" translatable="yes">Sho_w password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="sae_type_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="GtkLabel2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c deleted file mode 100644 index caedfa5f..00000000 --- a/src/wireless-security/ws-wep-key.c +++ /dev/null @@ -1,354 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <string.h> - -#include "wireless-security.h" -#include "utils.h" -#include "helpers.h" -#include "nma-ui-utils.h" - -struct _WirelessSecurityWEPKey { - WirelessSecurity parent; - - gboolean editing_connection; - const char *password_flags_name; - - NMWepKeyType type; - char keys[4][65]; - guint8 cur_index; -}; - -static void -show_toggled_cb (GtkCheckButton *button, WirelessSecurity *sec) -{ - GtkWidget *widget; - gboolean visible; - - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "wep_key_entry")); - g_assert (widget); - - visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - gtk_entry_set_visibility (GTK_ENTRY (widget), visible); -} - -static void -key_index_combo_changed_cb (GtkWidget *combo, WirelessSecurity *parent) -{ - WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent; - GtkWidget *entry; - const char *key; - int key_index; - - /* Save WEP key for old key index */ - entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry")); - key = gtk_entry_get_text (GTK_ENTRY (entry)); - if (key) - g_strlcpy (sec->keys[sec->cur_index], key, sizeof (sec->keys[sec->cur_index])); - else - memset (sec->keys[sec->cur_index], 0, sizeof (sec->keys[sec->cur_index])); - - key_index = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)); - g_return_if_fail (key_index <= 3); - g_return_if_fail (key_index >= 0); - - /* Populate entry with key from new index */ - gtk_entry_set_text (GTK_ENTRY (entry), sec->keys[key_index]); - sec->cur_index = key_index; - - wireless_security_changed_cb (combo, parent); -} - -static void -destroy (WirelessSecurity *parent) -{ - WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent; - int i; - - for (i = 0; i < 4; i++) - memset (sec->keys[i], 0, sizeof (sec->keys[i])); -} - -static gboolean -validate (WirelessSecurity *parent, GError **error) -{ - WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent; - NMSettingSecretFlags secret_flags; - GtkWidget *entry; - const char *key; - int i; - - entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry")); - g_assert (entry); - - secret_flags = nma_utils_menu_to_secret_flags (entry); - key = gtk_entry_get_text (GTK_ENTRY (entry)); - - if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED - || secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) { - /* All good. */ - } else if (!key) { - widget_set_error (entry); - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing wep-key")); - return FALSE; - } else if (sec->type == NM_WEP_KEY_TYPE_KEY) { - if ((strlen (key) == 10) || (strlen (key) == 26)) { - for (i = 0; i < strlen (key); i++) { - if (!g_ascii_isxdigit (key[i])) { - widget_set_error (entry); - g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key: key with a length of %zu must contain only hex-digits"), strlen (key)); - return FALSE; - } - } - } else if ((strlen (key) == 5) || (strlen (key) == 13)) { - for (i = 0; i < strlen (key); i++) { - if (!utils_char_is_ascii_print (key[i])) { - widget_set_error (entry); - g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key: key with a length of %zu must contain only ascii characters"), strlen (key)); - return FALSE; - } - } - } else { - widget_set_error (entry); - g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key: wrong key length %zu. A key must be either of length 5/13 (ascii) or 10/26 (hex)"), strlen (key)); - return FALSE; - } - } else if (sec->type == NM_WEP_KEY_TYPE_PASSPHRASE) { - if (!*key || (strlen (key) > 64)) { - widget_set_error (entry); - if (!*key) - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key: passphrase must be non-empty")); - else - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key: passphrase must be shorter than 64 characters")); - return FALSE; - } - } - widget_unset_error (entry); - - return TRUE; -} - -static void -add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) -{ - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_label")); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_label")); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_label")); - gtk_size_group_add_widget (group, widget); -} - -static void -fill_connection (WirelessSecurity *parent, NMConnection *connection) -{ - WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent; - NMSettingWirelessSecurity *s_wsec; - NMSettingSecretFlags secret_flags; - GtkWidget *widget, *passwd_entry; - gint auth_alg; - const char *key; - int i; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_combo")); - auth_alg = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry")); - passwd_entry = widget; - key = gtk_entry_get_text (GTK_ENTRY (widget)); - g_strlcpy (sec->keys[sec->cur_index], key, sizeof (sec->keys[sec->cur_index])); - - /* Blow away the old security setting by adding a clear one */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, (NMSetting *) s_wsec); - - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", - NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, sec->cur_index, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, (auth_alg == 1) ? "shared" : "open", - NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, sec->type, - NULL); - - for (i = 0; i < 4; i++) { - if (strlen (sec->keys[i])) - nm_setting_wireless_security_set_wep_key (s_wsec, i, sec->keys[i]); - } - - /* Save WEP_KEY_FLAGS to the connection */ - secret_flags = nma_utils_menu_to_secret_flags (passwd_entry); - g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, secret_flags, NULL); - - /* Update secret flags and popup when editing the connection */ - if (sec->editing_connection) - nma_utils_update_password_storage (passwd_entry, secret_flags, - NM_SETTING (s_wsec), sec->password_flags_name); -} - -static void -wep_entry_filter_cb (GtkEditable *editable, - gchar *text, - gint length, - gint *position, - gpointer data) -{ - WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) data; - - if (sec->type == NM_WEP_KEY_TYPE_KEY) { - utils_filter_editable_on_insert_text (editable, - text, length, position, data, - utils_char_is_ascii_print, - wep_entry_filter_cb); - } -} - -static void -update_secrets (WirelessSecurity *parent, NMConnection *connection) -{ - WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent; - NMSettingWirelessSecurity *s_wsec; - GtkWidget *widget; - const char *tmp; - int i; - - s_wsec = nm_connection_get_setting_wireless_security (connection); - for (i = 0; s_wsec && i < 4; i++) { - tmp = nm_setting_wireless_security_get_wep_key (s_wsec, i); - if (tmp) - g_strlcpy (sec->keys[i], tmp, sizeof (sec->keys[i])); - } - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry")); - if (strlen (sec->keys[sec->cur_index])) - gtk_entry_set_text (GTK_ENTRY (widget), sec->keys[sec->cur_index]); -} - -WirelessSecurityWEPKey * -ws_wep_key_new (NMConnection *connection, - NMWepKeyType type, - gboolean adhoc_create, - gboolean secrets_only) -{ - WirelessSecurity *parent; - WirelessSecurityWEPKey *sec; - GtkWidget *widget; - NMSettingWirelessSecurity *s_wsec = NULL; - NMSetting *setting = NULL; - guint8 default_key_idx = 0; - gboolean is_adhoc = adhoc_create; - gboolean is_shared_key = FALSE; - - parent = wireless_security_init (sizeof (WirelessSecurityWEPKey), - validate, - add_to_size_group, - fill_connection, - update_secrets, - destroy, - "/org/freedesktop/network-manager-applet/ws-wep-key.ui", - "wep_key_notebook", - "wep_key_entry"); - if (!parent) - return NULL; - - sec = (WirelessSecurityWEPKey *) parent; - sec->editing_connection = secrets_only ? FALSE : TRUE; - sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_WEP_KEY0; - sec->type = type; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry")); - g_assert (widget); - gtk_entry_set_width_chars (GTK_ENTRY (widget), 28); - - /* Create password-storage popup menu for password entry under entry's secondary icon */ - if (connection) - setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection); - nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name, - FALSE, secrets_only); - - if (connection) { - NMSettingWireless *s_wireless; - const char *mode, *auth_alg; - - s_wireless = nm_connection_get_setting_wireless (connection); - mode = s_wireless ? nm_setting_wireless_get_mode (s_wireless) : NULL; - if (mode && !strcmp (mode, "adhoc")) - is_adhoc = TRUE; - - s_wsec = nm_connection_get_setting_wireless_security (connection); - if (s_wsec) { - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - if (auth_alg && !strcmp (auth_alg, "shared")) - is_shared_key = TRUE; - } - } - - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - sec); - g_signal_connect (G_OBJECT (widget), "insert-text", - (GCallback) wep_entry_filter_cb, - sec); - if (sec->type == NM_WEP_KEY_TYPE_KEY) - gtk_entry_set_max_length (GTK_ENTRY (widget), 26); - else if (sec->type == NM_WEP_KEY_TYPE_PASSPHRASE) - gtk_entry_set_max_length (GTK_ENTRY (widget), 64); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_combo")); - if (connection && s_wsec) - default_key_idx = nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec); - - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), default_key_idx); - sec->cur_index = default_key_idx; - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) key_index_combo_changed_cb, - sec); - - /* Key index is useless with adhoc networks */ - if (is_adhoc || secrets_only) { - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_label")); - gtk_widget_hide (widget); - } - - /* Fill the key entry with the key for that index */ - if (connection) - update_secrets (WIRELESS_SECURITY (sec), connection); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_wep")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) show_toggled_cb, - sec); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_combo")); - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), is_shared_key ? 1 : 0); - - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - sec); - - /* Don't show auth method for adhoc (which always uses open-system) or - * when in "simple" mode. - */ - if (is_adhoc || secrets_only) { - /* Ad-Hoc connections can't use Shared Key auth */ - if (is_adhoc) - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); - gtk_widget_hide (widget); - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_label")); - gtk_widget_hide (widget); - } - - return sec; -} - diff --git a/src/wireless-security/ws-wep-key.h b/src/wireless-security/ws-wep-key.h deleted file mode 100644 index cd82e453..00000000 --- a/src/wireless-security/ws-wep-key.h +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#ifndef WS_WEP_KEY_H -#define WS_WEP_KEY_H - -typedef struct _WirelessSecurityWEPKey WirelessSecurityWEPKey; - -WirelessSecurityWEPKey *ws_wep_key_new (NMConnection *connection, - NMWepKeyType type, - gboolean adhoc_create, - gboolean secrets_only); - -#endif /* WS_WEP_KEY_H */ diff --git a/src/wireless-security/ws-wep-key.ui b/src/wireless-security/ws-wep-key.ui deleted file mode 100644 index 44ccd180..00000000 --- a/src/wireless-security/ws-wep-key.ui +++ /dev/null @@ -1,172 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkListStore" id="model3"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">Open System</col> - </row> - <row> - <col id="0" translatable="yes">Shared Key</col> - </row> - </data> - </object> - <object class="GtkListStore" id="model4"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">1 (Default)</col> - </row> - <row> - <col id="0">2</col> - </row> - <row> - <col id="0">3</col> - </row> - <row> - <col id="0">4</col> - </row> - </data> - </object> - <object class="GtkNotebook" id="wep_key_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="table6"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="wep_key_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Key</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">wep_key_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="wep_key_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="max_length">64</property> - <property name="visibility">False</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="show_checkbutton_wep"> - <property name="label" translatable="yes">Sho_w key</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="auth_method_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Au_thentication</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">auth_method_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="auth_method_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="model">model3</property> - <child> - <object class="GtkCellRendererText" id="renderer3"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="key_index_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">WEP inde_x</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">key_index_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="key_index_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="model">model4</property> - <child> - <object class="GtkCellRendererText" id="renderer4"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="label23"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/ws-wpa-eap.c b/src/wireless-security/ws-wpa-eap.c deleted file mode 100644 index 21f04f6f..00000000 --- a/src/wireless-security/ws-wpa-eap.c +++ /dev/null @@ -1,121 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "wireless-security.h" -#include "eap-method.h" - -struct _WirelessSecurityWPAEAP { - WirelessSecurity parent; - - GtkSizeGroup *size_group; -}; - - -static void -destroy (WirelessSecurity *parent) -{ - WirelessSecurityWPAEAP *sec = (WirelessSecurityWPAEAP *) parent; - - if (sec->size_group) - g_object_unref (sec->size_group); -} - -static gboolean -validate (WirelessSecurity *parent, GError **error) -{ - return ws_802_1x_validate (parent, "wpa_eap_auth_combo", error); -} - -static void -add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) -{ - WirelessSecurityWPAEAP *sec = (WirelessSecurityWPAEAP *) parent; - - if (sec->size_group) - g_object_unref (sec->size_group); - sec->size_group = g_object_ref (group); - - ws_802_1x_add_to_size_group (parent, - sec->size_group, - "wpa_eap_auth_label", - "wpa_eap_auth_combo"); -} - -static void -fill_connection (WirelessSecurity *parent, NMConnection *connection) -{ - NMSettingWirelessSecurity *s_wireless_sec; - - ws_802_1x_fill_connection (parent, "wpa_eap_auth_combo", connection); - - s_wireless_sec = nm_connection_get_setting_wireless_security (connection); - g_assert (s_wireless_sec); - - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL); -} - -static void -auth_combo_changed_cb (GtkWidget *combo, gpointer user_data) -{ - WirelessSecurity *parent = WIRELESS_SECURITY (user_data); - WirelessSecurityWPAEAP *sec = (WirelessSecurityWPAEAP *) parent; - - ws_802_1x_auth_combo_changed (combo, - parent, - "wpa_eap_method_vbox", - sec->size_group); -} - -static void -update_secrets (WirelessSecurity *parent, NMConnection *connection) -{ - ws_802_1x_update_secrets (parent, "wpa_eap_auth_combo", connection); -} - -WirelessSecurityWPAEAP * -ws_wpa_eap_new (NMConnection *connection, - gboolean is_editor, - gboolean secrets_only, - const char *const*secrets_hints) -{ - WirelessSecurity *parent; - GtkWidget *widget; - - parent = wireless_security_init (sizeof (WirelessSecurityWPAEAP), - validate, - add_to_size_group, - fill_connection, - update_secrets, - destroy, - "/org/freedesktop/network-manager-applet/ws-wpa-eap.ui", - "wpa_eap_notebook", - NULL); - if (!parent) - return NULL; - - parent->adhoc_compatible = FALSE; - parent->hotspot_compatible = FALSE; - - widget = ws_802_1x_auth_combo_init (parent, - "wpa_eap_auth_combo", - "wpa_eap_auth_label", - (GCallback) auth_combo_changed_cb, - connection, - is_editor, - secrets_only, - secrets_hints); - auth_combo_changed_cb (widget, parent); - - return (WirelessSecurityWPAEAP *) parent; -} - diff --git a/src/wireless-security/ws-wpa-eap.h b/src/wireless-security/ws-wpa-eap.h deleted file mode 100644 index 755188e3..00000000 --- a/src/wireless-security/ws-wpa-eap.h +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#ifndef WS_WPA_EAP_H -#define WS_WPA_EAP_H - -typedef struct _WirelessSecurityWPAEAP WirelessSecurityWPAEAP; - -WirelessSecurityWPAEAP * ws_wpa_eap_new (NMConnection *connection, - gboolean is_editor, - gboolean secrets_only, - const char *const*secrets_hints); - -#endif /* WS_WPA_EAP_H */ diff --git a/src/wireless-security/ws-wpa-eap.ui b/src/wireless-security/ws-wpa-eap.ui deleted file mode 100644 index 383b136f..00000000 --- a/src/wireless-security/ws-wpa-eap.ui +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkListStore" id="model5"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0"> </col> - </row> - </data> - </object> - <object class="GtkNotebook" id="wpa_eap_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="wpa_eap_table"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="wpa_eap_auth_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Au_thentication</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">wpa_eap_auth_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="wpa_eap_auth_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="model">model5</property> - <child> - <object class="GtkCellRendererText" id="renderer5"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkBox" id="wpa_eap_method_vbox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="orientation">vertical</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">2</property> - </packing> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="GtkLabel3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/ws-wpa-psk.c b/src/wireless-security/ws-wpa-psk.c deleted file mode 100644 index eba22a79..00000000 --- a/src/wireless-security/ws-wpa-psk.c +++ /dev/null @@ -1,219 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <ctype.h> -#include <string.h> - -#include "wireless-security.h" -#include "helpers.h" -#include "nma-ui-utils.h" -#include "utils.h" - -#define WPA_PMK_LEN 32 - -struct _WirelessSecurityWPAPSK { - WirelessSecurity parent; - - gboolean editing_connection; - const char *password_flags_name; -}; - -static void -show_toggled_cb (GtkCheckButton *button, WirelessSecurity *sec) -{ - GtkWidget *widget; - gboolean visible; - - widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "wpa_psk_entry")); - g_assert (widget); - - visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - gtk_entry_set_visibility (GTK_ENTRY (widget), visible); -} - -static gboolean -validate (WirelessSecurity *parent, GError **error) -{ - GtkWidget *entry; - NMSettingSecretFlags secret_flags; - const char *key; - gsize len; - int i; - - entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_entry")); - g_assert (entry); - - secret_flags = nma_utils_menu_to_secret_flags (entry); - key = gtk_entry_get_text (GTK_ENTRY (entry)); - len = key ? strlen (key) : 0; - - if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED - || secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) { - /* All good. */ - } else if ((len < 8) || (len > 64)) { - widget_set_error (entry); - g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wpa-psk: invalid key-length %zu. Must be [8,63] bytes or 64 hex digits"), len); - return FALSE; - } else if (len == 64) { - /* Hex PSK */ - for (i = 0; i < len; i++) { - if (!isxdigit (key[i])) { - widget_set_error (entry); - g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wpa-psk: cannot interpret key with 64 bytes as hex")); - return FALSE; - } - } - } - widget_unset_error (entry); - - /* passphrase can be between 8 and 63 characters inclusive */ - - return TRUE; -} - -static void -add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) -{ - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_type_label")); - gtk_size_group_add_widget (group, widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_label")); - gtk_size_group_add_widget (group, widget); -} - -static void -fill_connection (WirelessSecurity *parent, NMConnection *connection) -{ - WirelessSecurityWPAPSK *wpa_psk = (WirelessSecurityWPAPSK *) parent; - GtkWidget *widget, *passwd_entry; - const char *key; - NMSettingWireless *s_wireless; - NMSettingWirelessSecurity *s_wireless_sec; - NMSettingSecretFlags secret_flags; - const char *mode; - gboolean is_adhoc = FALSE; - - s_wireless = nm_connection_get_setting_wireless (connection); - g_assert (s_wireless); - - mode = nm_setting_wireless_get_mode (s_wireless); - if (mode && !strcmp (mode, "adhoc")) - is_adhoc = TRUE; - - /* Blow away the old security setting by adding a clear one */ - s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_entry")); - passwd_entry = widget; - key = gtk_entry_get_text (GTK_ENTRY (widget)); - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL); - - /* Save PSK_FLAGS to the connection */ - secret_flags = nma_utils_menu_to_secret_flags (passwd_entry); - nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), NM_SETTING_WIRELESS_SECURITY_PSK, - secret_flags, NULL); - - /* Update secret flags and popup when editing the connection */ - if (wpa_psk->editing_connection) - nma_utils_update_password_storage (passwd_entry, secret_flags, - NM_SETTING (s_wireless_sec), wpa_psk->password_flags_name); - - wireless_security_clear_ciphers (connection); - if (is_adhoc) { - /* Ad-Hoc settings as specified by the supplicant */ - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL); - nm_setting_wireless_security_add_proto (s_wireless_sec, "rsn"); - nm_setting_wireless_security_add_pairwise (s_wireless_sec, "ccmp"); - nm_setting_wireless_security_add_group (s_wireless_sec, "ccmp"); - } else { - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL); - - /* Just leave ciphers and protocol empty, the supplicant will - * figure that out magically based on the AP IEs and card capabilities. - */ - } -} - -static void -update_secrets (WirelessSecurity *parent, NMConnection *connection) -{ - helper_fill_secret_entry (connection, - parent->builder, - "wpa_psk_entry", - NM_TYPE_SETTING_WIRELESS_SECURITY, - (HelperSecretFunc) nm_setting_wireless_security_get_psk); -} - -WirelessSecurityWPAPSK * -ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only) -{ - WirelessSecurity *parent; - WirelessSecurityWPAPSK *sec; - NMSetting *setting = NULL; - GtkWidget *widget; - - parent = wireless_security_init (sizeof (WirelessSecurityWPAPSK), - validate, - add_to_size_group, - fill_connection, - update_secrets, - NULL, - "/org/freedesktop/network-manager-applet/ws-wpa-psk.ui", - "wpa_psk_notebook", - "wpa_psk_entry"); - if (!parent) - return NULL; - - parent->adhoc_compatible = TRUE; - sec = (WirelessSecurityWPAPSK *) parent; - sec->editing_connection = secrets_only ? FALSE : TRUE; - sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK; - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_entry")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "changed", - (GCallback) wireless_security_changed_cb, - sec); - gtk_entry_set_width_chars (GTK_ENTRY (widget), 28); - - /* Create password-storage popup menu for password entry under entry's secondary icon */ - if (connection) - setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection); - nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name, - FALSE, secrets_only); - - /* Fill secrets, if any */ - if (connection) - update_secrets (WIRELESS_SECURITY (sec), connection); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_wpa")); - g_assert (widget); - g_signal_connect (G_OBJECT (widget), "toggled", - (GCallback) show_toggled_cb, - sec); - - /* Hide WPA/RSN for now since this can be autodetected by NM and the - * supplicant when connecting to the AP. - */ - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_type_combo")); - g_assert (widget); - gtk_widget_hide (widget); - - widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_type_label")); - g_assert (widget); - gtk_widget_hide (widget); - - return sec; -} - diff --git a/src/wireless-security/ws-wpa-psk.h b/src/wireless-security/ws-wpa-psk.h deleted file mode 100644 index 4ad01030..00000000 --- a/src/wireless-security/ws-wpa-psk.h +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* NetworkManager Applet -- allow user control over networking - * - * Dan Williams <dcbw@redhat.com> - * - * Copyright 2007 - 2014 Red Hat, Inc. - */ - -#ifndef WS_WPA_PSK_H -#define WS_WPA_PSK_H - -typedef struct _WirelessSecurityWPAPSK WirelessSecurityWPAPSK; - -WirelessSecurityWPAPSK * ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only); - -#endif /* WS_WEP_KEY_H */ diff --git a/src/wireless-security/ws-wpa-psk.ui b/src/wireless-security/ws-wpa-psk.ui deleted file mode 100644 index ace15468..00000000 --- a/src/wireless-security/ws-wpa-psk.ui +++ /dev/null @@ -1,98 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface domain="nm-applet"> - <requires lib="gtk+" version="3.10"/> - <object class="GtkNotebook" id="wpa_psk_notebook"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <child> - <object class="GtkGrid" id="wpa_psk_table"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="wpa_psk_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Password</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">wpa_psk_entry</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="wpa_psk_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="max_length">64</property> - <property name="visibility">False</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="wpa_psk_type_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Type</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">wpa_psk_type_combo</property> - <property name="xalign">1</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="show_checkbutton_wpa"> - <property name="label" translatable="yes">Sho_w password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="wpa_psk_type_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="GtkLabel2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - </object> -</interface> diff --git a/src/wireless-security/ws.gresource.xml b/src/wireless-security/ws.gresource.xml deleted file mode 100644 index 5af6115d..00000000 --- a/src/wireless-security/ws.gresource.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<gresources> - <gresource prefix="/org/freedesktop/network-manager-applet"> - <file preprocess="xml-stripblanks">ws-dynamic-wep.ui</file> - <file preprocess="xml-stripblanks">ws-leap.ui</file> - <file preprocess="xml-stripblanks">ws-sae.ui</file> - <file preprocess="xml-stripblanks">ws-wep-key.ui</file> - <file preprocess="xml-stripblanks">ws-wpa-eap.ui</file> - <file preprocess="xml-stripblanks">ws-wpa-psk.ui</file> - <file preprocess="xml-stripblanks">eap-method-fast.ui</file> - <file preprocess="xml-stripblanks">eap-method-leap.ui</file> - <file preprocess="xml-stripblanks">eap-method-peap.ui</file> - <file preprocess="xml-stripblanks">eap-method-simple.ui</file> - <file preprocess="xml-stripblanks">eap-method-tls.ui</file> - <file preprocess="xml-stripblanks">eap-method-ttls.ui</file> - </gresource> -</gresources> |