diff options
Diffstat (limited to 'src/nmtui')
| -rw-r--r-- | src/nmtui/README.md | 15 | ||||
| -rw-r--r-- | src/nmtui/nmt-8021x-fields.c | 171 | ||||
| -rw-r--r-- | src/nmtui/nmt-connect-connection-list.c | 2 | ||||
| -rw-r--r-- | src/nmtui/nmt-port-list.c | 2 | ||||
| -rw-r--r-- | src/nmtui/nmtui-edit.c | 4 |
5 files changed, 188 insertions, 6 deletions
diff --git a/src/nmtui/README.md b/src/nmtui/README.md new file mode 100644 index 00000000..5205f480 --- /dev/null +++ b/src/nmtui/README.md @@ -0,0 +1,15 @@ +nmtui +===== + +The curses-based text user interface of NetworkManager. +It uses the D-Bus API of NetworkManager (via libnm). + +This is a NetworkManager client applications that can +edit connection profiles and activate them, by providing +a text UI. + +It uses libnewt. + +See: + +- `man 1 nmtui` ([[www]](https://networkmanager.dev/docs/api/latest/nmtui.html)) diff --git a/src/nmtui/nmt-8021x-fields.c b/src/nmtui/nmt-8021x-fields.c index a323be62..62ab69d8 100644 --- a/src/nmtui/nmt-8021x-fields.c +++ b/src/nmtui/nmt-8021x-fields.c @@ -30,6 +30,7 @@ struct _EapMethod { const EapMethodDesc *desc; NMSetting8021x *setting; NmtNewtWidget *inner_popup; + NmtNewtWidget *advanced_tls_settings; }; typedef struct { @@ -196,6 +197,166 @@ eap_method_populate_simple(EapMethod *method, NmtNewtWidget *subgrid) } static void +checkbox_advanced_tls_settings_changed(NmtNewtWidget *widget, GParamSpec *pspec, gpointer user_data) +{ + EapMethod *method = (EapMethod *) (user_data); + gboolean active; + + active = nmt_newt_checkbox_get_active(NMT_NEWT_CHECKBOX(widget)); + nmt_newt_widget_set_visible(method->advanced_tls_settings, active); +} + +static NmtNewtPopupEntry pe_tristate[] = {{N_("Default"), ""}, + {N_("Disable"), "disable"}, + {N_("Enable"), "enable"}, + {NULL, NULL}}; + +static NmtNewtPopupEntry pe_disable[] = {{N_("Default"), ""}, + {N_("Disable"), "disable"}, + {NULL, NULL}}; + +typedef struct _AuthFlagsTls AuthFlagsTls; +struct _AuthFlagsTls { + const char *label; + NMSetting8021xAuthFlags disable; + NMSetting8021xAuthFlags enable; + NmtNewtPopupEntry *states; +}; + +static gboolean +phase1_auth_flag_get_bit(GBinding *binding, + const GValue *from_value, + GValue *to_value, + gpointer user_data) +{ + AuthFlagsTls *af = (AuthFlagsTls *) user_data; + unsigned src = g_value_get_uint(from_value); + + if (src & af->disable) + g_value_set_string(to_value, "disable"); + else if (src & af->enable) + g_value_set_string(to_value, "enable"); + else + g_value_set_string(to_value, NULL); + return TRUE; +} + +static gboolean +phase1_auth_flag_set_bit(GBinding *binding, + const GValue *from_value, + GValue *to_value, + gpointer user_data) +{ + AuthFlagsTls *af = (AuthFlagsTls *) user_data; + GObject *from_object = g_binding_get_source(binding); + GValue orig_value; + unsigned bits; + const char *str_value; + + if (from_object == NULL) + return FALSE; + g_value_init(&orig_value, G_TYPE_UINT); + g_object_get_property(from_object, g_binding_get_source_property(binding), &orig_value); + bits = g_value_get_uint(&orig_value); + g_value_unset(&orig_value); + str_value = g_value_get_string(from_value); + bits = bits & ~(unsigned) (af->enable | af->disable); + if (str_value) + switch (str_value[0]) { + case 'd': + bits |= af->disable; + break; + case 'e': + bits |= af->enable; + break; + } + g_value_set_uint(to_value, bits); + return TRUE; +} + +static gboolean +empty_string_to_null(GBinding *binding, + const GValue *from_value, + GValue *to_value, + gpointer _unused) +{ + const char *value = g_value_get_string(from_value); + + if (value && value[0]) + g_value_set_string(to_value, value); + return TRUE; +} + +static void +eap_populate_advanced_tls_settings(EapMethod *method, NmtNewtWidget *subgrid) +{ + NmtNewtWidget *widget, *tlsgrid; + gboolean has_advanced_settings; + const char *oc; + static AuthFlagsTls auth_flag_switches[] = { +#define ENDIS_TLS(name, proto) \ + {name, \ + NM_SETTING_802_1X_AUTH_FLAGS_##proto##_DISABLE, \ + NM_SETTING_802_1X_AUTH_FLAGS_##proto##_ENABLE, \ + pe_tristate} + ENDIS_TLS(N_("TLS 1.0"), TLS_1_0), + ENDIS_TLS(N_("TLS 1.1"), TLS_1_1), + ENDIS_TLS(N_("TLS 1.2"), TLS_1_2), + ENDIS_TLS(N_("TLS 1.3"), TLS_1_3), +#undef ENDIS_TLS + {N_("Disable time checks"), + NM_SETTING_802_1X_AUTH_FLAGS_TLS_DISABLE_TIME_CHECKS, + NM_SETTING_802_1X_AUTH_FLAGS_NONE, + pe_disable}, + {NULL, NM_SETTING_802_1X_AUTH_FLAGS_NONE, NM_SETTING_802_1X_AUTH_FLAGS_NONE, NULL}, + }; + + oc = nm_setting_802_1x_get_openssl_ciphers(method->setting); + has_advanced_settings = + (oc != NULL && !!strlen(oc)) || !!nm_setting_802_1x_get_phase1_auth_flags(method->setting); + + widget = nmt_newt_checkbox_new(_("Show expert TLS options")); + nmt_newt_checkbox_set_active(NMT_NEWT_CHECKBOX(widget), has_advanced_settings); + g_signal_connect(widget, + "notify::active", + G_CALLBACK(checkbox_advanced_tls_settings_changed), + method); + nmt_editor_grid_append(NMT_EDITOR_GRID(subgrid), NULL, widget, NULL); + + tlsgrid = nmt_editor_grid_new(); + method->advanced_tls_settings = tlsgrid; + nmt_editor_grid_append(NMT_EDITOR_GRID(subgrid), NULL, tlsgrid, NULL); + checkbox_advanced_tls_settings_changed(widget, NULL, method); + + nmt_editor_grid_append(NMT_EDITOR_GRID(tlsgrid), _("Wpa_supplicant settings:"), NULL, NULL); + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(NMT_EDITOR_GRID(tlsgrid), _("Cipher string"), widget, NULL); + g_object_bind_property_full(method->setting, + NM_SETTING_802_1X_OPENSSL_CIPHERS, + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, + NULL, + empty_string_to_null, + NULL, + NULL); + + for (AuthFlagsTls *sw = auth_flag_switches; sw->states; sw++) { + widget = nmt_newt_popup_new(sw->states); + nmt_editor_grid_append(NMT_EDITOR_GRID(tlsgrid), sw->label, widget, NULL); + g_object_bind_property_full(method->setting, + NM_SETTING_802_1X_PHASE1_AUTH_FLAGS, + widget, + "active-id", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, + phase1_auth_flag_get_bit, + phase1_auth_flag_set_bit, + (gpointer) sw, + NULL); + } +} + +static void eap_method_populate_tls(EapMethod *method, NmtNewtWidget *subgrid) { NmtNewtWidget *widget; @@ -282,6 +443,8 @@ eap_method_populate_tls(EapMethod *method, NmtNewtWidget *subgrid) "password", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); nmt_editor_grid_append(NMT_EDITOR_GRID(subgrid), _("User privkey password"), widget, NULL); + + eap_populate_advanced_tls_settings(method, subgrid); } static void @@ -297,7 +460,7 @@ eap_method_populate_ttls(EapMethod *method, NmtNewtWidget *subgrid) {N_("GTC"), "eap-gtc"}, {NULL, NULL}}; - widget = nmt_newt_entry_new(40, NMT_NEWT_ENTRY_NONEMPTY); + widget = nmt_newt_entry_new(40, 0); nmt_editor_grid_append(NMT_EDITOR_GRID(subgrid), _("Anonymous identity"), widget, NULL); g_object_bind_property(method->setting, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, @@ -371,6 +534,8 @@ eap_method_populate_ttls(EapMethod *method, NmtNewtWidget *subgrid) "secret-flags", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); nmt_editor_grid_append(NMT_EDITOR_GRID(subgrid), _("Password"), widget, NULL); + + eap_populate_advanced_tls_settings(method, subgrid); } static void @@ -386,7 +551,7 @@ eap_method_populate_peap(EapMethod *method, NmtNewtWidget *subgrid) {N_("GTC"), "gtc"}, {NULL, NULL}}; - widget = nmt_newt_entry_new(40, NMT_NEWT_ENTRY_NONEMPTY); + widget = nmt_newt_entry_new(40, 0); nmt_editor_grid_append(NMT_EDITOR_GRID(subgrid), _("Anonymous identity"), widget, NULL); g_object_bind_property(method->setting, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, @@ -475,6 +640,8 @@ eap_method_populate_peap(EapMethod *method, NmtNewtWidget *subgrid) "secret-flags", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); nmt_editor_grid_append(NMT_EDITOR_GRID(subgrid), _("Password"), widget, NULL); + + eap_populate_advanced_tls_settings(method, subgrid); } static void diff --git a/src/nmtui/nmt-connect-connection-list.c b/src/nmtui/nmt-connect-connection-list.c index 329494cc..70264d3e 100644 --- a/src/nmtui/nmt-connect-connection-list.c +++ b/src/nmtui/nmt-connect-connection-list.c @@ -184,7 +184,7 @@ add_connections_for_device(NmtConnectDevice *nmtdev, const GPtrArray *connection NMSettingConnection *s_con; s_con = nm_connection_get_setting_connection(conn); - if (nm_setting_connection_get_master(s_con)) + if (nm_setting_connection_get_controller(s_con)) continue; if (nm_device_connection_valid(nmtdev->device, conn)) { diff --git a/src/nmtui/nmt-port-list.c b/src/nmtui/nmt-port-list.c index 9e4dd8a6..aa3217b1 100644 --- a/src/nmtui/nmt-port-list.c +++ b/src/nmtui/nmt-port-list.c @@ -107,7 +107,7 @@ nmt_port_list_connection_filter(NmtEditConnectionList *list, if (g_strcmp0(port_type, priv->controller_type) != 0) return FALSE; - controller = nm_setting_connection_get_master(s_con); + controller = nm_setting_connection_get_controller(s_con); if (!controller) return FALSE; diff --git a/src/nmtui/nmtui-edit.c b/src/nmtui/nmtui-edit.c index 723cfea9..0ba3bd0d 100644 --- a/src/nmtui/nmtui-edit.c +++ b/src/nmtui/nmtui-edit.c @@ -58,7 +58,7 @@ edit_connection_list_filter(NmtEditConnectionList *list, s_con = nm_connection_get_setting_connection(connection); g_return_val_if_fail(s_con != NULL, FALSE); - controller = nm_setting_connection_get_master(s_con); + controller = nm_setting_connection_get_controller(s_con); if (!controller) return TRUE; port_type = nm_setting_connection_get_port_type(s_con); @@ -525,7 +525,7 @@ nmt_remove_connection(NMRemoteConnection *connection) for (i = 0; i < all_conns->len; i++) { port = all_conns->pdata[i]; s_con = nm_connection_get_setting_connection(NM_CONNECTION(port)); - controller = nm_setting_connection_get_master(s_con); + controller = nm_setting_connection_get_controller(s_con); if (controller) { if (!g_strcmp0(controller, uuid) || !g_strcmp0(controller, iface)) ports = g_slist_prepend(ports, g_object_ref(port)); |