From da0a15a19b465dbf5a7080768e68a22d3de7578e Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 15 Aug 2017 15:42:21 +0100 Subject: [PATCH] More cleanups in gpst auth_form() Signed-off-by: David Woodhouse --- auth-globalprotect.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/auth-globalprotect.c b/auth-globalprotect.c index f5d877b8..0b547c14 100644 --- a/auth-globalprotect.c +++ b/auth-globalprotect.c @@ -36,10 +36,12 @@ static struct oc_auth_form *auth_form(struct openconnect_info *vpninfo, char *pr struct oc_form_opt *opt, *opt2; form = calloc(1, sizeof(*form)); - if (!form) return NULL; - if (prompt) form->message = strdup(prompt); + + if (prompt) + form->message = strdup(prompt); + form->auth_id = strdup(auth_id ? : "_gateway"); opt = form->opts = calloc(1, sizeof(*opt)); @@ -48,8 +50,8 @@ static struct oc_auth_form *auth_form(struct openconnect_info *vpninfo, char *pr free_auth_form(form); return NULL; } - opt->name=strdup("user"); - opt->label=strdup(_("Username: ")); + opt->name = strdup("user"); + opt->label = strdup(_("Username: ")); opt->type = OC_FORM_OPT_TEXT; opt2 = opt->next = calloc(1, sizeof(*opt)); @@ -57,7 +59,10 @@ static struct oc_auth_form *auth_form(struct openconnect_info *vpninfo, char *pr goto nomem; opt2->name = strdup("passwd"); opt2->label = auth_id ? strdup(_("Challenge: ")) : strdup(_("Password: ")); - opt2->type = vpninfo->token_mode!=OC_TOKEN_MODE_NONE ? OC_FORM_OPT_TOKEN : OC_FORM_OPT_PASSWORD; + if (vpninfo->token_mode == OC_TOKEN_MODE_NONE) + opt2->type = OC_FORM_OPT_PASSWORD; + else + opt2->type = OC_FORM_OPT_TOKEN; /* Don't we normally have to check can_gen_tokencode()? */ return form; } -- 2.49.0