Blame SOURCES/0001-http-control-GSSAPI-credential-delegation.patch

647f52
From 7dbd01e4815727ce46de0b5d6c2916fec9154196 Mon Sep 17 00:00:00 2001
647f52
From: Petr Stodulka <pstodulk@redhat.com>
647f52
Date: Mon, 5 Dec 2016 16:49:09 +0100
647f52
Subject: [PATCH] http: control GSSAPI credential delegation
647f52
647f52
Delegation of credentials is disabled by default in libcurl since
647f52
version 7.21.7 due to security vulnerability CVE-2011-2192. Which
647f52
makes troubles with GSS/kerberos authentication when delegation
647f52
of credentials is required. This can be changed with option
647f52
CURLOPT_GSSAPI_DELEGATION in libcurl with set expected parameter
647f52
since libcurl version 7.22.0.
647f52
647f52
This patch provides new configuration variable http.delegation
647f52
which corresponds to curl parameter "--delegation" (see man 1 curl).
647f52
647f52
The following values are supported:
647f52
647f52
* none (default).
647f52
* policy
647f52
* always
647f52
---
647f52
 http.c | 38 ++++++++++++++++++++++++++++++++++++++
647f52
 1 file changed, 38 insertions(+)
647f52
647f52
diff --git a/http.c b/http.c
647f52
index a1c7dcb..e7c77c0 100644
647f52
--- a/http.c
647f52
+++ b/http.c
647f52
@@ -66,6 +66,19 @@ static struct curl_slist *no_pragma_header;
647f52
 
647f52
 static struct active_request_slot *active_queue_head;
647f52
 
647f52
+#if LIBCURL_VERSION_NUM >= 0x071600
647f52
+static const char *curl_deleg;
647f52
+static struct {
647f52
+	const char *name;
647f52
+	long curl_deleg_param;
647f52
+} curl_deleg_levels[] = {
647f52
+	{ "none", CURLGSSAPI_DELEGATION_NONE },
647f52
+	{ "policy", CURLGSSAPI_DELEGATION_POLICY_FLAG },
647f52
+	{ "always", CURLGSSAPI_DELEGATION_FLAG },
647f52
+};
647f52
+#endif
647f52
+
647f52
+
647f52
 size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
647f52
 {
647f52
 	size_t size = eltsize * nmemb;
647f52
@@ -169,6 +182,16 @@ static int http_options(const char *var, const char *value, void *cb)
647f52
 		curl_ssl_try = git_config_bool(var, value);
647f52
 		return 0;
647f52
 	}
647f52
+
647f52
+	if (!strcmp("http.delegation", var)) {
647f52
+#if LIBCURL_VERSION_NUM >= 0x071600
647f52
+		return git_config_string(&curl_deleg, var, value);
647f52
+#else
647f52
+		warning("Delegation control is not supported with cURL < 7.22.0");
647f52
+		return 0;
647f52
+#endif
647f52
+	}
647f52
+
647f52
 	if (!strcmp("http.minsessions", var)) {
647f52
 		min_curl_sessions = git_config_int(var, value);
647f52
 #ifndef USE_CURL_MULTI
647f52
@@ -271,6 +294,21 @@ static CURL *get_curl_handle(void)
647f52
 #ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
647f52
 	curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
647f52
 #endif
647f52
+#if LIBCURL_VERSION_NUM >= 0x071600
647f52
+	if (curl_deleg) {
647f52
+		int i;
647f52
+		for (i = 0; i < ARRAY_SIZE(curl_deleg_levels); i++) {
647f52
+			if (!strcmp(curl_deleg, curl_deleg_levels[i].name)) {
647f52
+				curl_easy_setopt(result, CURLOPT_GSSAPI_DELEGATION,
647f52
+						curl_deleg_levels[i].curl_deleg_param);
647f52
+				break;
647f52
+			}
647f52
+		}
647f52
+		if (i == ARRAY_SIZE(curl_deleg_levels))
647f52
+			warning("Unknown delegation method '%s': using default",
647f52
+				curl_deleg);
647f52
+	}
647f52
+#endif
647f52
 
647f52
 	if (http_proactive_auth)
647f52
 		init_curl_http_auth(result);
647f52
-- 
647f52
2.5.5
647f52