{"thread":{"id":"45669","subject":"[PATCH v4 0/2] http: few fixes for the proxy configuration handling","startedAt":"2017-04-11T20:22:38Z","lastAt":"2017-04-14T21:23:59Z","messageCount":4,"participants":["Sergey Ryazanov","Jeff King"],"isPatch":true,"patchVersion":4,"patchTotal":2},"messages":[{"id":"316639","messageId":"20170411202219.20165-1-ryazanov.s.a@gmail.com","threadId":"45669","inReplyTo":null,"subject":"[PATCH v4 0/2] http: few fixes for the proxy configuration handling","fromName":"Sergey Ryazanov","fromEmail":"ryazanov.s.a@gmail.com","sentAt":"2017-04-11T20:22:17Z","receivedAt":"2017-04-11T20:22:38Z","isPatch":true,"sender":{"key":"ryazanov.s.a@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11219080?v=4"},"body":"Hello,\n\nthis is few patches, which fixes regressions in the proxy handling.\n\nBoth patches are based on the maint branch.\n\nChanges since v3:\n - fix grammar (thanks to Jeff)\n\nChanges since v2:\n - fix grammar (thanks to Ævar)\n - add new patch which fixes the silent ignoring of proxy missconfiguration\n\nSergey Ryazanov (2):\n  http: honor empty http.proxy option to bypass proxy\n  http: fix the silent ignoring of proxy misconfiguraion\n\n http.c | 13 +++++++++++--\n 1 file changed, 11 insertions(+), 2 deletions(-)\n\n-- \n2.10.2\n\n"},{"id":"316640","messageId":"20170411202219.20165-2-ryazanov.s.a@gmail.com","threadId":"45669","inReplyTo":"20170411202219.20165-1-ryazanov.s.a@gmail.com","subject":"[PATCH v4 1/2] http: honor empty http.proxy option to bypass proxy","fromName":"Sergey Ryazanov","fromEmail":"ryazanov.s.a@gmail.com","sentAt":"2017-04-11T20:22:18Z","receivedAt":"2017-04-11T20:22:39Z","isPatch":true,"sender":{"key":"ryazanov.s.a@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11219080?v=4"},"body":"Curl distinguishes between an empty proxy address and a NULL proxy\naddress. In the first case it completely disables proxy usage, but if\nthe proxy address option is NULL then curl attempts to determine the\nproxy address from the http_proxy environment variable.\n\nAccording to the documentation, if the http.proxy option is set to an\nempty string, git should bypass proxy and connect to the server\ndirectly:\n\n    export http_proxy=http://network-proxy/\n    cd ~/foobar-project\n    git config remote.origin.proxy \"\"\n    git fetch\n\nPreviously, proxy host was configured by one line:\n\n    curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);\n\nCommit 372370f167 (\"http: use credential API to handle proxy\nauthentication\", 2016-01-26) parses the proxy option, then extracts the\nproxy host address and updates the curl configuration, making the\nprevious call a noop:\n\n    credential_from_url(&proxy_auth, curl_http_proxy);\n    curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);\n\nBut if the proxy option is empty then the proxy host field becomes NULL.\nThis forces curl to fall back to detecting the proxy configuration from\nthe environment, causing the http.proxy option to not work anymore.\n\nFix this issue by explicitly handling http.proxy being set the empty\nstring. This also makes the code a bit more clear and should help us\navoid such regressions in the future.\n\nHelped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nHelped-by: Jeff King <peff@peff.net>\nSigned-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>\n---\n\nChanges since v1:\n - explicitly handle this case instead of mangling the common code\n\nChanges since v2:\n - fix grammar (thanks to Ævar)\n\nChanges since v3:\n - no changes\n\n http.c | 10 ++++++++--\n 1 file changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 96d84bb..8be75b2 100644\n--- a/http.c\n+++ b/http.c\n@@ -836,8 +836,14 @@ static CURL *get_curl_handle(void)\n \t\t}\n \t}\n \n-\tif (curl_http_proxy) {\n-\t\tcurl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);\n+\tif (curl_http_proxy && curl_http_proxy[0] == '\\0') {\n+\t\t/*\n+\t\t * Handle case with the empty http.proxy value here to keep\n+\t\t * common code clean.\n+\t\t * NB: empty option disables proxying at all.\n+\t\t */\n+\t\tcurl_easy_setopt(result, CURLOPT_PROXY, \"\");\n+\t} else if (curl_http_proxy) {\n #if LIBCURL_VERSION_NUM >= 0x071800\n \t\tif (starts_with(curl_http_proxy, \"socks5h\"))\n \t\t\tcurl_easy_setopt(result,\n-- \n2.10.2\n\n"},{"id":"316641","messageId":"20170411202219.20165-3-ryazanov.s.a@gmail.com","threadId":"45669","inReplyTo":"20170411202219.20165-1-ryazanov.s.a@gmail.com","subject":"[PATCH v4 2/2] http: fix the silent ignoring of proxy misconfiguraion","fromName":"Sergey Ryazanov","fromEmail":"ryazanov.s.a@gmail.com","sentAt":"2017-04-11T20:22:19Z","receivedAt":"2017-04-11T20:22:41Z","isPatch":true,"sender":{"key":"ryazanov.s.a@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11219080?v=4"},"body":"Earlier, the whole http.proxy option string was passed to curl without\nany preprocessing so curl could complain about the invalid proxy\nconfiguration.\n\nAfter the commit 372370f167 (\"http: use credential API to handle proxy\nauthentication\", 2016-01-26), if the user specified an invalid HTTP\nproxy option in the configuration, then the option parsing silently\nfails and NULL will be passed to curl as a proxy. This forces curl to\nfall back to detecting the proxy configuration from the environment,\ncausing the http.proxy option ignoring.\n\nFix this issue by checking the proxy option parsing result. If parsing\nfailed then print an error message and die. Such behaviour allows the\nuser to quickly figure the proxy misconfiguration and correct it.\n\nHelped-by: Jeff King <peff@peff.net>\nSigned-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>\n---\n\nChanges since v2:\n  - new patch\n\nChanges since v3:\n  - fix grammar (thanks to Jeff)\n\n http.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/http.c b/http.c\nindex 8be75b2..82664dd 100644\n--- a/http.c\n+++ b/http.c\n@@ -867,6 +867,9 @@ static CURL *get_curl_handle(void)\n \t\t\tstrbuf_release(&url);\n \t\t}\n \n+\t\tif (!proxy_auth.host)\n+\t\t\tdie(\"Invalid proxy URL '%s'\", curl_http_proxy);\n+\n \t\tcurl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);\n #if LIBCURL_VERSION_NUM >= 0x071304\n \t\tvar_override(&curl_no_proxy, getenv(\"NO_PROXY\"));\n-- \n2.10.2\n\n"},{"id":"316860","messageId":"20170414212352.aqhi3s7gwygf2fqn@sigill.intra.peff.net","threadId":"45669","inReplyTo":"20170411202219.20165-1-ryazanov.s.a@gmail.com","subject":"Re: [PATCH v4 0/2] http: few fixes for the proxy configuration handling","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-04-14T21:23:52Z","receivedAt":"2017-04-14T21:23:59Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Apr 11, 2017 at 11:22:17PM +0300, Sergey Ryazanov wrote:\n\n> this is few patches, which fixes regressions in the proxy handling.\n> \n> Both patches are based on the maint branch.\n> \n> Changes since v3:\n>  - fix grammar (thanks to Jeff)\n> \n> Changes since v2:\n>  - fix grammar (thanks to Ævar)\n>  - add new patch which fixes the silent ignoring of proxy missconfiguration\n> \n> Sergey Ryazanov (2):\n>   http: honor empty http.proxy option to bypass proxy\n>   http: fix the silent ignoring of proxy misconfiguraion\n> \n>  http.c | 13 +++++++++++--\n>  1 file changed, 11 insertions(+), 2 deletions(-)\n\nThis whole series looks good to me.\n\n-Peff\n"}]}