diff options
author | Andrew Zaborowski <andrew.zaborowski@intel.com> | 2018-09-03 06:25:39 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-11-26 15:05:52 +0100 |
commit | 89331ca0f8632b4ccad918db36ff949eb09369e0 (patch) | |
tree | 7aab4ceffc34fe90863b660ce5b065f18a994036 | |
parent | 755cc5647f4ee1bb90db6fa884ff1e7105c2d321 (diff) | |
download | network-manager-applet-89331ca0f8632b4ccad918db36ff949eb09369e0.tar.gz |
all: pass 'hints' from secret agent to ws_wpa_eap_new
The secret agent requests contain two parameters that aren't currently
used when handling Wifi network connections: the setting name and hints.
Those parameters turned out useful with 802.1X / EAP authentication with
NM's IWD backend where it passes a specific 802_1x setting key name that
is being requested in the 'hints' array, one of: identity, password or
private_key_password.
nmcli already gained support for handling such agent requests in
1a6e53808db8bb8e75317fd5feacd74a9a98860f (which was obviously much
easier) so this is an attempt to let the src/wireless-security/* classes
in nm-applet also handle these requests as intended.
A new libnma function nma_wifi_dialog_new_for_secrets is added to
receive the values from setting name and hints without changing existing
API.
-rw-r--r-- | src/applet-device-wifi.c | 5 | ||||
-rw-r--r-- | src/connection-editor/page-8021x-security.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-wifi-security.c | 2 | ||||
-rw-r--r-- | src/ethernet-dialog.c | 2 | ||||
-rw-r--r-- | src/libnm-gtk/nm-wifi-dialog.c | 2 | ||||
-rw-r--r-- | src/libnma/libnma.ver | 4 | ||||
-rw-r--r-- | src/libnma/nma-wifi-dialog.c | 126 | ||||
-rw-r--r-- | src/libnma/nma-wifi-dialog.h | 5 | ||||
-rw-r--r-- | src/wireless-security/ws-wpa-eap.c | 3 | ||||
-rw-r--r-- | src/wireless-security/ws-wpa-eap.h | 3 |
10 files changed, 126 insertions, 28 deletions
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c index d8a31a04..a95d1f52 100644 --- a/src/applet-device-wifi.c +++ b/src/applet-device-wifi.c @@ -1643,7 +1643,10 @@ wifi_get_secrets (SecretsRequest *req, GError **error) g_return_val_if_fail (!info->dialog, FALSE); - info->dialog = nma_wifi_dialog_new (req->applet->nm_client, req->connection, NULL, NULL, TRUE); + info->dialog = nma_wifi_dialog_new_for_secrets (req->applet->nm_client, + req->connection, + req->setting_name, + (const char *const*) req->hints); if (info->dialog) { applet_secrets_request_set_free_func (req, free_wifi_info); g_signal_connect (info->dialog, "response", diff --git a/src/connection-editor/page-8021x-security.c b/src/connection-editor/page-8021x-security.c index bbe614bb..b0489ca9 100644 --- a/src/connection-editor/page-8021x-security.c +++ b/src/connection-editor/page-8021x-security.c @@ -68,7 +68,7 @@ finish_setup (CEPage8021xSecurity *self, gpointer user_data) CEPage8021xSecurityPrivate *priv = CE_PAGE_8021X_SECURITY_GET_PRIVATE (self); GtkWidget *parent_container; - priv->security = (WirelessSecurity *) ws_wpa_eap_new (parent->connection, TRUE, FALSE); + priv->security = (WirelessSecurity *) ws_wpa_eap_new (parent->connection, TRUE, FALSE, NULL); if (!priv->security) { g_warning ("Could not load 802.1X user interface."); return; diff --git a/src/connection-editor/page-wifi-security.c b/src/connection-editor/page-wifi-security.c index 701126e4..e53588c4 100644 --- a/src/connection-editor/page-wifi-security.c +++ b/src/connection-editor/page-wifi-security.c @@ -411,7 +411,7 @@ finish_setup (CEPageWifiSecurity *self, gpointer user_data) if (security_valid (NMU_SEC_WPA_ENTERPRISE, mode) || security_valid (NMU_SEC_WPA2_ENTERPRISE, mode)) { WirelessSecurityWPAEAP *ws_wpa_eap; - ws_wpa_eap = ws_wpa_eap_new (connection, TRUE, FALSE); + ws_wpa_eap = ws_wpa_eap_new (connection, TRUE, FALSE, NULL); if (ws_wpa_eap) { add_security_item (self, WIRELESS_SECURITY (ws_wpa_eap), sec_model, &iter, _("WPA & WPA2 Enterprise"), FALSE, FALSE); diff --git a/src/ethernet-dialog.c b/src/ethernet-dialog.c index 2f7275a1..255feed1 100644 --- a/src/ethernet-dialog.c +++ b/src/ethernet-dialog.c @@ -57,7 +57,7 @@ dialog_set_security (NMConnection *connection, GList *iter; WirelessSecurity *security; - security = (WirelessSecurity *) ws_wpa_eap_new (connection, FALSE, TRUE); + security = (WirelessSecurity *) ws_wpa_eap_new (connection, FALSE, TRUE, NULL); /* Remove any previous wireless security widgets */ children = gtk_container_get_children (GTK_CONTAINER (box)); diff --git a/src/libnm-gtk/nm-wifi-dialog.c b/src/libnm-gtk/nm-wifi-dialog.c index 71c5bd31..8b45a3ad 100644 --- a/src/libnm-gtk/nm-wifi-dialog.c +++ b/src/libnm-gtk/nm-wifi-dialog.c @@ -983,7 +983,7 @@ security_combo_init (NMAWifiDialog *self, gboolean secrets_only) || nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, !!priv->ap, is_adhoc, ap_flags, ap_wpa, ap_rsn)) { WirelessSecurityWPAEAP *ws_wpa_eap; - ws_wpa_eap = ws_wpa_eap_new (priv->connection, FALSE, secrets_only); + ws_wpa_eap = ws_wpa_eap_new (priv->connection, FALSE, secrets_only, NULL); if (ws_wpa_eap) { add_security_item (self, WIRELESS_SECURITY (ws_wpa_eap), sec_model, &iter, _("WPA & WPA2 Enterprise")); diff --git a/src/libnma/libnma.ver b/src/libnma/libnma.ver index 2f6a1b64..d5fe734a 100644 --- a/src/libnma/libnma.ver +++ b/src/libnma/libnma.ver @@ -99,3 +99,7 @@ global: libnma_1_8_12 { nma_mobile_wizard_get_type; } libnma_1_8_0; + +libnma_1_8_20 { + nma_wifi_dialog_new_for_secrets; +} libnma_1_8_12; diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c index 2288ae2b..c4dca8f1 100644 --- a/src/libnma/nma-wifi-dialog.c +++ b/src/libnma/nma-wifi-dialog.c @@ -85,7 +85,9 @@ enum { #define C_SEP_COLUMN 2 #define C_NEW_COLUMN 3 -static gboolean security_combo_init (NMAWifiDialog *self, gboolean secrets_only); +static gboolean security_combo_init (NMAWifiDialog *self, gboolean secrets_only, + const char *secrets_setting_name, + const char *const*secrets_hints); static void ssid_entry_changed (GtkWidget *entry, gpointer user_data); void @@ -363,7 +365,7 @@ connection_combo_changed (GtkWidget *combo, if (priv->connection) eap_method_ca_cert_ignore_load (priv->connection); - if (!security_combo_init (self, priv->secrets_only)) { + if (!security_combo_init (self, priv->secrets_only, NULL, NULL)) { g_warning ("Couldn't change Wi-Fi security combo box."); return; } @@ -574,7 +576,7 @@ device_combo_changed (GtkWidget *combo, return; } - if (!security_combo_init (self, priv->secrets_only)) { + if (!security_combo_init (self, priv->secrets_only, NULL, NULL)) { g_warning ("Couldn't change Wi-Fi security combo box."); return; } @@ -824,7 +826,8 @@ out: } static gboolean -security_combo_init (NMAWifiDialog *self, gboolean secrets_only) +security_combo_init (NMAWifiDialog *self, gboolean secrets_only, + const char *secrets_setting_name, const char *const*secrets_hints) { NMAWifiDialogPrivate *priv; GtkListStore *sec_model; @@ -853,7 +856,8 @@ security_combo_init (NMAWifiDialog *self, gboolean secrets_only) /* The security options displayed are filtered based on device * capabilities, and if provided, additionally by access point capabilities. * If a connection is given, that connection's options should be selected - * by default. + * by default. If hints is non-empty only filter based on the setting + * keys on the hints list. */ dev_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (priv->device)); if (priv->ap != NULL) { @@ -970,8 +974,12 @@ security_combo_init (NMAWifiDialog *self, gboolean secrets_only) if ( nm_utils_security_valid (NMU_SEC_WPA_ENTERPRISE, dev_caps, !!priv->ap, is_adhoc, ap_flags, ap_wpa, ap_rsn) || nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, !!priv->ap, is_adhoc, ap_flags, ap_wpa, ap_rsn)) { WirelessSecurityWPAEAP *ws_wpa_eap; + const char *const*hints = NULL; - ws_wpa_eap = ws_wpa_eap_new (priv->connection, FALSE, secrets_only); + if (secrets_setting_name && !strcmp (secrets_setting_name, NM_SETTING_802_1X_SETTING_NAME)) + hints = secrets_hints; + + ws_wpa_eap = ws_wpa_eap_new (priv->connection, FALSE, secrets_only, hints); if (ws_wpa_eap) { add_security_item (self, WIRELESS_SECURITY (ws_wpa_eap), sec_model, &iter, _("WPA & WPA2 Enterprise")); @@ -1026,7 +1034,9 @@ static gboolean internal_init (NMAWifiDialog *self, NMConnection *specific_connection, NMDevice *specific_device, - gboolean secrets_only) + gboolean secrets_only, + const char *secrets_setting_name, + const char *const*secrets_hints) { NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self); GtkWidget *widget; @@ -1098,7 +1108,7 @@ internal_init (NMAWifiDialog *self, return FALSE; } - if (!security_combo_init (self, priv->secrets_only)) { + if (!security_combo_init (self, priv->secrets_only, secrets_setting_name, secrets_hints)) { g_warning ("Couldn't set up Wi-Fi security combo box."); return FALSE; } @@ -1256,27 +1266,21 @@ nma_wifi_dialog_get_connection (NMAWifiDialog *self, return connection; } -GtkWidget * -nma_wifi_dialog_new (NMClient *client, +static GtkWidget * +internal_new_dialog (NMClient *client, NMConnection *connection, NMDevice *device, NMAccessPoint *ap, - gboolean secrets_only) + gboolean secrets_only, + const char *secrets_setting_name, + const char *const*secrets_hints) { NMAWifiDialog *self; NMAWifiDialogPrivate *priv; - guint32 dev_caps; g_return_val_if_fail (NM_IS_CLIENT (client), NULL); g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); - /* Ensure device validity */ - if (device) { - dev_caps = nm_device_get_capabilities (device); - g_return_val_if_fail (dev_caps & NM_DEVICE_CAP_NM_SUPPORTED, NULL); - g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); - } - self = NMA_WIFI_DIALOG (g_object_new (NMA_TYPE_WIFI_DIALOG, NULL)); if (self) { priv = NMA_WIFI_DIALOG_GET_PRIVATE (self); @@ -1291,7 +1295,7 @@ nma_wifi_dialog_new (NMClient *client, /* Handle CA cert ignore stuff */ eap_method_ca_cert_ignore_load (connection); - if (!internal_init (self, connection, device, secrets_only)) { + if (!internal_init (self, connection, device, secrets_only, secrets_setting_name, secrets_hints)) { g_warning ("Couldn't create Wi-Fi security dialog."); gtk_widget_destroy (GTK_WIDGET (self)); self = NULL; @@ -1301,6 +1305,86 @@ nma_wifi_dialog_new (NMClient *client, return GTK_WIDGET (self); } +/** + * nma_wifi_dialog_new: + * @client: client to retrieve list of devices or connections from + * @connection: connection to be shown/edited or %NULL + * @device: device to check connection compatibility against + * @ap: AP to check connection compatibility against + * @secrets_only: whether to only ask for secrets for given connection + * + * Creates a wifi connection dialog and populates it with settings from + * @connection if given. If @device is not given a device selection combo box + * will be included. If @connection is not given a connection selection combo + * box will be included. If @secrets_only is %FALSE a complete connection + * creator/editor dialog is returned, otherwise only wifi security secrets + * relevant to the security settings in @connection are going to be shown and + * will be editable. + * + * Returns: the dialog widget or %NULL in case of error + */ +GtkWidget * +nma_wifi_dialog_new (NMClient *client, + NMConnection *connection, + NMDevice *device, + NMAccessPoint *ap, + gboolean secrets_only) +{ + guint32 dev_caps; + + /* Ensure device validity */ + if (device) { + dev_caps = nm_device_get_capabilities (device); + g_return_val_if_fail (dev_caps & NM_DEVICE_CAP_NM_SUPPORTED, NULL); + g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); + } + + return internal_new_dialog (client, + connection, + device, + ap, + secrets_only, + NULL, + NULL); +} + +/** + * nma_wifi_dialog_new_for_secrets: + * @client: client to retrieve list of devices or connections from + * @connection: connection for which secrets are requested + * @secrets_setting_name: setting name whose secrets are requested + * or %NULL + * @secrets_hints: array of setting key names within the setting given in + * @secrets_setting_name which are requested or %NULL + * + * Creates a wifi secrets dialog and populates it with setting values from + * @connection. If @secrets_setting_name and @secrets_hints are not given + * this function creates an identical dialog as nma_wifi_dialog_new() would + * create with the @secrets_only parameter %TRUE. Otherwise + * @secrets_setting_name and @secrets_hints determine the list of specific + * secrets that are being requested from the user and no editable entries + * are shown for any other settings. + * + * Note: only a subset of all settings and setting keys is supported as + * @secrets_setting_name and @secrets_hints. + * + * Returns: the dialog widget or %NULL in case of error + */ +GtkWidget * +nma_wifi_dialog_new_for_secrets (NMClient *client, + NMConnection *connection, + const char *secrets_setting_name, + const char *const*secrets_hints) +{ + return internal_new_dialog (client, + connection, + NULL, + NULL, + TRUE, + secrets_setting_name, + secrets_hints); +} + static GtkWidget * internal_new_operation (NMClient *client, guint operation) @@ -1321,7 +1405,7 @@ internal_new_operation (NMClient *client, priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); priv->operation = operation; - if (!internal_init (self, NULL, NULL, FALSE)) { + if (!internal_init (self, NULL, NULL, FALSE, NULL, NULL)) { g_warning ("Couldn't create Wi-Fi security dialog."); gtk_widget_destroy (GTK_WIDGET (self)); return NULL; diff --git a/src/libnma/nma-wifi-dialog.h b/src/libnma/nma-wifi-dialog.h index bb7a8c19..7dba081a 100644 --- a/src/libnma/nma-wifi-dialog.h +++ b/src/libnma/nma-wifi-dialog.h @@ -53,6 +53,11 @@ GtkWidget *nma_wifi_dialog_new (NMClient *client, NMAccessPoint *ap, gboolean secrets_only); +GtkWidget *nma_wifi_dialog_new_for_secrets (NMClient *client, + NMConnection *connection, + const char *secrets_setting_name, + const char *const*secrets_hints); + GtkWidget *nma_wifi_dialog_new_for_hidden (NMClient *client); GtkWidget *nma_wifi_dialog_new_for_create (NMClient *client); diff --git a/src/wireless-security/ws-wpa-eap.c b/src/wireless-security/ws-wpa-eap.c index 2479a3ee..c58dd7f5 100644 --- a/src/wireless-security/ws-wpa-eap.c +++ b/src/wireless-security/ws-wpa-eap.c @@ -99,7 +99,8 @@ update_secrets (WirelessSecurity *parent, NMConnection *connection) WirelessSecurityWPAEAP * ws_wpa_eap_new (NMConnection *connection, gboolean is_editor, - gboolean secrets_only) + gboolean secrets_only, + const char *const*secrets_hints) { WirelessSecurity *parent; GtkWidget *widget; diff --git a/src/wireless-security/ws-wpa-eap.h b/src/wireless-security/ws-wpa-eap.h index 0ebff700..283c4fa7 100644 --- a/src/wireless-security/ws-wpa-eap.h +++ b/src/wireless-security/ws-wpa-eap.h @@ -27,6 +27,7 @@ typedef struct _WirelessSecurityWPAEAP WirelessSecurityWPAEAP; WirelessSecurityWPAEAP * ws_wpa_eap_new (NMConnection *connection, gboolean is_editor, - gboolean secrets_only); + gboolean secrets_only, + const char *const*secrets_hints); #endif /* WS_WPA_EAP_H */ |