]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Fix GlobalProtect authgroup handling
authorDaniel Lenski <dlenski@gmail.com>
Mon, 8 Oct 2018 18:03:45 +0000 (11:03 -0700)
committerDaniel Lenski <dlenski@gmail.com>
Mon, 8 Oct 2018 18:03:45 +0000 (11:03 -0700)
When connecting to a GlobalProtect server via the portal interface, then
`vpninfo->authgroup` needs to be set to the URL of one of the allowed
gateways.

The problem here is that if the user actually wanted to select the _first_
gateway in the dropdown list, it was already pre-selected, and thus clicking
"continue"/"login" on the form wouldn't trigger `OC_FORM_RESULT_NEWGROUP`.

This would prevent `vpninfo->authgroup` from getting set correctly, and the
gateway redirect would be skipped entirely.  Thus it was effectively
impossible to select the first option in the gateway dropdown.

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

index a745c0624c871432d0657d1d61959f76ce0c91bd..f4c45742fe2cbe2cdc2cf2c8ba3de352b5b98bc8 100644 (file)
@@ -401,6 +401,8 @@ gateways:
                                     choice->label, choice->name);
                }
        }
+       if (!vpninfo->authgroup && opt->nr_choices)
+               vpninfo->authgroup = strdup(opt->choices[0]->name);
 
        if (vpninfo->write_new_config) {
                buf_append(buf, "  </ServerList>\n</GPPortal>\n");
@@ -412,7 +414,7 @@ gateways:
 
        /* process auth form to select gateway */
        result = process_auth_form(vpninfo, form);
-       if (result != OC_FORM_RESULT_NEWGROUP)
+       if (result == OC_FORM_RESULT_CANCELLED || result < 0)
                goto out;
 
        /* redirect to the gateway (no-op if it's the same host) */