nm: Add minimum length constraint for PSK passwords in connection editor
authorTobias Brunner <tobias@strongswan.org>
Thu, 21 Apr 2016 15:46:02 +0000 (17:46 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 5 Sep 2016 13:41:15 +0000 (15:41 +0200)
We already have this restriction in the auth-dialog.

src/frontends/gnome/properties/nm-strongswan.c

index 223dfb3..b791068 100644 (file)
@@ -127,6 +127,22 @@ check_validity (StrongswanPluginUiWidget *self, GError **error)
                                         "address");
                return FALSE;
        }
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "method-combo"));
+       switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)))
+       {
+               case 4:
+               {
+                       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;
+                       }
+               }
+       }
        return TRUE;
 }