{"thread":{"id":"29692","subject":"[PATCH] Improve http proxy support","startedAt":"2012-02-22T14:04:36Z","lastAt":"2012-02-23T12:52:06Z","messageCount":5,"participants":["Nelson Benítez León","Matthieu Moy","Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"185174","messageId":"CAAUd640GaLz4TGs_Lz6KbSFK0VcEVxGfO6PpSCdhch+fYwVovw@mail.gmail.com","threadId":"29692","inReplyTo":null,"subject":"[PATCH] Improve http proxy support","fromName":"Nelson Benítez León","fromEmail":"nbenitezl@gmail.com","sentAt":"2012-02-22T14:04:36Z","receivedAt":"2012-02-22T14:04:36Z","isPatch":true,"sender":{"key":"nbenitezl@gmail.com","avatar":"https://gravatar.com/avatar/43794fe96eb6be6a99b1334207fa0fffa2c6606a64e2abd5ea994ffb65ddeab3?d=mp&s=160"},"body":"Hi, my initial motivation for this patch was to add NTLM proxy\nauthentication so I could 'git clone' from inside my employers\nnetwork, but apart from doing that, I also added two more features,\nso, this patch adds the following improvements to the http proxy\nsupport:\n\n- Support NTLM proxy authentication (as well as other authentication\nmethods) by setting CURLOPT_PROXYAUTH[1] to CURLAUTH_ANY.\n\n- Look up environment vars http_proxy and HTTP_PROXY in case git\nhttp.proxy config option is not set. This supports system wide proxy\nsupport in terminals.\n\n- Support proxy urls with username but without a password, in which\ncase we interactively ask for the password (as it's already done in\nhttp auth code). This makes possible to not have the password written\ndown in git config files or in env vars.\n\nThanks!\n\n[1] http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXYAUTH\n\n\n--- http.c\t2012-01-19 01:19:22.000000000 +0100\n+++ http.mod2.c\t2012-02-22 14:44:11.727773038 +0100\n@@ -299,8 +299,54 @@\n \tif (curl_ftp_no_epsv)\n \t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n \n-\tif (curl_http_proxy)\n-\t\tcurl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);\n+\tif (!curl_http_proxy) {\n+\t\tconst char *env_proxy;\n+\t\tenv_proxy = getenv(\"HTTP_PROXY\");\n+\t\tif (!env_proxy) {\n+\t\t\tenv_proxy = getenv(\"http_proxy\");\n+\t\t}\n+\t\tif (env_proxy) {\n+\t\t\tcurl_http_proxy = xstrdup(env_proxy);\n+\t\t}\n+\t}\n+\tif (curl_http_proxy) {\n+\t\tchar *at, *colon, *proxyuser;\n+\t\tconst char *cp;\n+\t\tcp = strstr(curl_http_proxy, \"://\");\n+\t\tif (cp == NULL) {\n+\t\t\tcp = curl_http_proxy;\n+\t\t} else {\n+\t\t\tcp += 3;\n+\t\t}\n+\t\tat = strchr(cp, '@');\n+\t\tcolon = strchr(cp, ':');\n+\t\tif (at && (!colon || at < colon)) {\n+\t\t\t/* proxy string has username but no password, ask for password */\n+\t\t\tchar *ask_str, *proxyuser, *proxypass;\n+\t\t\tint len;\n+\t\t\tstruct strbuf pbuf = STRBUF_INIT;\n+\t\t\tlen = at - cp;\n+\t\t\tproxyuser = xmalloc(len + 1);\n+\t\t\tmemcpy(proxyuser, cp, len);\n+\t\t\tproxyuser[len] = '\\0';\n+\t\t\t\n+\t\t\tstrbuf_addf(&pbuf, \"Enter password for proxy %s...\", at+1);\n+\t\t\task_str = strbuf_detach(&pbuf, NULL);\n+\t\t\tproxypass = xstrdup(git_getpass(ask_str));\n+\t\t\t\n+\t\t\tstrbuf_insert(&pbuf, 0, curl_http_proxy, cp - curl_http_proxy);\n+\t\t\tstrbuf_addf(&pbuf, \"%s:%s\", proxyuser, proxypass);\n+\t\t\tstrbuf_add(&pbuf, at, strlen(at));\n+\t\t\tcurl_easy_setopt(result, CURLOPT_PROXY, strbuf_detach(&pbuf, NULL));\n+\t\t\t\n+\t\t\tfree(ask_str);\n+\t\t\tfree(proxyuser);\n+\t\t\tfree(proxypass);\n+\t\t} else {\n+\t\t\tcurl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);\n+\t\t}\n+\t\tcurl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);\n+\t}\n \n \treturn result;\n }\n"},{"id":"185175","messageId":"vpqd397x8fc.fsf@bauges.imag.fr","threadId":"29692","inReplyTo":"CAAUd640GaLz4TGs_Lz6KbSFK0VcEVxGfO6PpSCdhch+fYwVovw@mail.gmail.com","subject":"Re: [PATCH] Improve http proxy support","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-22T14:13:43Z","receivedAt":"2012-02-22T14:13:43Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Nelson Benítez León <nbenitezl@gmail.com> writes:\n\n> Hi, my initial motivation for this patch was to add NTLM proxy\n> authentication [...]\n\nThat sounds interesting, but please read Documentation/SubmittingPatches\nin Git's tree. The formatting of your email is wrong (giving more work\nfor your maintainer) and you need to sign-off your patch to allow your\ncode to be legally included.\n\nThanks,\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"185182","messageId":"87fwe2x1hu.fsf@thomas.inf.ethz.ch","threadId":"29692","inReplyTo":"vpqd397x8fc.fsf@bauges.imag.fr","subject":"Re: [PATCH] Improve http proxy support","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2012-02-22T16:43:25Z","receivedAt":"2012-02-22T16:43:25Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Nelson Benítez León <nbenitezl@gmail.com> writes:\n>\n>> Hi, my initial motivation for this patch was to add NTLM proxy\n>> authentication [...]\n>\n> That sounds interesting, but please read Documentation/SubmittingPatches\n> in Git's tree. The formatting of your email is wrong (giving more work\n> for your maintainer) and you need to sign-off your patch to allow your\n> code to be legally included.\n\nJudging from the message, it also conflates three changes into one\npatch.  Don't do that.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"185269","messageId":"CAAUd643RHOrhm+gfW5UeXfjcG0Xr+q0nxzAVqYsh8VxhhP_m1g@mail.gmail.com","threadId":"29692","inReplyTo":"vpqd397x8fc.fsf@bauges.imag.fr","subject":"Re: [PATCH] Improve http proxy support","fromName":"Nelson Benítez León","fromEmail":"nbenitezl@gmail.com","sentAt":"2012-02-23T12:20:45Z","receivedAt":"2012-02-23T12:20:45Z","isPatch":true,"sender":{"key":"nbenitezl@gmail.com","avatar":"https://gravatar.com/avatar/43794fe96eb6be6a99b1334207fa0fffa2c6606a64e2abd5ea994ffb65ddeab3?d=mp&s=160"},"body":"El día 22 de febrero de 2012 15:13, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> escribió:\n> Nelson Benítez León <nbenitezl@gmail.com> writes:\n>\n>> Hi, my initial motivation for this patch was to add NTLM proxy\n>> authentication [...]\n>\n> That sounds interesting, but please read Documentation/SubmittingPatches\n> in Git's tree. The formatting of your email is wrong (giving more work\n> for your maintainer) and you need to sign-off your patch to allow your\n> code to be legally included.\n\nThank you for the advice, I read README file (couldn't find a HACKING\none) and the git website, and neither of those had a reference to\nSubmittingPatches..\n"},{"id":"185271","messageId":"1330001526-23772-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"29692","inReplyTo":"CAAUd643RHOrhm+gfW5UeXfjcG0Xr+q0nxzAVqYsh8VxhhP_m1g@mail.gmail.com","subject":"[PATCH] README: point to Documentation/SubmittingPatches","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-02-23T12:52:06Z","receivedAt":"2012-02-23T12:52:06Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"It was indeed not obvious for new contributors to find this document in\nthe source tree, since there were no reference to it outside the\nDocumentation/ directory.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n> Thank you for the advice, I read README file (couldn't find a HACKING\n> one) and the git website, and neither of those had a reference to\n> SubmittingPatches..\n\nIndeed. As a bonnus, here's a submission that should match the\nguidelines (above --- is the commit message, and here is the place for\nfree comments).\n\n README |   10 ++++++----\n 1 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/README b/README\nindex 67cfeb2..d2690ec 100644\n--- a/README\n+++ b/README\n@@ -42,10 +42,12 @@ including full documentation and Git related tools.\n \n The user discussion and development of Git take place on the Git\n mailing list -- everyone is welcome to post bug reports, feature\n-requests, comments and patches to git@vger.kernel.org. To subscribe\n-to the list, send an email with just \"subscribe git\" in the body to\n-majordomo@vger.kernel.org. The mailing list archives are available at\n-http://marc.theaimsgroup.com/?l=git and other archival sites.\n+requests, comments and patches to git@vger.kernel.org (read\n+Documentation/SubmittingPatches for instructions on patch submission).\n+To subscribe to the list, send an email with just \"subscribe git\" in\n+the body to majordomo@vger.kernel.org. The mailing list archives are\n+available at http://marc.theaimsgroup.com/?l=git and other archival\n+sites.\n \n The messages titled \"A note from the maintainer\", \"What's in\n git.git (stable)\" and \"What's cooking in git.git (topics)\" and\n-- \n1.7.9.111.gf3fb0.dirty\n"}]}