Line 0
Link Here
|
|
|
1 |
diff --git a/lib/url.c b/lib/url.c |
2 |
index 02a7ace..42bf1eb 100644 |
3 |
--- lib/url.c |
4 |
+++ lib/url.c |
5 |
@@ -3128,12 +3128,17 @@ ConnectionExists(struct SessionHandle *data, |
6 |
struct connectdata *chosen = 0; |
7 |
bool foundPendingCandidate = FALSE; |
8 |
bool canPipeline = IsPipeliningPossible(data, needle); |
9 |
+ struct connectbundle *bundle; |
10 |
+ |
11 |
#ifdef USE_NTLM |
12 |
- bool wantNTLMhttp = ((data->state.authhost.want & CURLAUTH_NTLM) || |
13 |
- (data->state.authhost.want & CURLAUTH_NTLM_WB)) && |
14 |
- (needle->handler->protocol & PROTO_FAMILY_HTTP) ? TRUE : FALSE; |
15 |
+ bool wantNTLMhttp = ((data->state.authhost.want & |
16 |
+ (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && |
17 |
+ (needle->handler->protocol & PROTO_FAMILY_HTTP)); |
18 |
+ bool wantProxyNTLMhttp = (needle->bits.proxy_user_passwd && |
19 |
+ ((data->state.authproxy.want & |
20 |
+ (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && |
21 |
+ (needle->handler->protocol & PROTO_FAMILY_HTTP))); |
22 |
#endif |
23 |
- struct connectbundle *bundle; |
24 |
|
25 |
*force_reuse = FALSE; |
26 |
*waitpipe = FALSE; |
27 |
@@ -3188,9 +3193,6 @@ ConnectionExists(struct SessionHandle *data, |
28 |
curr = bundle->conn_list->head; |
29 |
while(curr) { |
30 |
bool match = FALSE; |
31 |
-#if defined(USE_NTLM) |
32 |
- bool credentialsMatch = FALSE; |
33 |
-#endif |
34 |
size_t pipeLen; |
35 |
|
36 |
/* |
37 |
@@ -3300,21 +3302,14 @@ ConnectionExists(struct SessionHandle *data, |
38 |
continue; |
39 |
} |
40 |
|
41 |
- if((!(needle->handler->flags & PROTOPT_CREDSPERREQUEST)) |
42 |
-#ifdef USE_NTLM |
43 |
- || (wantNTLMhttp || check->ntlm.state != NTLMSTATE_NONE) |
44 |
-#endif |
45 |
- ) { |
46 |
- /* This protocol requires credentials per connection or is HTTP+NTLM, |
47 |
+ if(!(needle->handler->flags & PROTOPT_CREDSPERREQUEST)) { |
48 |
+ /* This protocol requires credentials per connection, |
49 |
so verify that we're using the same name and password as well */ |
50 |
if(!strequal(needle->user, check->user) || |
51 |
!strequal(needle->passwd, check->passwd)) { |
52 |
/* one of them was different */ |
53 |
continue; |
54 |
} |
55 |
-#if defined(USE_NTLM) |
56 |
- credentialsMatch = TRUE; |
57 |
-#endif |
58 |
} |
59 |
|
60 |
if(!needle->bits.httpproxy || needle->handler->flags&PROTOPT_SSL || |
61 |
@@ -3374,20 +3369,43 @@ ConnectionExists(struct SessionHandle *data, |
62 |
possible. (Especially we must not reuse the same connection if |
63 |
partway through a handshake!) */ |
64 |
if(wantNTLMhttp) { |
65 |
- if(credentialsMatch && check->ntlm.state != NTLMSTATE_NONE) { |
66 |
- chosen = check; |
67 |
+ if(!strequal(needle->user, check->user) || |
68 |
+ !strequal(needle->passwd, check->passwd)) |
69 |
+ continue; |
70 |
+ } |
71 |
+ else if(check->ntlm.state != NTLMSTATE_NONE) { |
72 |
+ /* Connection is using NTLM auth but we don't want NTLM */ |
73 |
+ continue; |
74 |
+ } |
75 |
+ |
76 |
+ /* Same for Proxy NTLM authentication */ |
77 |
+ if(wantProxyNTLMhttp) { |
78 |
+ if(!strequal(needle->proxyuser, check->proxyuser) || |
79 |
+ !strequal(needle->proxypasswd, check->proxypasswd)) |
80 |
+ continue; |
81 |
+ } |
82 |
+ else if(check->proxyntlm.state != NTLMSTATE_NONE) { |
83 |
+ /* Proxy connection is using NTLM auth but we don't want NTLM */ |
84 |
+ continue; |
85 |
+ } |
86 |
+ |
87 |
+ if(wantNTLMhttp || wantProxyNTLMhttp) { |
88 |
+ /* Credentials are already checked, we can use this connection */ |
89 |
+ chosen = check; |
90 |
|
91 |
+ if((wantNTLMhttp && |
92 |
+ (check->ntlm.state != NTLMSTATE_NONE)) || |
93 |
+ (wantProxyNTLMhttp && |
94 |
+ (check->proxyntlm.state != NTLMSTATE_NONE))) { |
95 |
/* We must use this connection, no other */ |
96 |
*force_reuse = TRUE; |
97 |
break; |
98 |
} |
99 |
- else if(credentialsMatch) |
100 |
- /* this is a backup choice */ |
101 |
- chosen = check; |
102 |
+ |
103 |
+ /* Continue look up for a better connection */ |
104 |
continue; |
105 |
} |
106 |
#endif |
107 |
- |
108 |
if(canPipeline) { |
109 |
/* We can pipeline if we want to. Let's continue looking for |
110 |
the optimal connection to use, i.e the shortest pipe that is not |