d004d8
From bf614e0e8a231b820160ebca2bc13afeee44c683 Mon Sep 17 00:00:00 2001
d004d8
From: Isaac Boukris <iboukris@gmail.com>
d004d8
Date: Fri, 27 Jan 2017 00:42:28 +0200
d004d8
Subject: [PATCH 1/3] authneg: clear auth.multi flag at http_done
d004d8
d004d8
This flag is meant for the current request based on authentication
d004d8
state, once the request is done we can clear the flag.
d004d8
d004d8
Also change auth.multi to auth.multipass for better readability.
d004d8
d004d8
Fixes https://github.com/curl/curl/issues/1095
d004d8
Closes https://github.com/curl/curl/pull/1326
d004d8
d004d8
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
d004d8
Reported-by: Michael Kaufmann
d004d8
d004d8
Upstream-commit: 5278462c32a70cd972a8cc824a38f164151d6c6d
d004d8
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d004d8
---
d004d8
 lib/http.c    | 11 ++++++++---
d004d8
 lib/urldata.h |  4 ++--
d004d8
 2 files changed, 10 insertions(+), 5 deletions(-)
d004d8
d004d8
diff --git a/lib/http.c b/lib/http.c
d004d8
index db37cf9..9419bff 100644
d004d8
--- a/lib/http.c
d004d8
+++ b/lib/http.c
d004d8
@@ -585,10 +585,10 @@ output_auth_headers(struct connectdata *conn,
d004d8
           proxy?"Proxy":"Server", auth,
d004d8
           proxy?(conn->proxyuser?conn->proxyuser:""):
d004d8
                 (conn->user?conn->user:""));
d004d8
-    authstatus->multi = (!authstatus->done) ? TRUE : FALSE;
d004d8
+    authstatus->multipass = (!authstatus->done) ? TRUE : FALSE;
d004d8
   }
d004d8
   else
d004d8
-    authstatus->multi = FALSE;
d004d8
+    authstatus->multipass = FALSE;
d004d8
 
d004d8
   return CURLE_OK;
d004d8
 }
d004d8
@@ -1402,6 +1402,11 @@ CURLcode Curl_http_done(struct connectdata *conn,
d004d8
   struct SessionHandle *data = conn->data;
d004d8
   struct HTTP *http =data->state.proto.http;
d004d8
 
d004d8
+  /* Clear multipass flag. If authentication isn't done yet, then it will get
d004d8
+   * a chance to be set back to true when we output the next auth header */
d004d8
+  data->state.authhost.multipass = FALSE;
d004d8
+  data->state.authproxy.multipass = FALSE;
d004d8
+
d004d8
   Curl_unencode_cleanup(conn);
d004d8
 
d004d8
 #ifdef USE_HTTP_NEGOTIATE
d004d8
@@ -1738,7 +1743,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
d004d8
   if(result)
d004d8
     return result;
d004d8
 
d004d8
-  if((data->state.authhost.multi || data->state.authproxy.multi) &&
d004d8
+  if((data->state.authhost.multipass || data->state.authproxy.multipass) &&
d004d8
      (httpreq != HTTPREQ_GET) &&
d004d8
      (httpreq != HTTPREQ_HEAD)) {
d004d8
     /* Auth is required and we are not authenticated yet. Make a PUT or POST
d004d8
diff --git a/lib/urldata.h b/lib/urldata.h
d004d8
index 3e6ace5..7e0c30d 100644
d004d8
--- a/lib/urldata.h
d004d8
+++ b/lib/urldata.h
d004d8
@@ -1143,8 +1143,8 @@ struct auth {
d004d8
                           this resource */
d004d8
   bool done;  /* TRUE when the auth phase is done and ready to do the *actual*
d004d8
                  request */
d004d8
-  bool multi; /* TRUE if this is not yet authenticated but within the auth
d004d8
-                 multipass negotiation */
d004d8
+  bool multipass; /* TRUE if this is not yet authenticated but within the
d004d8
+                     auth multipass negotiation */
d004d8
   bool iestyle; /* TRUE if digest should be done IE-style or FALSE if it should
d004d8
                    be RFC compliant */
d004d8
 };
d004d8
-- 
d004d8
2.13.6
d004d8
d004d8
d004d8
From 8fe4533bc8de3664f8b664fa5ab78739b5ea3d87 Mon Sep 17 00:00:00 2001
d004d8
From: Michael Kaufmann <mail@michael-kaufmann.ch>
d004d8
Date: Sat, 11 Mar 2017 18:22:30 +0100
d004d8
Subject: [PATCH 2/3] curl_easy_reset: Also reset the authentication state
d004d8
d004d8
Follow-up to 5278462
d004d8
See https://github.com/curl/curl/issues/1095
d004d8
d004d8
Upstream-commit: 0afbcfd800c45e766e225e4ce273b128ee6a8c25
d004d8
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d004d8
---
d004d8
 lib/easy.c | 4 ++++
d004d8
 1 file changed, 4 insertions(+)
d004d8
d004d8
diff --git a/lib/easy.c b/lib/easy.c
d004d8
index 13801b2..0e9ba18 100644
d004d8
--- a/lib/easy.c
d004d8
+++ b/lib/easy.c
d004d8
@@ -670,6 +670,10 @@ void curl_easy_reset(CURL *curl)
d004d8
 
d004d8
   data->progress.flags |= PGRS_HIDE;
d004d8
   data->state.current_speed = -1; /* init to negative == impossible */
d004d8
+
d004d8
+  /* zero out authentication data: */
d004d8
+  memset(&data->state.authhost, 0, sizeof(struct auth));
d004d8
+  memset(&data->state.authproxy, 0, sizeof(struct auth));
d004d8
 }
d004d8
 
d004d8
 /*
d004d8
-- 
d004d8
2.13.6
d004d8
d004d8
d004d8
From db75a5b82f0b4b24a838fb91e9d3352d4c4c05f2 Mon Sep 17 00:00:00 2001
d004d8
From: Michael Kaufmann <mail@michael-kaufmann.ch>
d004d8
Date: Sat, 11 Mar 2017 20:06:56 +0100
d004d8
Subject: [PATCH 3/3] tests: fix the authretry tests
d004d8
d004d8
Do not call curl_easy_reset() between the requests, because the
d004d8
auth state must be preserved for these tests.
d004d8
d004d8
Follow-up to 0afbcfd
d004d8
d004d8
Upstream-commit: 8d105209933e27293cfc4f224614cea57ddd8372
d004d8
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d004d8
---
d004d8
 tests/libtest/libauthretry.c | 5 -----
d004d8
 1 file changed, 5 deletions(-)
d004d8
d004d8
diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c
d004d8
index 9576132..6342252 100644
d004d8
--- a/tests/libtest/libauthretry.c
d004d8
+++ b/tests/libtest/libauthretry.c
d004d8
@@ -111,12 +111,10 @@ int test(char *url)
d004d8
   res = send_wrong_password(curl, url, 100, main_auth_scheme);
d004d8
   if (res != CURLE_OK)
d004d8
       goto test_cleanup;
d004d8
-  curl_easy_reset(curl);
d004d8
 
d004d8
   res = send_right_password(curl, url, 200, fallback_auth_scheme);
d004d8
   if (res != CURLE_OK)
d004d8
       goto test_cleanup;
d004d8
-  curl_easy_reset(curl);
d004d8
 
d004d8
   curl_easy_cleanup(curl);
d004d8
 
d004d8
@@ -131,17 +129,14 @@ int test(char *url)
d004d8
   res = send_wrong_password(curl, url, 300, main_auth_scheme);
d004d8
   if (res != CURLE_OK)
d004d8
       goto test_cleanup;
d004d8
-  curl_easy_reset(curl);
d004d8
 
d004d8
   res = send_wrong_password(curl, url, 400, fallback_auth_scheme);
d004d8
   if (res != CURLE_OK)
d004d8
       goto test_cleanup;
d004d8
-  curl_easy_reset(curl);
d004d8
 
d004d8
   res = send_right_password(curl, url, 500, fallback_auth_scheme);
d004d8
   if (res != CURLE_OK)
d004d8
       goto test_cleanup;
d004d8
-  curl_easy_reset(curl);
d004d8
 
d004d8
 test_cleanup:
d004d8
 
d004d8
-- 
d004d8
2.13.6
d004d8