git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] http.c: fix parsing of http.sslCertPasswordProtected variable

From
Kyle J. McKay <mackyle@gmail.com>
Date
Jul 13, 2013, 19:28 UTC
Message-ID
<35166ba04d1ce901e0fb63a5c522970@f74d39fa044aa309eaea14b9f57fe79>
In-Reply-To
<20130712190531.GD8482@google.com>
On Jul 12, 2013, at 12:05, Jonathan Nieder wrote:
Show 24 quoted lines
> Junio C Hamano wrote:
>
>> The existing code triggers only when the configuration variable is
>> set to true.  Once the variable is set to true in a more generic
>> configuration file (e.g. ~/.gitconfig), it cannot be overriden to
>> false in the repository specific one (e.g. .git/config).
> [...]
>> --- a/http.c
>> +++ b/http.c
>> @@ -160,8 +160,7 @@ static int http_options(const char *var, const  
>> char *value, void *cb)
>> 	if (!strcmp("http.sslcainfo", var))
>> 		return git_config_string(&ssl_cainfo, var, value);
>> 	if (!strcmp("http.sslcertpasswordprotected", var)) {
>> -		if (git_config_bool(var, value))
>> -			ssl_cert_password_required = 1;
>> +		ssl_cert_password_required = git_config_bool(var, value);
>
> Thanks for catching it.  The documentation doesn't say anything about
> this "can only enable and cannot disable" behavior and the usual
> pattern is to allow later settings to override earlier ones, so this
> change looks good.
>
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Looks good to me too.
> FWIW the GIT_SSL_CERT_PASSWORD_PROTECTED envvar has a similar "can
> only enable" behavior, but since it's documented, that's not as big
> of a problem.
Hmmm.  git help config says:
> Can be overridden by the GIT_SSL_CERT_PASSWORD_PROTECTED environment
> variable.

in the http.sslCertPasswordProtected section of the help. It doesn't say it can only be overridden to on. Is there some other documentation for that somewhere I'm missing about being can-only-enable?

If not, perhaps a change something like the following could be added to the patch:

diff --git a/http.c b/http.c
index 2d086ae..83fc6b4 100644
--- a/http.c
+++ b/http.c
@@ -404,11 +404,10 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
 		curl_ftp_no_epsv = 1;
 
 	if (url) {
+		int pwdreq = git_env_bool("GIT_SSL_CERT_PASSWORD_PROTECTED", -1);
 		credential_from_url(&http_auth, url);
-		if (!ssl_cert_password_required &&
-		    getenv("GIT_SSL_CERT_PASSWORD_PROTECTED") &&
-		    !prefixcmp(url, "https://"))
-			ssl_cert_password_required = 1;
+		if (pwdreq != -1 && !prefixcmp(url, "https://"))
+			ssl_cert_password_required = pwdreq;
 	}
 
 #ifndef NO_CURL_EASY_DUPHANDLE
Previous: Junio C Hamano
Message 8 of 8 in “http.c: fix parsing of http.sslCertPasswordProtected variable”
  1. http.c: fix parsing of http.sslCertPasswordProtected variableJunio C Hamano, Jul 12, 2013
  2. Jonathan NiederJul 12, 2013
  3. Junio C HamanoJul 12, 2013
  4. Mark LodatoJul 14, 2013
  5. Junio C HamanoJul 15, 2013
  6. Kyle J. McKayJul 15, 2013
  7. Junio C HamanoJul 15, 2013
  8. Kyle J. McKayJul 13, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.