]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
don't require F5 forms other than first one to have any particular name/ID
authorDaniel Lenski <dlenski@gmail.com>
Sun, 14 Mar 2021 18:38:38 +0000 (11:38 -0700)
committerDaniel Lenski <dlenski@gmail.com>
Mon, 29 Mar 2021 03:57:25 +0000 (20:57 -0700)
This allow-list of known forms is a relic of the HTML-form-parsing code
which was originally written for the Juniper protocol, and requires a bunch
of special-casing.  I don't think it's particularly relevant for F5 forms.

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

diff --git a/f5.c b/f5.c
index 162e0fb6bc0f50985356f22c91dfd88750678d70..624b680367ff1dc96ee9eab525941f43fd0727ee 100644 (file)
--- a/f5.c
+++ b/f5.c
@@ -87,7 +87,7 @@ static int check_cookie_success(struct openconnect_info *vpninfo)
 
 int f5_obtain_cookie(struct openconnect_info *vpninfo)
 {
-       int ret;
+       int ret, form_order=0;
        xmlDocPtr doc = NULL;
        xmlNode *node;
        struct oc_text_buf *req_buf = NULL;
@@ -98,7 +98,7 @@ int f5_obtain_cookie(struct openconnect_info *vpninfo)
        if ((ret = buf_error(req_buf)))
                goto out;
 
-       while (1) {
+       while (++form_order) {
                char *resp_buf = NULL;
                char *url;
 
@@ -141,16 +141,15 @@ int f5_obtain_cookie(struct openconnect_info *vpninfo)
                buf_truncate(req_buf);
 
                node = find_form_node(doc);
-               if (!node) {
+               if (!node && form_order==1) {
                        /* XX: some F5 VPNs simply do not have a static HTML form to parse */
                        vpn_progress(vpninfo, PRG_ERR,
                                     _("WARNING: no HTML login form found; assuming username and password fields\n"));
                        if ((form = plain_auth_form()) == NULL)
                                goto nomem;
                } else {
-                       if (!xmlnode_get_prop(node, "id", &form_id) && !strcmp(form_id, "auth_form"))
-                               form = parse_form_node(vpninfo, node, NULL, FORM_FLAVOR_F5, NULL);
-                       else {
+                       form = parse_form_node(vpninfo, node, NULL, FORM_FLAVOR_F5, NULL);
+                       if (form_order==1 && (xmlnode_get_prop(node, "id", &form_id) || strcmp(form_id, "auth_form"))) {
                                vpn_progress(vpninfo, PRG_ERR, _("Unknown form ID '%s' (expected 'auth_form')\n"),
                                             form_id);