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

@ -27,6 +27,8 @@
#include <curl/curl.h>
#include "vauth.h"
#include "urldata.h"
#include "strcase.h"
#include "curl_multibyte.h"
#include "curl_printf.h"
@ -144,3 +146,18 @@ bool Curl_auth_user_contains_domain(const char *user)
return valid;
}
/*
* Curl_auth_ollowed_to_host() tells if authentication, cookies or other
* "sensitive data" can (still) be sent to this host.
*/
bool Curl_auth_allowed_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)));
}

View file

@ -54,6 +54,12 @@ struct gsasldata;
#define GSS_ERROR(status) ((status) & 0x80000000)
#endif
/*
* Curl_auth_allowed_to_host() tells if authentication, cookies or other
* "sensitive data" can (still) be sent to this host.
*/
bool Curl_auth_allowed_to_host(struct Curl_easy *data);
/* This is used to build a SPN string */
#if !defined(USE_WINDOWS_SSPI)
char *Curl_auth_build_spn(const char *service, const char *host,