Skip to content

Commit

Permalink
auth: Implement special handling of <select> dropdowns on XML POST
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cernekee authored and David Woodhouse committed Feb 17, 2013
1 parent 91462d2 commit 5c4d37a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions auth.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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>
*/

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 5c4d37a

Please sign in to comment.