credential: stop using the_repository

Stop using `the_repository` in the "credential" subsystem by passing in
a repository when filling, approving or rejecting credentials.

Adjust callers accordingly by using `the_repository`. While there may be
some callers that have a repository available in their context, this
trivial conversion allows for easier verification and bubbles up the use
of `the_repository` by one level.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-12-17 07:43:56 +01:00
committed by Junio C Hamano
parent 71e5afee8b
commit 6c27d22276
6 changed files with 46 additions and 43 deletions

24
http.c
View File

@@ -609,7 +609,7 @@ static void init_curl_http_auth(CURL *result)
}
}
credential_fill(&http_auth, 1);
credential_fill(the_repository, &http_auth, 1);
if (http_auth.password) {
if (always_auth_proactively()) {
@@ -652,7 +652,7 @@ static void init_curl_proxy_auth(CURL *result)
{
if (proxy_auth.username) {
if (!proxy_auth.password && !proxy_auth.credential)
credential_fill(&proxy_auth, 1);
credential_fill(the_repository, &proxy_auth, 1);
set_proxyauth_name_password(result);
}
@@ -686,7 +686,7 @@ static int has_cert_password(void)
cert_auth.host = xstrdup("");
cert_auth.username = xstrdup("");
cert_auth.path = xstrdup(ssl_cert);
credential_fill(&cert_auth, 0);
credential_fill(the_repository, &cert_auth, 0);
}
return 1;
}
@@ -700,7 +700,7 @@ static int has_proxy_cert_password(void)
proxy_cert_auth.host = xstrdup("");
proxy_cert_auth.username = xstrdup("");
proxy_cert_auth.path = xstrdup(http_proxy_ssl_cert);
credential_fill(&proxy_cert_auth, 0);
credential_fill(the_repository, &proxy_cert_auth, 0);
}
return 1;
}
@@ -1784,9 +1784,9 @@ static int handle_curl_result(struct slot_results *results)
curl_errorstr, sizeof(curl_errorstr));
if (results->curl_result == CURLE_OK) {
credential_approve(&http_auth);
credential_approve(&proxy_auth);
credential_approve(&cert_auth);
credential_approve(the_repository, &http_auth);
credential_approve(the_repository, &proxy_auth);
credential_approve(the_repository, &cert_auth);
return HTTP_OK;
} else if (results->curl_result == CURLE_SSL_CERTPROBLEM) {
/*
@@ -1795,7 +1795,7 @@ static int handle_curl_result(struct slot_results *results)
* with the certificate. So we reject the credential to
* avoid caching or saving a bad password.
*/
credential_reject(&cert_auth);
credential_reject(the_repository, &cert_auth);
return HTTP_NOAUTH;
} else if (results->curl_result == CURLE_SSL_PINNEDPUBKEYNOTMATCH) {
return HTTP_NOMATCHPUBLICKEY;
@@ -1808,7 +1808,7 @@ static int handle_curl_result(struct slot_results *results)
credential_clear_secrets(&http_auth);
return HTTP_REAUTH;
}
credential_reject(&http_auth);
credential_reject(the_repository, &http_auth);
if (always_auth_proactively())
http_proactive_auth = PROACTIVE_AUTH_NONE;
return HTTP_NOAUTH;
@@ -1822,7 +1822,7 @@ static int handle_curl_result(struct slot_results *results)
}
} else {
if (results->http_connectcode == 407)
credential_reject(&proxy_auth);
credential_reject(the_repository, &proxy_auth);
if (!curl_errorstr[0])
strlcpy(curl_errorstr,
curl_easy_strerror(results->curl_result),
@@ -2210,7 +2210,7 @@ static int http_request_reauth(const char *url,
int ret;
if (always_auth_proactively())
credential_fill(&http_auth, 1);
credential_fill(the_repository, &http_auth, 1);
ret = http_request(url, result, target, options);
@@ -2251,7 +2251,7 @@ static int http_request_reauth(const char *url,
BUG("Unknown http_request target");
}
credential_fill(&http_auth, 1);
credential_fill(the_repository, &http_auth, 1);
ret = http_request(url, result, target, options);
}