]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
More cleanups in gpst auth_form()
authorDavid Woodhouse <dwmw2@infradead.org>
Tue, 15 Aug 2017 14:42:21 +0000 (15:42 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 15 Aug 2017 14:42:35 +0000 (15:42 +0100)
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
auth-globalprotect.c

index f5d877b84b9f0583e017266c9b832fb9c2997484..0b547c143a5e43d957160411686471f84e547d7a 100644 (file)
@@ -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;
 }