Signed-off-by: Kevin Cernekee <cernekee at gmail.com> --- main.c | 33 ++++++++++++++++++--------------- openconnect-internal.h | 2 -- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/main.c b/main.c index 5ddd9b8..e0114d2 100644 --- a/main.c +++ b/main.c @@ -83,6 +83,10 @@ int nocertcheck; int non_inter; int cookieonly; +char *username; +char *password; +char *authgroup; + enum { OPT_AUTHENTICATE = 0x100, OPT_AUTHGROUP, @@ -563,7 +567,7 @@ int main(int argc, char **argv) vpninfo->cookie = NULL; break; case OPT_PASSWORD_ON_STDIN: - read_stdin(&vpninfo->password); + read_stdin(&password); break; case OPT_NO_PASSWD: vpninfo->nopasswd = 1; @@ -581,7 +585,7 @@ int main(int argc, char **argv) vpninfo->dtls_ciphers = keep_config_arg(); break; case OPT_AUTHGROUP: - vpninfo->authgroup = keep_config_arg(); + authgroup = keep_config_arg(); break; case 'b': background = 1; @@ -661,7 +665,7 @@ int main(int argc, char **argv) vpninfo->script_tun = 1; break; case 'u': - vpninfo->username = keep_config_arg(); + username = keep_config_arg(); break; case 'U': { char *strend; @@ -1106,13 +1110,12 @@ static int process_auth_form(void *_vpninfo, if (!select_opt->nr_choices) continue; - if (vpninfo->authgroup && + if (authgroup && !strcmp(opt->name, "group_list")) { for (i = 0; i < select_opt->nr_choices; i++) { choice = &select_opt->choices[i]; - if (!strcmp(vpninfo->authgroup, - choice->label)) { + if (!strcmp(authgroup, choice->label)) { opt->value = choice->name; break; } @@ -1120,7 +1123,7 @@ static int process_auth_form(void *_vpninfo, if (!opt->value) vpn_progress(vpninfo, PRG_ERR, _("Auth choice \"%s\" not available\n"), - vpninfo->authgroup); + authgroup); } if (!opt->value && select_opt->nr_choices == 1) { choice = &select_opt->choices[0]; @@ -1173,9 +1176,9 @@ static int process_auth_form(void *_vpninfo, for (opt = form->opts; opt; opt = opt->next) { if (opt->type == OC_FORM_OPT_TEXT) { - if (vpninfo->username && + if (username && !strcmp(opt->name, "username")) { - opt->value = strdup(vpninfo->username); + opt->value = strdup(username); if (!opt->value) goto err; } else if (non_inter) { @@ -1199,10 +1202,10 @@ static int process_auth_form(void *_vpninfo, } } else if (opt->type == OC_FORM_OPT_PASSWORD) { - if (vpninfo->password && + if (password && !strcmp(opt->name, "password")) { - opt->value = vpninfo->password; - vpninfo->password = NULL; + opt->value = password; + password = NULL; if (!opt->value) goto err; } else if (non_inter) { @@ -1239,9 +1242,9 @@ static int process_auth_form(void *_vpninfo, } } - if (vpninfo->password) { - free(vpninfo->password); - vpninfo->password = NULL; + if (password) { + free(password); + password = NULL; } return 0; diff --git a/openconnect-internal.h b/openconnect-internal.h index 4dc9ed4..4f9af77 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -171,8 +171,6 @@ struct openconnect_info { const char *servercert; const char *xmlconfig; char xmlsha1[(SHA1_SIZE * 2) + 1]; - char *username; - char *password; char *authgroup; int nopasswd; int xmlpost; -- 1.7.9.5