http, vauth: always provide Curl_allow_auth_to_host() functionality

This function is currently located in the lib/http.c module and is
therefore disabled by the CURL_DISABLE_HTTP conditional token.

As it may be called by TLS backends, disabling HTTP results in an
undefined reference error at link time.

Move this function to vauth/vauth.c to always provide it and rename it
as Curl_auth_allowed_to_host() to respect the vauth module naming
convention.

Closes #9600
This commit is contained in:
Patrick Monnerat 2022-09-27 01:01:16 +02:00 committed by Daniel Stenberg
parent 4adee03cd4
commit 72652c0613
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 29 additions and 25 deletions

View file

@ -721,21 +721,6 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
return result;
}
/*
* Curl_allow_auth_to_host() tells if authentication, cookies or other
* "sensitive data" can (still) be sent to this host.
*/
bool Curl_allow_auth_to_host(struct Curl_easy *data)
{
struct connectdata *conn = data->conn;
return (!data->state.this_is_a_follow ||
data->set.allow_auth_to_other_hosts ||
(data->state.first_host &&
strcasecompare(data->state.first_host, conn->host.name) &&
(data->state.first_remote_port == conn->remote_port) &&
(data->state.first_remote_protocol == conn->handler->protocol)));
}
#ifndef CURL_DISABLE_HTTP_AUTH
/*
* Output the correct authentication header depending on the auth type
@ -934,7 +919,7 @@ Curl_http_output_auth(struct Curl_easy *data,
/* To prevent the user+password to get sent to other than the original host
due to a location-follow */
if(Curl_allow_auth_to_host(data)
if(Curl_auth_allowed_to_host(data)
#ifndef CURL_DISABLE_NETRC
|| conn->bits.netrc
#endif
@ -1988,7 +1973,7 @@ CURLcode Curl_add_custom_headers(struct Curl_easy *data,
checkprefix("Cookie:", compare)) &&
/* be careful of sending this potentially sensitive header to
other hosts */
!Curl_allow_auth_to_host(data))
!Curl_auth_allowed_to_host(data))
;
else {
#ifdef USE_HYPER