nm: Only check PSK length if one is actually stored
authorTobias Brunner <tobias@strongswan.org>
Wed, 12 Feb 2020 13:04:45 +0000 (14:04 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 14 Feb 2020 13:51:43 +0000 (14:51 +0100)
src/frontends/gnome/properties/nm-strongswan.c

index 9aeb274..81c89c1 100644 (file)
@@ -133,13 +133,21 @@ check_validity (StrongswanPluginUiWidget *self, GError **error)
                case 3:
                {
                        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "passwd-entry"));
-                       str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
-                       if (str && strlen (str) < 20) {
-                               g_set_error (error,
-                                                        STRONGSWAN_PLUGIN_UI_ERROR,
-                                                        STRONGSWAN_PLUGIN_UI_ERROR_INVALID_PROPERTY,
-                                                        "password is too short");
-                               return FALSE;
+                       switch (nma_utils_menu_to_secret_flags(widget))
+                       {
+                               case NM_SETTING_SECRET_FLAG_NONE:
+                               case NM_SETTING_SECRET_FLAG_AGENT_OWNED:
+                                       str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
+                                       if (str && strlen (str) < 20) {
+                                               g_set_error (error,
+                                                                        STRONGSWAN_PLUGIN_UI_ERROR,
+                                                                        STRONGSWAN_PLUGIN_UI_ERROR_INVALID_PROPERTY,
+                                                                        "password is too short");
+                                               return FALSE;
+                                       }
+                                       break;
+                               default:
+                                       break;
                        }
                }
        }