mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
moved the proxyuser and proxypasswd fields from the sessionhandle to the
connectdata to work as expected
This commit is contained in:
parent
1a192c489b
commit
071c95128e
@ -732,7 +732,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef USE_SSLEAY
|
#ifdef USE_SSLEAY
|
||||||
if(data->state.authwant == CURLAUTH_NTLM) {
|
if(data->state.authwant == CURLAUTH_NTLM) {
|
||||||
result = Curl_output_ntlm(conn);
|
result = Curl_output_ntlm(conn, FALSE);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ typedef enum {
|
|||||||
CURLntlm Curl_input_ntlm(struct connectdata *conn, char *header);
|
CURLntlm Curl_input_ntlm(struct connectdata *conn, char *header);
|
||||||
|
|
||||||
/* this is for creating ntlm header output */
|
/* this is for creating ntlm header output */
|
||||||
CURLcode Curl_output_ntlm(struct connectdata *conn);
|
CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
|
||||||
|
|
||||||
void Curl_ntlm_cleanup(struct SessionHandle *data);
|
void Curl_ntlm_cleanup(struct SessionHandle *data);
|
||||||
|
|
||||||
|
113
lib/url.c
113
lib/url.c
@ -167,6 +167,11 @@ RETSIGTYPE alarmfunc(int signal)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void Curl_safefree(void *ptr)
|
||||||
|
{
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the internal function curl_easy_cleanup() calls. This should
|
* This is the internal function curl_easy_cleanup() calls. This should
|
||||||
@ -194,11 +199,8 @@ CURLcode Curl_close(struct SessionHandle *data)
|
|||||||
if(data->change.cookielist) /* clean up list if any */
|
if(data->change.cookielist) /* clean up list if any */
|
||||||
curl_slist_free_all(data->change.cookielist);
|
curl_slist_free_all(data->change.cookielist);
|
||||||
|
|
||||||
if(data->state.auth_host)
|
Curl_safefree(data->state.auth_host);
|
||||||
free(data->state.auth_host);
|
Curl_safefree(data->state.scratch);
|
||||||
|
|
||||||
if(data->state.scratch)
|
|
||||||
free(data->state.scratch);
|
|
||||||
|
|
||||||
if(data->change.proxy_alloc)
|
if(data->change.proxy_alloc)
|
||||||
free(data->change.proxy);
|
free(data->change.proxy);
|
||||||
@ -209,8 +211,7 @@ CURLcode Curl_close(struct SessionHandle *data)
|
|||||||
if(data->change.url_alloc)
|
if(data->change.url_alloc)
|
||||||
free(data->change.url);
|
free(data->change.url);
|
||||||
|
|
||||||
if(data->state.headerbuff)
|
Curl_safefree(data->state.headerbuff);
|
||||||
free(data->state.headerbuff);
|
|
||||||
|
|
||||||
#ifndef CURL_DISABLE_HTTP
|
#ifndef CURL_DISABLE_HTTP
|
||||||
if(data->set.cookiejar) {
|
if(data->set.cookiejar) {
|
||||||
@ -225,8 +226,7 @@ CURLcode Curl_close(struct SessionHandle *data)
|
|||||||
/* free the connection cache */
|
/* free the connection cache */
|
||||||
free(data->state.connects);
|
free(data->state.connects);
|
||||||
|
|
||||||
if(data->info.contenttype)
|
Curl_safefree(data->info.contenttype);
|
||||||
free(data->info.contenttype);
|
|
||||||
|
|
||||||
Curl_digest_cleanup(data);
|
Curl_digest_cleanup(data);
|
||||||
|
|
||||||
@ -1233,14 +1233,9 @@ CURLcode Curl_disconnect(struct connectdata *conn)
|
|||||||
/* This is set if protocol-specific cleanups should be made */
|
/* This is set if protocol-specific cleanups should be made */
|
||||||
conn->curl_disconnect(conn);
|
conn->curl_disconnect(conn);
|
||||||
|
|
||||||
if(conn->proto.generic)
|
Curl_safefree(conn->proto.generic);
|
||||||
free(conn->proto.generic);
|
Curl_safefree(conn->newurl);
|
||||||
|
Curl_safefree(conn->path); /* the URL path part */
|
||||||
if(conn->newurl)
|
|
||||||
free(conn->newurl);
|
|
||||||
|
|
||||||
if(conn->path) /* the URL path part */
|
|
||||||
free(conn->path);
|
|
||||||
|
|
||||||
#ifdef USE_SSLEAY
|
#ifdef USE_SSLEAY
|
||||||
Curl_SSL_Close(conn);
|
Curl_SSL_Close(conn);
|
||||||
@ -1252,32 +1247,20 @@ CURLcode Curl_disconnect(struct connectdata *conn)
|
|||||||
if(-1 != conn->firstsocket)
|
if(-1 != conn->firstsocket)
|
||||||
sclose(conn->firstsocket);
|
sclose(conn->firstsocket);
|
||||||
|
|
||||||
if(conn->user)
|
Curl_safefree(conn->user);
|
||||||
free(conn->user);
|
Curl_safefree(conn->passwd);
|
||||||
if(conn->passwd)
|
Curl_safefree(conn->proxyuser);
|
||||||
free(conn->passwd);
|
Curl_safefree(conn->proxypasswd);
|
||||||
|
Curl_safefree(conn->allocptr.proxyuserpwd);
|
||||||
if(conn->allocptr.proxyuserpwd)
|
Curl_safefree(conn->allocptr.uagent);
|
||||||
free(conn->allocptr.proxyuserpwd);
|
Curl_safefree(conn->allocptr.userpwd);
|
||||||
if(conn->allocptr.uagent)
|
Curl_safefree(conn->allocptr.accept_encoding);
|
||||||
free(conn->allocptr.uagent);
|
Curl_safefree(conn->allocptr.rangeline);
|
||||||
if(conn->allocptr.userpwd)
|
Curl_safefree(conn->allocptr.ref);
|
||||||
free(conn->allocptr.userpwd);
|
Curl_safefree(conn->allocptr.cookie);
|
||||||
if(conn->allocptr.accept_encoding)
|
Curl_safefree(conn->allocptr.host);
|
||||||
free(conn->allocptr.accept_encoding);
|
Curl_safefree(conn->allocptr.cookiehost);
|
||||||
if(conn->allocptr.rangeline)
|
Curl_safefree(conn->proxyhost);
|
||||||
free(conn->allocptr.rangeline);
|
|
||||||
if(conn->allocptr.ref)
|
|
||||||
free(conn->allocptr.ref);
|
|
||||||
if(conn->allocptr.cookie)
|
|
||||||
free(conn->allocptr.cookie);
|
|
||||||
if(conn->allocptr.host)
|
|
||||||
free(conn->allocptr.host);
|
|
||||||
if(conn->allocptr.cookiehost)
|
|
||||||
free(conn->allocptr.cookiehost);
|
|
||||||
|
|
||||||
if(conn->proxyhost)
|
|
||||||
free(conn->proxyhost);
|
|
||||||
|
|
||||||
Curl_free_ssl_config(&conn->ssl_config);
|
Curl_free_ssl_config(&conn->ssl_config);
|
||||||
|
|
||||||
@ -1722,8 +1705,8 @@ static CURLcode ConnectPlease(struct connectdata *conn,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (conn->data->set.proxytype == CURLPROXY_SOCKS5) {
|
if (conn->data->set.proxytype == CURLPROXY_SOCKS5) {
|
||||||
return handleSock5Proxy(conn->data->state.proxyuser,
|
return handleSock5Proxy(conn->proxyuser,
|
||||||
conn->data->state.proxypasswd,
|
conn->proxypasswd,
|
||||||
conn,
|
conn,
|
||||||
conn->firstsocket) ?
|
conn->firstsocket) ?
|
||||||
CURLE_COULDNT_CONNECT : CURLE_OK;
|
CURLE_COULDNT_CONNECT : CURLE_OK;
|
||||||
@ -2065,29 +2048,36 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
* Take care of proxy authentication stuff
|
* Take care of proxy authentication stuff
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
if(conn->bits.proxy_user_passwd) {
|
if(conn->bits.proxy_user_passwd) {
|
||||||
data->state.proxyuser[0] =0;
|
char proxyuser[MAX_CURL_USER_LENGTH]="";
|
||||||
data->state.proxypasswd[0]=0;
|
char proxypasswd[MAX_CURL_PASSWORD_LENGTH]="";
|
||||||
|
|
||||||
if(*data->set.proxyuserpwd != ':') {
|
if(*data->set.proxyuserpwd != ':') {
|
||||||
/* the name is given, get user+password */
|
/* the name is given, get user+password */
|
||||||
sscanf(data->set.proxyuserpwd, "%127[^:]:%127[^\n]",
|
sscanf(data->set.proxyuserpwd, "%127[^:]:%127[^\n]",
|
||||||
data->state.proxyuser, data->state.proxypasswd);
|
proxyuser, proxypasswd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* no name given, get the password only */
|
/* no name given, get the password only */
|
||||||
sscanf(data->set.proxyuserpwd+1, "%127[^\n]", data->state.proxypasswd);
|
sscanf(data->set.proxyuserpwd+1, "%127[^\n]", proxypasswd);
|
||||||
|
|
||||||
/* check for password, if no ask for one */
|
/* check for password, if no ask for one */
|
||||||
if( !data->state.proxypasswd[0] ) {
|
if( !proxypasswd[0] ) {
|
||||||
if(data->set.fpasswd( data->set.passwd_client,
|
if(data->set.fpasswd( data->set.passwd_client,
|
||||||
"proxy password:",
|
"proxy password:",
|
||||||
data->state.proxypasswd,
|
proxypasswd,
|
||||||
sizeof(data->state.proxypasswd))) {
|
sizeof(proxypasswd))) {
|
||||||
failf(data, "Bad password from password callback");
|
failf(data, "Bad password from password callback");
|
||||||
return CURLE_BAD_PASSWORD_ENTERED;
|
return CURLE_BAD_PASSWORD_ENTERED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conn->proxyuser = strdup(proxyuser);
|
||||||
|
if(!conn->proxyuser)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
conn->proxypasswd = strdup(proxypasswd);
|
||||||
|
if(!conn->proxypasswd)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
@ -2097,7 +2087,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
conn->ppath = conn->path;
|
conn->ppath = conn->path;
|
||||||
conn->hostname = conn->name;
|
conn->hostname = conn->name;
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Detect what (if any) proxy to use
|
* Detect what (if any) proxy to use
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
@ -2215,8 +2204,20 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
"%" MAX_CURL_PASSWORD_LENGTH_TXT "[^@]",
|
"%" MAX_CURL_PASSWORD_LENGTH_TXT "[^@]",
|
||||||
user, passwd))) {
|
user, passwd))) {
|
||||||
/* found user and password, rip them out */
|
/* found user and password, rip them out */
|
||||||
strcpy(data->state.proxyuser, user);
|
if(conn->proxyuser)
|
||||||
strcpy(data->state.proxypasswd, passwd);
|
free(conn->proxyuser);
|
||||||
|
conn->proxyuser = strdup(user);
|
||||||
|
|
||||||
|
if(!conn->proxyuser)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
if(conn->proxypasswd)
|
||||||
|
free(conn->proxypasswd);
|
||||||
|
conn->proxypasswd = strdup(passwd);
|
||||||
|
|
||||||
|
if(!conn->proxypasswd)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
conn->bits.proxy_user_passwd = TRUE; /* enable it */
|
conn->bits.proxy_user_passwd = TRUE; /* enable it */
|
||||||
|
|
||||||
ptr = strdup(ptr+1);
|
ptr = strdup(ptr+1);
|
||||||
@ -2976,7 +2977,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
if(conn->bits.proxy_user_passwd) {
|
if(conn->bits.proxy_user_passwd) {
|
||||||
char *authorization;
|
char *authorization;
|
||||||
snprintf(data->state.buffer, BUFSIZE, "%s:%s",
|
snprintf(data->state.buffer, BUFSIZE, "%s:%s",
|
||||||
data->state.proxyuser, data->state.proxypasswd);
|
conn->proxyuser, conn->proxypasswd);
|
||||||
if(Curl_base64_encode(data->state.buffer, strlen(data->state.buffer),
|
if(Curl_base64_encode(data->state.buffer, strlen(data->state.buffer),
|
||||||
&authorization) >= 0) {
|
&authorization) >= 0) {
|
||||||
if(conn->allocptr.proxyuserpwd)
|
if(conn->allocptr.proxyuserpwd)
|
||||||
|
@ -42,4 +42,5 @@ bool Curl_ssl_config_matches(struct ssl_config_data* data,
|
|||||||
bool Curl_clone_ssl_config(struct ssl_config_data* source,
|
bool Curl_clone_ssl_config(struct ssl_config_data* source,
|
||||||
struct ssl_config_data* dest);
|
struct ssl_config_data* dest);
|
||||||
void Curl_free_ssl_config(struct ssl_config_data* sslc);
|
void Curl_free_ssl_config(struct ssl_config_data* sslc);
|
||||||
|
void Curl_safefree(void *ptr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -416,6 +416,9 @@ struct connectdata {
|
|||||||
char *user; /* user name string, allocated */
|
char *user; /* user name string, allocated */
|
||||||
char *passwd; /* password string, allocated */
|
char *passwd; /* password string, allocated */
|
||||||
|
|
||||||
|
char *proxyuser; /* proxy user name string, allocated */
|
||||||
|
char *proxypasswd; /* proxy password string, allocated */
|
||||||
|
|
||||||
struct timeval now; /* "current" time */
|
struct timeval now; /* "current" time */
|
||||||
struct timeval created; /* creation time */
|
struct timeval created; /* creation time */
|
||||||
int firstsocket; /* the main socket to use */
|
int firstsocket; /* the main socket to use */
|
||||||
@ -618,8 +621,6 @@ struct UrlState {
|
|||||||
} used_interface;
|
} used_interface;
|
||||||
|
|
||||||
/* buffers to store authentication data in, as parsed from input options */
|
/* buffers to store authentication data in, as parsed from input options */
|
||||||
char proxyuser[MAX_CURL_USER_LENGTH];
|
|
||||||
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
|
|
||||||
struct timeval keeps_speed; /* for the progress meter really */
|
struct timeval keeps_speed; /* for the progress meter really */
|
||||||
|
|
||||||
/* 'connects' will be an allocated array with pointers. If the pointer is
|
/* 'connects' will be an allocated array with pointers. If the pointer is
|
||||||
|
Loading…
Reference in New Issue
Block a user