]> git.ipfire.org Git - thirdparty/git.git/commit
http: allow using netrc for WebDAV-based HTTP protocol
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 23 Feb 2025 01:53:31 +0000 (01:53 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2025 16:49:10 +0000 (08:49 -0800)
commit3306edb3805aac7baf77c4916b5495ff278353e5
tree5e770191b1b4fb953bafb1eb1c1f90046d48ff54
parent2d2a71ce85026edcc40f469678a1035df0dfcf57
http: allow using netrc for WebDAV-based HTTP protocol

For an extended period of time, we've enabled libcurl's netrc
functionality, which will read credentials from the netrc file if none
are provided.  Unfortunately, we have also not documented this fact or
written any tests for it, but people have come to rely on it.

In 610cbc1dfb ("http: allow authenticating proactively", 2024-07-10), we
accidentally broke the ability of users to use the netrc file for the
WebDAV-based HTTP protocol.  Notably, it works on the initial request
but does not work on subsequent requests, which causes failures because
that version of the protocol will necessarily make multiple requests.

This happens because curl_empty_auth_enabled never returns -1, only 0 or
1, and so if http.proactiveAuth is not enabled, the username and
password are always set to empty credentials, which prevents libcurl's
fallback to netrc from working.  However, in other cases, the server
continues to get a 401 response and the credential helper is invoked,
which is the normal behavior, so this was not noticed earlier.

To fix this, change the condition to check for enabling empty auth and
also not having proactive auth enabled, which should result in the
username and password not being set to a single colon in the typical
case, and thus the netrc file being used.

Reported-by: Peter Georg <peter.georg@physik.uni-regensburg.de>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http.c
t/t5540-http-push-webdav.sh