summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wireless-security/ws-leap.c13
-rw-r--r--src/wireless-security/ws-wep-key.c12
-rw-r--r--src/wireless-security/ws-wpa-psk.c12
3 files changed, 26 insertions, 11 deletions
diff --git a/src/wireless-security/ws-leap.c b/src/wireless-security/ws-leap.c
index 0d2ce75b..49294f22 100644
--- a/src/wireless-security/ws-leap.c
+++ b/src/wireless-security/ws-leap.c
@@ -52,6 +52,7 @@ static gboolean
validate (WirelessSecurity *parent, GError **error)
{
GtkWidget *entry;
+ NMSettingSecretFlags secret_flags;
const char *text;
gboolean ret = TRUE;
@@ -67,15 +68,21 @@ validate (WirelessSecurity *parent, GError **error)
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 (!text || !strlen (text)) {
+
+ 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;
}
- } else
- widget_unset_error (entry);
+ }
return ret;
}
diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c
index c7472ca3..b1b77c1a 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -94,6 +94,7 @@ static gboolean
validate (WirelessSecurity *parent, GError **error)
{
WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent;
+ NMSettingSecretFlags secret_flags;
GtkWidget *entry;
const char *key;
int i;
@@ -101,14 +102,17 @@ validate (WirelessSecurity *parent, GError **error)
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 (!key) {
+
+ 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;
- }
-
- if (sec->type == NM_WEP_KEY_TYPE_KEY) {
+ } 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])) {
diff --git a/src/wireless-security/ws-wpa-psk.c b/src/wireless-security/ws-wpa-psk.c
index befe68b0..1ea1791b 100644
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -56,6 +56,7 @@ static gboolean
validate (WirelessSecurity *parent, GError **error)
{
GtkWidget *entry;
+ NMSettingSecretFlags secret_flags;
const char *key;
gsize len;
int i;
@@ -63,15 +64,18 @@ validate (WirelessSecurity *parent, GError **error)
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 ((len < 8) || (len > 64)) {
+
+ 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;
- }
-
- if (len == 64) {
+ } else if (len == 64) {
/* Hex PSK */
for (i = 0; i < len; i++) {
if (!isxdigit (key[i])) {