]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
auth: Implement special handling of <select> dropdowns on XML POST
authorKevin Cernekee <cernekee@gmail.com>
Sun, 17 Feb 2013 00:18:04 +0000 (16:18 -0800)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 17 Feb 2013 21:54:07 +0000 (21:54 +0000)
Experimentation with the Cisco AnyConnect client showed that the
following changes need to be made for compatibility:

1) If the "value" attribute is missing from the <option> node, use the
XML node content instead.  i.e. this should post as
"<dropdown>vpn</dropdown>":

    <select name="dropdown">
      <option>vpn</option>
    </select>

And this should post as "<dropdown>optname</dropdown>":

    <select name="dropdown">
      <option value="optname">vpn</option>
    </select>

2) If the name of the <select> node happens to be "group_list", put the
response in a special <group-select> node right under the <config-auth>
node, instead of putting it under the <auth> node.  (These strings are
hardcoded into the Cisco client.)

Reported-by: Fabian Jäger <fabian.jaeger@chungwasoft.com>
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
auth.c

diff --git a/auth.c b/auth.c
index 5634224b8c52b99a9f66a62f5db022d23fe12cf6..a4f95d6818a8fc8ff7f3fafc41c76a00610b4c37 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -143,6 +143,8 @@ static int parse_auth_choice(struct openconnect_info *vpninfo, struct oc_auth_fo
                        continue;
 
                form_id = (char *)xmlGetProp(xml_node, (unsigned char *)"value");
+               if (!form_id)
+                       form_id = (char *)xmlNodeGetContent(xml_node);
                if (!form_id)
                        continue;
 
@@ -678,6 +680,7 @@ void free_auth_form(struct oc_auth_form *form)
  *     <username><!-- same treatment as the old form options --></username>
  *     <password><!-- ditto -->
  *   </auth>
+ *   <group-select><!-- name of selected authgroup --></group-select>
  *   <host-scan-token><!-- vpninfo->csd_ticket --></host-scan-token>
  */
 
@@ -793,6 +796,14 @@ static int xmlpost_append_form_opts(struct openconnect_info *vpninfo,
                goto bad;
 
        for (opt = form->opts; opt; opt = opt->next) {
+               /* group_list: create a new <group-select> node under <config-auth> */
+               if (!strcmp(opt->name, "group_list")) {
+                       if (!xmlNewTextChild(root, NULL, XCAST("group-select"), XCAST(opt->value)))
+                               goto bad;
+                       continue;
+               }
+
+               /* everything else: create <foo>user_input</foo> under <auth> */
                if (!xmlNewTextChild(node, NULL, XCAST(opt->name), XCAST(opt->value)))
                        goto bad;
        }