]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
http: Fix redirect handling in auth form loop
authorKevin Cernekee <cernekee@gmail.com>
Sun, 17 Feb 2013 00:18:06 +0000 (16:18 -0800)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 17 Feb 2013 21:54:14 +0000 (21:54 +0000)
The gateway may ask the user to fill out different forms that live at
different URLs, e.g.

    GET /+webvpn+/index.html
    (returns <form method="post" action="/+webvpn+/index.html"> and
     username/password form elements)
    POST /+webvpn+/index.html
    (returns <form method="post" action="/+webvpn+/login/challenge.html">
     and challenge/response form elements)
    POST /+webvpn+/login/challenge.html
    (returns <auth> node with valid cookie)

The refactored openconnect_obtain_cookie() loop tried to post the
challenge/response data to index.html, preventing successful login.  This
patch changes the logic so that it will honor the new "action" attribute
if present.

This probably does not affect XML POST mode, because XML POST <form> tags
do not seem to use attributes.

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>
http.c

diff --git a/http.c b/http.c
index bcc4e988a6be4e2865450af60f2fa1cee56e9cb1..d6a3636cf8cbd1bf08120855744e3f56a89d018a 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1072,6 +1072,10 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo)
                result = parse_xml_response(vpninfo, form_buf, &form);
                if (result < 0)
                        goto out;
+               if (form->action) {
+                       vpninfo->redirect_url = strdup(form->action);
+                       handle_redirect(vpninfo);
+               }
        }
 
        /* A return value of 2 means the XML form indicated