From: Junio C Hamano Date: Fri, 7 Sep 2012 18:09:49 +0000 (-0700) Subject: Merge branch 'jk/maint-http-half-auth-push' X-Git-Tag: v1.8.0-rc0~91 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e6dd70e9bfef40d545cb0f452f082bde562e8785;p=git.git Merge branch 'jk/maint-http-half-auth-push' Pushing to smart HTTP server with recent Git fails without having the username in the URL to force authentication, if the server is configured to allow GET anonymously, while requiring authentication for POST. * jk/maint-http-half-auth-push: http: prompt for credentials on failed POST http: factor out http error code handling t: test http access to "half-auth" repositories t: test basic smart-http authentication t/lib-httpd: recognize */smart/* repos as smart-http t/lib-httpd: only route auth/dumb to dumb repos t5550: factor out http auth setup t5550: put auth-required repo in auth/dumb --- e6dd70e9bfef40d545cb0f452f082bde562e8785 diff --cc http.c index 18bc6bf7b,7c4a4072f..9bac1d89f --- a/http.c +++ b/http.c @@@ -745,6 -744,33 +745,35 @@@ char *get_remote_object_url(const char return strbuf_detach(&buf, NULL); } + int handle_curl_result(struct active_request_slot *slot) + { + struct slot_results *results = slot->results; + + if (results->curl_result == CURLE_OK) { + credential_approve(&http_auth); + return HTTP_OK; + } else if (missing_target(results)) + return HTTP_MISSING_TARGET; + else if (results->http_code == 401) { + if (http_auth.username && http_auth.password) { + credential_reject(&http_auth); + return HTTP_NOAUTH; + } else { + credential_fill(&http_auth); + init_curl_http_auth(slot->curl); + return HTTP_REAUTH; + } + } else { ++#if LIBCURL_VERSION_NUM >= 0x070c00 + if (!curl_errorstr[0]) + strlcpy(curl_errorstr, + curl_easy_strerror(results->curl_result), + sizeof(curl_errorstr)); ++#endif + return HTTP_ERROR; + } + } + /* http_request() targets */ #define HTTP_REQUEST_STRBUF 0 #define HTTP_REQUEST_FILE 1 diff --cc t/lib-httpd/apache.conf index 36b1596a1,ec8618dfd..49d5d877c --- a/t/lib-httpd/apache.conf +++ b/t/lib-httpd/apache.conf @@@ -42,30 -42,25 +42,28 @@@ ErrorLog error.lo +PassEnv GIT_VALGRIND +PassEnv GIT_VALGRIND_OPTIONS + Alias /dumb/ www/ - Alias /auth/ www/auth/ + Alias /auth/dumb/ www/auth/dumb/ - + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} SetEnv GIT_HTTP_EXPORT_ALL - - + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} - - + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} SetEnv GIT_HTTP_EXPORT_ALL SetEnv GIT_COMMITTER_NAME "Custom User" SetEnv GIT_COMMITTER_EMAIL custom@example.com - - ScriptAlias /smart/ ${GIT_EXEC_PATH}/git-http-backend/ - ScriptAlias /smart_noexport/ ${GIT_EXEC_PATH}/git-http-backend/ - ScriptAlias /smart_custom_env/ ${GIT_EXEC_PATH}/git-http-backend/ + + ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1 - Options None + Options FollowSymlinks Options ExecCGI