]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
With --user, enter username in all forms, not just the first
authorDaniel Lenski <dlenski@gmail.com>
Fri, 25 Jun 2021 16:42:27 +0000 (09:42 -0700)
committerDaniel Lenski <dlenski@gmail.com>
Tue, 29 Jun 2021 17:51:17 +0000 (10:51 -0700)
Until now, the -u/--user=USERNAME option has caused the OpenConnect CLI to
automatically fill the username only in the *first* form where there is a
match field.  This patch causes it to fill the username repeatedly
(including when a form is repeated due to an authentication failure).

As described by @DimitriPapadopoulos in #267:

> In many cases, I expect the authentication failure to be caused by an
> incorrect password, not an incorrect username
>
> Having to [re]enter the username, when it has already been specified from
> the command line or worse in a config file, is an annoyance.  I suggest
> openconnect [re]prompts for the username only when it has been entered
> interactively from the start.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
main.c

diff --git a/main.c b/main.c
index 73ecb698d6abee3924e142702c69e8c6c37d5d5f..ba0d44ab0ab62805f7796baffc6b043eda0c647d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2614,8 +2614,7 @@ static int process_auth_form_cb(void *_vpninfo,
                        if (username &&
                            (!strncasecmp(opt->name, "user", 4) ||
                             !strncasecmp(opt->name, "uname", 5))) {
-                               opt->_value = username;
-                               username = NULL;
+                               opt->_value = strdup(username);
                        } else {
                                opt->_value = saved_form_field(vpninfo, form->auth_id, opt->name);
                                if (!opt->_value)