[libnma/ac/owe: 1/2] wireless-security: include owe
- From: Ana Cabral <acabral src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnma/ac/owe: 1/2] wireless-security: include owe
- Date: Fri, 11 Mar 2022 22:11:24 +0000 (UTC)
commit 746eb7db6a75da6ebf34e671b574abd89db54acd
Author: Ana Cabral <acabral redhat com>
Date: Fri Mar 11 09:27:07 2022 +0100
wireless-security: include owe
https://gitlab.gnome.org/GNOME/libnma/-/issues/9
Makefile.am | 2 +
shared/nm-libnm-compat.h | 6 +++
src/libnma.ver | 5 ++
src/nma-version.h.in | 7 +++
src/nma-wifi-dialog.c | 14 +++++
src/nma-ws/meson.build | 2 +
src/nma-ws/nma-ws-owe.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++
src/nma-ws/nma-ws-owe.h | 26 +++++++++
src/nma-ws/nma-ws.c | 10 ++--
src/nma-ws/nma-ws.h | 1 +
src/tests/ws.c | 7 +++
11 files changed, 210 insertions(+), 3 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index b60baf41..1f755e9b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -172,6 +172,7 @@ libnma_h_pub = \
src/nma-ws/nma-ws-dynamic-wep.h \
src/nma-ws/nma-ws.h \
src/nma-ws/nma-ws-leap.h \
+ src/nma-ws/nma-ws-owe.h \
src/nma-ws/nma-ws-sae.h \
src/nma-ws/nma-ws-wep-key.h \
src/nma-ws/nma-ws-wpa-eap.h \
@@ -200,6 +201,7 @@ libnma_c_real = \
src/nma-ws/nma-ws-dynamic-wep.c \
src/nma-ws/nma-ws-helpers.c \
src/nma-ws/nma-ws-leap.c \
+ src/nma-ws/nma-ws-owe.c \
src/nma-ws/nma-ws-sae.c \
src/nma-ws/nma-ws-wep-key.c \
src/nma-ws/nma-ws-wpa-eap.c \
diff --git a/shared/nm-libnm-compat.h b/shared/nm-libnm-compat.h
index 9cfac52b..bb69c53c 100644
--- a/shared/nm-libnm-compat.h
+++ b/shared/nm-libnm-compat.h
@@ -28,4 +28,10 @@
G_GNUC_END_IGNORE_DEPRECATIONS \
})
+#define _NMU_SEC_OWE ((NMUtilsSecurityType) 10)
+#if !NM_CHECK_VERSION (1,24,0)
+#define NMU_SEC_OWE _NMU_SEC_OWE
+#endif
+G_STATIC_ASSERT (NMU_SEC_OWE == _NMU_SEC_OWE);
+
#endif /* __NM_LIBNM_COMPAT_H__ */
diff --git a/src/libnma.ver b/src/libnma.ver
index 3e444d44..dd9e33e7 100644
--- a/src/libnma.ver
+++ b/src/libnma.ver
@@ -134,3 +134,8 @@ libnma_1_8_28 {
nma_ws_wpa_psk_get_type;
nma_ws_wpa_psk_new;
} libnma_1_8_22;
+
+libnma_1_8_36 {
+ nma_ws_owe_get_type;
+ nma_ws_owe_new;
+} libnma_1_8_28;
diff --git a/src/nma-version.h.in b/src/nma-version.h.in
index 9c511da6..d2be7b9f 100644
--- a/src/nma-version.h.in
+++ b/src/nma-version.h.in
@@ -62,6 +62,7 @@
#define NMA_VERSION_1_8_26 (NMA_ENCODE_VERSION (1, 8, 26))
#define NMA_VERSION_1_8_28 (NMA_ENCODE_VERSION (1, 8, 28))
#define NMA_VERSION_1_8_34 (NMA_ENCODE_VERSION (1, 8, 34))
+#define NMA_VERSION_1_8_36 (NMA_ENCODE_VERSION (1, 8, 36))
/* For releases, NMA_API_VERSION is equal to NMA_VERSION.
*
@@ -150,4 +151,10 @@
# define NMA_AVAILABLE_IN_1_8_34
#endif
+#if NMA_VERSION_MAX_ALLOWED < NMA_VERSION_1_8_36
+# define NMA_AVAILABLE_IN_1_8_36 G_UNAVAILABLE(1.8,36)
+#else
+# define NMA_AVAILABLE_IN_1_8_36
+#endif
+
#endif /* NMA_VERSION_H */
diff --git a/src/nma-wifi-dialog.c b/src/nma-wifi-dialog.c
index 60793fc6..bb8c4f82 100644
--- a/src/nma-wifi-dialog.c
+++ b/src/nma-wifi-dialog.c
@@ -686,6 +686,9 @@ get_default_type_for_security (NMSettingWirelessSecurity *sec,
if (!strcmp (key_mgmt, "none"))
return NMU_SEC_STATIC_WEP;
+ if (!strcmp (key_mgmt, "owe"))
+ return NMU_SEC_OWE;
+
if ( !strcmp (key_mgmt, "ieee8021x")
&& (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY))) {
if (auth_alg && !strcmp (auth_alg, "leap"))
@@ -1018,6 +1021,17 @@ security_combo_init (NMAWifiDialog *self, gboolean secrets_only,
item++;
}
+ if (security_valid (NMU_SEC_OWE, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)) {
+ NMAWsOwe *ws_owe;
+
+ ws_owe = nma_ws_owe_new (priv->connection);
+ add_security_item (self, NMA_WS (ws_owe), sec_model,
+ &iter, _("Enhanced Open"));
+ if (active < 0 && default_type == NMU_SEC_OWE)
+ active = item;
+ item++;
+ }
+
gtk_combo_box_set_model (GTK_COMBO_BOX (priv->sec_combo), GTK_TREE_MODEL (sec_model));
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->sec_combo), active < 0 ? 0 : (guint32) active);
g_object_unref (G_OBJECT (sec_model));
diff --git a/src/nma-ws/meson.build b/src/nma-ws/meson.build
index 7b94d4be..1e971ea2 100644
--- a/src/nma-ws/meson.build
+++ b/src/nma-ws/meson.build
@@ -19,6 +19,7 @@ nma_ws_headers = files(
'nma-ws-dynamic-wep.h',
'nma-ws.h',
'nma-ws-leap.h',
+ 'nma-ws-owe.h',
'nma-ws-sae.h',
'nma-ws-wep-key.h',
'nma-ws-wpa-eap.h',
@@ -38,6 +39,7 @@ nma_ws_sources = files(
'nma-ws-dynamic-wep.c',
'nma-ws-helpers.c',
'nma-ws-leap.c',
+ 'nma-ws-owe.c',
'nma-ws-sae.c',
'nma-ws-wep-key.c',
'nma-ws-wpa-eap.c',
diff --git a/src/nma-ws/nma-ws-owe.c b/src/nma-ws/nma-ws-owe.c
new file mode 100644
index 00000000..82254815
--- /dev/null
+++ b/src/nma-ws/nma-ws-owe.c
@@ -0,0 +1,133 @@
+#include "nm-default.h"
+#include "nma-private.h"
+
+#include "nma-ws.h"
+#include "nma-ws-private.h"
+#include "nma-ws-owe.h"
+
+struct _NMAWsOwe {
+ GtkGrid parent;
+
+ NMConnection *connection;
+};
+
+struct _NMAWsOweClass {
+ GtkGridClass parent;
+};
+
+static void nma_ws_interface_init (NMAWsInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (NMAWsOwe, nma_ws_owe, GTK_TYPE_GRID,
+ G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
+
+enum {
+ PROP_0,
+ PROP_CONNECTION,
+ PROP_SECRETS_ONLY,
+ PROP_LAST
+};
+
+static void
+fill_connection (NMAWs *ws, NMConnection *connection)
+{
+ NMSetting *s_wireless_sec;
+
+ /* Blow away the old security setting by adding a clear one */
+ s_wireless_sec = nm_setting_wireless_security_new ();
+ g_object_set (s_wireless_sec,
+ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "owe",
+ NULL);
+
+ nm_connection_add_setting (connection, s_wireless_sec);
+}
+
+static void
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NMAWsOwe *self = NMA_WS_OWE (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, self->connection);
+ break;
+ case PROP_SECRETS_ONLY:
+ g_value_set_boolean (value, FALSE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NMAWsOwe *self = NMA_WS_OWE (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ self->connection = g_value_dup_object (value);
+ break;
+ case PROP_SECRETS_ONLY:
+ /* OWE does not support setting this property to TRUE. */
+ g_return_if_fail (!g_value_get_boolean(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+nma_ws_owe_init (NMAWsOwe *self)
+{
+}
+
+static void
+nma_ws_interface_init (NMAWsInterface *iface)
+{
+ iface->fill_connection = fill_connection;
+ iface->adhoc_compatible = FALSE;
+ iface->hotspot_compatible = TRUE;
+}
+
+NMAWsOwe *
+nma_ws_owe_new (NMConnection *connection)
+{
+ return g_object_new (NMA_TYPE_WS_OWE,
+ "connection", connection,
+ "secrets-only", FALSE,
+ NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMAWsOwe *self = NMA_WS_OWE (object);
+
+ g_clear_object (&self->connection);
+
+ G_OBJECT_CLASS (nma_ws_owe_parent_class)->dispose (object);
+}
+
+static void
+nma_ws_owe_class_init (NMAWsOweClass *klass){
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+ object_class->dispose = dispose;
+
+ g_object_class_override_property (object_class,
+ PROP_CONNECTION, "connection");
+
+ g_object_class_override_property (object_class,
+ PROP_SECRETS_ONLY, "secrets-only");
+
+}
diff --git a/src/nma-ws/nma-ws-owe.h b/src/nma-ws/nma-ws-owe.h
new file mode 100644
index 00000000..5d458e41
--- /dev/null
+++ b/src/nma-ws/nma-ws-owe.h
@@ -0,0 +1,26 @@
+#ifndef NMA_WS_OWE_H
+#define NMA_WS_OWE_H
+
+#include "nma-version.h"
+
+G_BEGIN_DECLS
+
+typedef struct _NMAWsOwe NMAWsOwe;
+typedef struct _NMAWsOweClass NMAWsOweClass;
+
+#define NMA_TYPE_WS_OWE (nma_ws_owe_get_type ())
+#define NMA_WS_OWE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_OWE, NMAWsOwe))
+#define NMA_WS_OWE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_OWE, NMAWsOweClass))
+#define NMA_IS_WS_OWE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_OWE))
+#define NMA_IS_OWE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_OWE))
+#define NMA_WS_OWE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_OWE, NMAWsOweClass))
+
+NMA_AVAILABLE_IN_1_8_36
+GType nma_ws_owe_get_type (void);
+
+NMA_AVAILABLE_IN_1_8_36
+NMAWsOwe *nma_ws_owe_new (NMConnection *connection);
+
+G_END_DECLS
+
+#endif /* NMA_WS_OWE_H */
diff --git a/src/nma-ws/nma-ws.c b/src/nma-ws/nma-ws.c
index 1861f822..98ba0c3a 100644
--- a/src/nma-ws/nma-ws.c
+++ b/src/nma-ws/nma-ws.c
@@ -32,7 +32,11 @@ nma_ws_validate (NMAWs *self, GError **error)
g_return_val_if_fail (!error || !*error, FALSE);
iface = NMA_WS_GET_INTERFACE (self);
- g_return_val_if_fail (iface->validate, FALSE);
+ if (!iface->validate) {
+ /* OWE case */
+ return TRUE;
+ }
+
result = (*(iface->validate)) (self, error);
if (!result && error && !*error)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Unknown error validating 802.1X
security"));
@@ -48,8 +52,8 @@ nma_ws_add_to_size_group (NMAWs *self, GtkSizeGroup *group)
g_return_if_fail (group != NULL);
iface = NMA_WS_GET_INTERFACE (self);
- g_return_if_fail (iface->add_to_size_group);
- return (*(iface->add_to_size_group)) (self, group);
+ if (iface->add_to_size_group)
+ return (*(iface->add_to_size_group)) (self, group);
}
void
diff --git a/src/nma-ws/nma-ws.h b/src/nma-ws/nma-ws.h
index e046cc11..752f76cd 100644
--- a/src/nma-ws/nma-ws.h
+++ b/src/nma-ws/nma-ws.h
@@ -49,6 +49,7 @@ G_END_DECLS
#include "nma-ws-802-1x.h"
#include "nma-ws-dynamic-wep.h"
#include "nma-ws-leap.h"
+#include "nma-ws-owe.h"
#include "nma-ws-sae.h"
#include "nma-ws-wep-key.h"
#include "nma-ws-wpa-eap.h"
diff --git a/src/tests/ws.c b/src/tests/ws.c
index f1d0d481..1003dc1f 100644
--- a/src/tests/ws.c
+++ b/src/tests/ws.c
@@ -110,6 +110,13 @@ main (int argc, char *argv[])
g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
ws_changed_cb (NMA_WS (w), connection);
+ w = GTK_WIDGET (nma_ws_owe_new (connection));
+ gtk_widget_show (w);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), w, gtk_label_new ("OWE"));
+ nma_ws_add_to_size_group (NMA_WS (w), gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL));
+ g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
+ ws_changed_cb (NMA_WS (w), connection);
+
g_main_loop_run (loop);
g_main_loop_unref (loop);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]