From: David Woodhouse Date: Thu, 30 May 2013 12:40:52 +0000 (+0100) Subject: When falling back to non-xmlpost, revert to original URL X-Git-Tag: v5.01~15 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=152d4e4a296984a538d7d6b52a18b24ce32bffdb;p=users%2Fdwmw2%2Fopenconnect.git When falling back to non-xmlpost, revert to original URL If the XML POST attempt ended up being redirected, we don't want to stay at that location when we fall back to the old method. We want to start again from scratch. Signed-off-by: David Woodhouse --- diff --git a/http.c b/http.c index 1437b897..292970ac 100644 --- a/http.c +++ b/http.c @@ -967,6 +967,8 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo) char request_body[2048]; const char *request_body_type = "application/x-www-form-urlencoded"; const char *method = "POST"; + char *orig_host = NULL, *orig_path = NULL; + int orig_port = 0; int xmlpost = 1; /* Step 1: Unlock software token (if applicable) */ @@ -992,6 +994,10 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo) if (result < 0) return result; + orig_host = strdup(vpninfo->hostname); + orig_path = vpninfo->urlpath ? strdup(vpninfo->urlpath) : NULL; + orig_port = vpninfo->port; + for (tries = 0; ; tries++) { if (tries == 3) { fail: @@ -1002,6 +1008,14 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo) request_body_type = NULL; request_body[0] = 0; method = "GET"; + if (orig_host) { + openconnect_set_hostname(vpninfo, orig_host); + orig_host = NULL; + free(vpninfo->urlpath); + vpninfo->urlpath = orig_path; + orig_path = NULL; + vpninfo->port = orig_port; + } openconnect_close_https(vpninfo, 0); } else { return -EIO; @@ -1034,6 +1048,9 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo) if (xmlpost) vpn_progress(vpninfo, PRG_INFO, _("XML POST enabled\n")); + free (orig_host); + free (orig_path); + /* Step 4: Run the CSD trojan, if applicable */ if (vpninfo->csd_starturl && vpninfo->csd_waiturl) { char *form_path = NULL; diff --git a/www/changelog.xml b/www/changelog.xml index ec848da9..4f4ad2eb 100644 --- a/www/changelog.xml +++ b/www/changelog.xml @@ -17,6 +17,7 @@