Skip to content

Commit 26a7b23

Browse files
pirat89gitster
authored andcommitted
http: control GSSAPI credential delegation
Delegation of credentials is disabled by default in libcurl since version 7.21.7 due to security vulnerability CVE-2011-2192. Which makes troubles with GSS/kerberos authentication when delegation of credentials is required. This can be changed with option CURLOPT_GSSAPI_DELEGATION in libcurl with set expected parameter since libcurl version 7.22.0. This patch provides new configuration variable http.delegation which corresponds to curl parameter "--delegation" (see man 1 curl). The following values are supported: * none (default). * policy * always Signed-off-by: Petr Stodulka <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c0304a commit 26a7b23

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

Documentation/config.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,20 @@ http.emptyAuth::
17301730
a username in the URL, as libcurl normally requires a username for
17311731
authentication.
17321732

1733+
http.delegation::
1734+
Control GSSAPI credential delegation. The delegation is disabled
1735+
by default in libcurl since version 7.21.7. Set parameter to tell
1736+
the server what it is allowed to delegate when it comes to user
1737+
credentials. Used with GSS/kerberos. Possible values are:
1738+
+
1739+
--
1740+
* `none` - Don't allow any delegation.
1741+
* `policy` - Delegates if and only if the OK-AS-DELEGATE flag is set in the
1742+
Kerberos service ticket, which is a matter of realm policy.
1743+
* `always` - Unconditionally allow the server to delegate.
1744+
--
1745+
1746+
17331747
http.extraHeader::
17341748
Pass an additional HTTP header when communicating with a server. If
17351749
more than one such entry exists, all of them are added as extra

http.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ static struct {
9090
* here, too
9191
*/
9292
};
93+
#if LIBCURL_VERSION_NUM >= 0x071600
94+
static const char *curl_deleg;
95+
static struct {
96+
const char *name;
97+
long curl_deleg_param;
98+
} curl_deleg_levels[] = {
99+
{ "none", CURLGSSAPI_DELEGATION_NONE },
100+
{ "policy", CURLGSSAPI_DELEGATION_POLICY_FLAG },
101+
{ "always", CURLGSSAPI_DELEGATION_FLAG },
102+
};
103+
#endif
104+
93105
static struct credential proxy_auth = CREDENTIAL_INIT;
94106
static const char *curl_proxyuserpwd;
95107
static const char *curl_cookie_file;
@@ -316,6 +328,15 @@ static int http_options(const char *var, const char *value, void *cb)
316328
return 0;
317329
}
318330

331+
if (!strcmp("http.delegation", var)) {
332+
#if LIBCURL_VERSION_NUM >= 0x071600
333+
return git_config_string(&curl_deleg, var, value);
334+
#else
335+
warning(_("Delegation control is not supported with cURL < 7.22.0"));
336+
return 0;
337+
#endif
338+
}
339+
319340
if (!strcmp("http.pinnedpubkey", var)) {
320341
#if LIBCURL_VERSION_NUM >= 0x072c00
321342
return git_config_pathname(&ssl_pinnedkey, var, value);
@@ -622,6 +643,22 @@ static CURL *get_curl_handle(void)
622643
curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
623644
#endif
624645

646+
#if LIBCURL_VERSION_NUM >= 0x071600
647+
if (curl_deleg) {
648+
int i;
649+
for (i = 0; i < ARRAY_SIZE(curl_deleg_levels); i++) {
650+
if (!strcmp(curl_deleg, curl_deleg_levels[i].name)) {
651+
curl_easy_setopt(result, CURLOPT_GSSAPI_DELEGATION,
652+
curl_deleg_levels[i].curl_deleg_param);
653+
break;
654+
}
655+
}
656+
if (i == ARRAY_SIZE(curl_deleg_levels))
657+
warning("Unknown delegation method '%s': using default",
658+
curl_deleg);
659+
}
660+
#endif
661+
625662
if (http_proactive_auth)
626663
init_curl_http_auth(result);
627664

0 commit comments

Comments
 (0)