nm: Require the PSK to be at least 20 characters long

This commit is contained in:
Tobias Brunner 2013-11-25 18:17:58 +01:00
parent 692a421aa0
commit 0b506edb19
2 changed files with 14 additions and 5 deletions

View File

@ -118,7 +118,7 @@ int main (int argc, char *argv[])
gchar *name = NULL, *uuid = NULL, *service = NULL, *keyring = NULL, *pass; gchar *name = NULL, *uuid = NULL, *service = NULL, *keyring = NULL, *pass;
GOptionContext *context; GOptionContext *context;
char *agent, *type; char *agent, *type;
guint32 itemid; guint32 itemid, minlen = 0;
GtkWidget *dialog; GtkWidget *dialog;
GOptionEntry entries[] = { GOptionEntry entries[] = {
{ "reprompt", 'r', 0, G_OPTION_ARG_NONE, &retry, "Reprompt for passwords", NULL}, { "reprompt", 'r', 0, G_OPTION_ARG_NONE, &retry, "Reprompt for passwords", NULL},
@ -182,9 +182,10 @@ int main (int argc, char *argv[])
else if (!strcmp(type, "psk")) else if (!strcmp(type, "psk"))
{ {
dialog = gnome_password_dialog_new(_("VPN password required"), dialog = gnome_password_dialog_new(_("VPN password required"),
_("Pre-shared key required to establish VPN connection:"), _("Pre-shared key required to establish VPN connection (min. 20 characters):"),
NULL, NULL, TRUE); NULL, NULL, TRUE);
gnome_password_dialog_set_show_remember(GNOME_PASSWORD_DIALOG(dialog), TRUE); gnome_password_dialog_set_show_remember(GNOME_PASSWORD_DIALOG(dialog), TRUE);
minlen = 20;
} }
else /* smartcard */ else /* smartcard */
{ {
@ -198,12 +199,18 @@ int main (int argc, char *argv[])
{ {
gnome_password_dialog_set_password(GNOME_PASSWORD_DIALOG(dialog), pass); gnome_password_dialog_set_password(GNOME_PASSWORD_DIALOG(dialog), pass);
} }
too_short_retry:
if (!gnome_password_dialog_run_and_block(GNOME_PASSWORD_DIALOG(dialog))) if (!gnome_password_dialog_run_and_block(GNOME_PASSWORD_DIALOG(dialog)))
{ {
return 1; return 1;
} }
pass = gnome_password_dialog_get_password(GNOME_PASSWORD_DIALOG(dialog)); pass = gnome_password_dialog_get_password(GNOME_PASSWORD_DIALOG(dialog));
if (minlen && strlen(pass) < minlen)
{
goto too_short_retry;
}
switch (gnome_password_dialog_get_remember(GNOME_PASSWORD_DIALOG(dialog))) switch (gnome_password_dialog_get_remember(GNOME_PASSWORD_DIALOG(dialog)))
{ {
case GNOME_PASSWORD_DIALOG_REMEMBER_NOTHING: case GNOME_PASSWORD_DIALOG_REMEMBER_NOTHING:

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: NetworkManager-strongswan\n" "Project-Id-Version: NetworkManager-strongswan\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-22 14:00+0100\n" "POT-Creation-Date: 2013-11-25 18:14+0100\n"
"PO-Revision-Date: 2010-02-18 09:20+0100\n" "PO-Revision-Date: 2010-02-18 09:20+0100\n"
"Last-Translator: Martin Willi <martin@strongswan.org>\n" "Last-Translator: Martin Willi <martin@strongswan.org>\n"
"Language-Team: de <martin@strongswan.org>\n" "Language-Team: de <martin@strongswan.org>\n"
@ -161,9 +161,11 @@ msgstr ""
"Passwort geschützt:" "Passwort geschützt:"
#: ../auth-dialog/main.c:185 #: ../auth-dialog/main.c:185
msgid "Pre-shared key required to establish VPN connection:" msgid ""
"Pre-shared key required to establish VPN connection (min. 20 characters):"
msgstr "" msgstr ""
"Für die Erstellung des VPN-Tunnels ist ein Pre-shared Key erforderlich:" "Für die Erstellung des VPN-Tunnels ist ein Pre-shared Key erforderlich (min. "
"20 Zeichen):"
#: ../auth-dialog/main.c:192 #: ../auth-dialog/main.c:192
msgid "Smartcard PIN required to establish VPN connection:" msgid "Smartcard PIN required to establish VPN connection:"