Merge branch 'ab/http-drop-old-curl-plus'
Conditional compilation around versions of libcURL has been straightened out. * ab/http-drop-old-curl-plus: http: don't hardcode the value of CURL_SOCKOPT_OK http: centralize the accounting of libcurl dependencies http: correct curl version check for CURLOPT_PINNEDPUBLICKEY http: correct version check for CURL_HTTP_VERSION_2 http: drop support for curl < 7.18.0 (again) Makefile: drop support for curl < 7.9.8 (again) INSTALL: mention that we need libcurl 7.19.4 or newer to build INSTALL: reword and copy-edit the "libcurl" section INSTALL: don't mention the "curl" executable at all
This commit is contained in:
commit
8f79fb6445
15
INSTALL
15
INSTALL
@ -138,12 +138,15 @@ Issues of note:
|
||||
BLK_SHA1. Also included is a version optimized for PowerPC
|
||||
(PPC_SHA1).
|
||||
|
||||
- "libcurl" library is used by git-http-fetch, git-fetch, and, if
|
||||
the curl version >= 7.34.0, for git-imap-send. You might also
|
||||
want the "curl" executable for debugging purposes. If you do not
|
||||
use http:// or https:// repositories, and do not want to put
|
||||
patches into an IMAP mailbox, you do not have to have them
|
||||
(use NO_CURL).
|
||||
- "libcurl" library is used for fetching and pushing
|
||||
repositories over http:// or https://, as well as by
|
||||
git-imap-send if the curl version is >= 7.34.0. If you do
|
||||
not need that functionality, use NO_CURL to build without
|
||||
it.
|
||||
|
||||
Git requires version "7.19.4" or later of "libcurl" to build
|
||||
without NO_CURL. This version requirement may be bumped in
|
||||
the future.
|
||||
|
||||
- "expat" library; git-http-push uses it for remote lock
|
||||
management over DAV. Similar to "curl" above, this is optional
|
||||
|
11
Makefile
11
Makefile
@ -1421,15 +1421,8 @@ else
|
||||
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
|
||||
PROGRAM_OBJS += http-fetch.o
|
||||
PROGRAMS += $(REMOTE_CURL_NAMES)
|
||||
curl_check := $(shell (echo 070908; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
|
||||
ifeq "$(curl_check)" "070908"
|
||||
ifndef NO_EXPAT
|
||||
PROGRAM_OBJS += http-push.o
|
||||
else
|
||||
EXCLUDED_PROGRAMS += git-http-push
|
||||
endif
|
||||
else
|
||||
EXCLUDED_PROGRAMS += git-http-push
|
||||
ifndef NO_EXPAT
|
||||
PROGRAM_OBJS += http-push.o
|
||||
endif
|
||||
curl_check := $(shell (echo 072200; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
|
||||
ifeq "$(curl_check)" "072200"
|
||||
|
128
git-curl-compat.h
Normal file
128
git-curl-compat.h
Normal file
@ -0,0 +1,128 @@
|
||||
#ifndef GIT_CURL_COMPAT_H
|
||||
#define GIT_CURL_COMPAT_H
|
||||
#include <curl/curl.h>
|
||||
|
||||
/**
|
||||
* This header centralizes the declaration of our libcurl dependencies
|
||||
* to make it easy to discover the oldest versions we support, and to
|
||||
* inform decisions about removing support for older libcurl in the
|
||||
* future.
|
||||
*
|
||||
* The oldest supported version of curl is documented in the "INSTALL"
|
||||
* document.
|
||||
*
|
||||
* The source of truth for what versions have which symbols is
|
||||
* https://github.com/curl/curl/blob/master/docs/libcurl/symbols-in-versions;
|
||||
* the release dates are taken from curl.git (at
|
||||
* https://github.com/curl/curl/).
|
||||
*
|
||||
* For each X symbol we need from curl we define our own
|
||||
* GIT_CURL_HAVE_X. If multiple similar symbols with the same prefix
|
||||
* were defined in the same version we pick one and check for that name.
|
||||
*
|
||||
* We may also define a missing CURL_* symbol to its known value, if
|
||||
* doing so is sufficient to add support for it to older versions that
|
||||
* don't have it.
|
||||
*
|
||||
* Keep any symbols in date order of when their support was
|
||||
* introduced, oldest first, in the official version of cURL library.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CURL_SOCKOPT_OK was added in 7.21.5, released in April 2011.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM < 0x071505
|
||||
#define CURL_SOCKOPT_OK 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURLOPT_TCP_KEEPALIVE was added in 7.25.0, released in March 2012.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x071900
|
||||
#define GITCURL_HAVE_CURLOPT_TCP_KEEPALIVE 1
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* CURLOPT_LOGIN_OPTIONS was added in 7.34.0, released in December
|
||||
* 2013.
|
||||
*
|
||||
* If we start requiring 7.34.0 we might also be able to remove the
|
||||
* code conditional on USE_CURL_FOR_IMAP_SEND in imap-send.c, see
|
||||
* 1e16b255b95 (git-imap-send: use libcurl for implementation,
|
||||
* 2014-11-09) and the check it added for "072200" in the Makefile.
|
||||
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x072200
|
||||
#define GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURL_SSLVERSION_TLSv1_[012] was added in 7.34.0, released in
|
||||
* December 2013.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x072200
|
||||
#define GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURLOPT_PINNEDPUBLICKEY was added in 7.39.0, released in November
|
||||
* 2014.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x072c00
|
||||
#define GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURL_HTTP_VERSION_2 was added in 7.43.0, released in June 2015.
|
||||
*
|
||||
* The CURL_HTTP_VERSION_2 alias (but not CURL_HTTP_VERSION_2_0) has
|
||||
* always been a macro, not an enum field (checked on curl version
|
||||
* 7.78.0)
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x072b00
|
||||
#define GIT_CURL_HAVE_CURL_HTTP_VERSION_2 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURLSSLOPT_NO_REVOKE was added in 7.44.0, released in August 2015.
|
||||
*
|
||||
* The CURLSSLOPT_NO_REVOKE is, has always been a macro, not an enum
|
||||
* field (checked on curl version 7.78.0)
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x072c00
|
||||
#define GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURLOPT_PROXY_CAINFO was added in 7.52.0, released in August 2017.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x073400
|
||||
#define GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURLOPT_PROXY_{KEYPASSWD,SSLCERT,SSLKEY} was added in 7.52.0,
|
||||
* released in August 2017.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x073400
|
||||
#define GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURL_SSLVERSION_TLSv1_3 was added in 7.53.0, released in February
|
||||
* 2017.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x073400
|
||||
#define GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_3 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CURLSSLSET_{NO_BACKENDS,OK,TOO_LATE,UNKNOWN_BACKEND} were added in
|
||||
* 7.56.0, released in September 2017.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x073800
|
||||
#define GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
|
||||
#endif
|
||||
|
||||
#endif
|
35
http.c
35
http.c
@ -1,4 +1,5 @@
|
||||
#include "git-compat-util.h"
|
||||
#include "git-curl-compat.h"
|
||||
#include "http.h"
|
||||
#include "config.h"
|
||||
#include "pack.h"
|
||||
@ -47,19 +48,19 @@ static struct {
|
||||
{ "sslv2", CURL_SSLVERSION_SSLv2 },
|
||||
{ "sslv3", CURL_SSLVERSION_SSLv3 },
|
||||
{ "tlsv1", CURL_SSLVERSION_TLSv1 },
|
||||
#if LIBCURL_VERSION_NUM >= 0x072200
|
||||
#ifdef GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0
|
||||
{ "tlsv1.0", CURL_SSLVERSION_TLSv1_0 },
|
||||
{ "tlsv1.1", CURL_SSLVERSION_TLSv1_1 },
|
||||
{ "tlsv1.2", CURL_SSLVERSION_TLSv1_2 },
|
||||
#endif
|
||||
#if LIBCURL_VERSION_NUM >= 0x073400
|
||||
#ifdef GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_3
|
||||
{ "tlsv1.3", CURL_SSLVERSION_TLSv1_3 },
|
||||
#endif
|
||||
};
|
||||
static const char *ssl_key;
|
||||
static const char *ssl_capath;
|
||||
static const char *curl_no_proxy;
|
||||
#if LIBCURL_VERSION_NUM >= 0x072c00
|
||||
#ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
|
||||
static const char *ssl_pinnedkey;
|
||||
#endif
|
||||
static const char *ssl_cainfo;
|
||||
@ -373,10 +374,10 @@ static int http_options(const char *var, const char *value, void *cb)
|
||||
}
|
||||
|
||||
if (!strcmp("http.pinnedpubkey", var)) {
|
||||
#if LIBCURL_VERSION_NUM >= 0x072c00
|
||||
#ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
|
||||
return git_config_pathname(&ssl_pinnedkey, var, value);
|
||||
#else
|
||||
warning(_("Public key pinning not supported with cURL < 7.44.0"));
|
||||
warning(_("Public key pinning not supported with cURL < 7.39.0"));
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@ -500,7 +501,7 @@ static int has_cert_password(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x073400
|
||||
#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD
|
||||
static int has_proxy_cert_password(void)
|
||||
{
|
||||
if (http_proxy_ssl_cert == NULL || proxy_ssl_cert_password_required != 1)
|
||||
@ -516,7 +517,7 @@ static int has_proxy_cert_password(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x071900
|
||||
#ifdef GITCURL_HAVE_CURLOPT_TCP_KEEPALIVE
|
||||
static void set_curl_keepalive(CURL *c)
|
||||
{
|
||||
curl_easy_setopt(c, CURLOPT_TCP_KEEPALIVE, 1);
|
||||
@ -536,7 +537,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
|
||||
if (rc < 0)
|
||||
warning_errno("unable to set SO_KEEPALIVE on socket");
|
||||
|
||||
return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
|
||||
return CURL_SOCKOPT_OK;
|
||||
}
|
||||
|
||||
static void set_curl_keepalive(CURL *c)
|
||||
@ -732,7 +733,7 @@ static long get_curl_allowed_protocols(int from_user)
|
||||
return allowed_protocols;
|
||||
}
|
||||
|
||||
#if LIBCURL_VERSION_NUM >=0x072f00
|
||||
#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
|
||||
static int get_curl_http_version_opt(const char *version_string, long *opt)
|
||||
{
|
||||
int i;
|
||||
@ -774,7 +775,7 @@ static CURL *get_curl_handle(void)
|
||||
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
}
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
|
||||
#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
|
||||
if (curl_http_version) {
|
||||
long opt;
|
||||
if (!get_curl_http_version_opt(curl_http_version, &opt)) {
|
||||
@ -805,7 +806,7 @@ static CURL *get_curl_handle(void)
|
||||
|
||||
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
|
||||
!http_schannel_check_revoke) {
|
||||
#if LIBCURL_VERSION_NUM >= 0x072c00
|
||||
#ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
|
||||
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
|
||||
#else
|
||||
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
|
||||
@ -845,20 +846,20 @@ static CURL *get_curl_handle(void)
|
||||
curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
|
||||
if (ssl_capath != NULL)
|
||||
curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
|
||||
#if LIBCURL_VERSION_NUM >= 0x072c00
|
||||
#ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
|
||||
if (ssl_pinnedkey != NULL)
|
||||
curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
|
||||
#endif
|
||||
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
|
||||
!http_schannel_use_ssl_cainfo) {
|
||||
curl_easy_setopt(result, CURLOPT_CAINFO, NULL);
|
||||
#if LIBCURL_VERSION_NUM >= 0x073400
|
||||
#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO
|
||||
curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, NULL);
|
||||
#endif
|
||||
} else if (ssl_cainfo != NULL || http_proxy_ssl_ca_info != NULL) {
|
||||
if (ssl_cainfo != NULL)
|
||||
curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
|
||||
#if LIBCURL_VERSION_NUM >= 0x073400
|
||||
#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO
|
||||
if (http_proxy_ssl_ca_info != NULL)
|
||||
curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, http_proxy_ssl_ca_info);
|
||||
#endif
|
||||
@ -927,7 +928,6 @@ static CURL *get_curl_handle(void)
|
||||
*/
|
||||
curl_easy_setopt(result, CURLOPT_PROXY, "");
|
||||
} else if (curl_http_proxy) {
|
||||
#if LIBCURL_VERSION_NUM >= 0x071800
|
||||
if (starts_with(curl_http_proxy, "socks5h"))
|
||||
curl_easy_setopt(result,
|
||||
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
|
||||
@ -940,8 +940,7 @@ static CURL *get_curl_handle(void)
|
||||
else if (starts_with(curl_http_proxy, "socks"))
|
||||
curl_easy_setopt(result,
|
||||
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
||||
#endif
|
||||
#if LIBCURL_VERSION_NUM >= 0x073400
|
||||
#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD
|
||||
else if (starts_with(curl_http_proxy, "https")) {
|
||||
curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
|
||||
|
||||
@ -1006,7 +1005,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
|
||||
free(normalized_url);
|
||||
string_list_clear(&config.vars, 1);
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x073800
|
||||
#ifdef GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
|
||||
if (http_ssl_backend) {
|
||||
const curl_ssl_backend **backends;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
|
@ -1441,7 +1441,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
|
||||
curl_easy_setopt(curl, CURLOPT_PORT, server.port);
|
||||
|
||||
if (server.auth_method) {
|
||||
#if LIBCURL_VERSION_NUM < 0x072200
|
||||
#ifndef GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS
|
||||
warning("No LOGIN_OPTIONS support in this cURL version");
|
||||
#else
|
||||
struct strbuf auth = STRBUF_INIT;
|
||||
|
Loading…
Reference in New Issue
Block a user