Skip to content

Commit fbfe878

Browse files
committed
Merge branch 'ps/http-gssapi-cred-delegation'
In recent versions of cURL, GSSAPI credential delegation is disabled by default due to CVE-2011-2192; introduce a configuration to selectively allow enabling this. * ps/http-gssapi-cred-delegation: http: control GSSAPI credential delegation
2 parents cb52426 + 26a7b23 commit fbfe878

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
@@ -1736,6 +1736,20 @@ http.emptyAuth::
17361736
a username in the URL, as libcurl normally requires a username for
17371737
authentication.
17381738

1739+
http.delegation::
1740+
Control GSSAPI credential delegation. The delegation is disabled
1741+
by default in libcurl since version 7.21.7. Set parameter to tell
1742+
the server what it is allowed to delegate when it comes to user
1743+
credentials. Used with GSS/kerberos. Possible values are:
1744+
+
1745+
--
1746+
* `none` - Don't allow any delegation.
1747+
* `policy` - Delegates if and only if the OK-AS-DELEGATE flag is set in the
1748+
Kerberos service ticket, which is a matter of realm policy.
1749+
* `always` - Unconditionally allow the server to delegate.
1750+
--
1751+
1752+
17391753
http.extraHeader::
17401754
Pass an additional HTTP header when communicating with a server. If
17411755
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;
@@ -323,6 +335,15 @@ static int http_options(const char *var, const char *value, void *cb)
323335
return 0;
324336
}
325337

338+
if (!strcmp("http.delegation", var)) {
339+
#if LIBCURL_VERSION_NUM >= 0x071600
340+
return git_config_string(&curl_deleg, var, value);
341+
#else
342+
warning(_("Delegation control is not supported with cURL < 7.22.0"));
343+
return 0;
344+
#endif
345+
}
346+
326347
if (!strcmp("http.pinnedpubkey", var)) {
327348
#if LIBCURL_VERSION_NUM >= 0x072c00
328349
return git_config_pathname(&ssl_pinnedkey, var, value);
@@ -629,6 +650,22 @@ static CURL *get_curl_handle(void)
629650
curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
630651
#endif
631652

653+
#if LIBCURL_VERSION_NUM >= 0x071600
654+
if (curl_deleg) {
655+
int i;
656+
for (i = 0; i < ARRAY_SIZE(curl_deleg_levels); i++) {
657+
if (!strcmp(curl_deleg, curl_deleg_levels[i].name)) {
658+
curl_easy_setopt(result, CURLOPT_GSSAPI_DELEGATION,
659+
curl_deleg_levels[i].curl_deleg_param);
660+
break;
661+
}
662+
}
663+
if (i == ARRAY_SIZE(curl_deleg_levels))
664+
warning("Unknown delegation method '%s': using default",
665+
curl_deleg);
666+
}
667+
#endif
668+
632669
if (http_proactive_auth)
633670
init_curl_http_auth(result);
634671

0 commit comments

Comments
 (0)