From patchwork Fri Jul 30 09:31:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12410843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2568C432BE for ; Fri, 30 Jul 2021 09:35:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC01461019 for ; Fri, 30 Jul 2021 09:35:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238347AbhG3JfJ (ORCPT ); Fri, 30 Jul 2021 05:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238260AbhG3JfI (ORCPT ); Fri, 30 Jul 2021 05:35:08 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA75BC0613C1 for ; Fri, 30 Jul 2021 02:35:03 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id p5so10473121wro.7 for ; Fri, 30 Jul 2021 02:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uqtUirrA6RBMRqwGn2IHf5VsqwHfBMe4uA1fE38P5zQ=; b=OEpqakv2yHyrg8RZoeuK8WiVIcGGKGQt1iF/I2Qw3CKUt+QH5GI/I97G3ufO50VGOB sOXjDccJcmSjvxZ3JPuWj/O3rmJ4zftcJXXtV/9FBKPUZ5psqXgq0tnDcB0KRZoU2Z3J i/moCiSL4QYGo/bzCfrpi0G7IFFGG/6uEE8pdC6z2jjCBWZtVLF/GtnUHqRexLIkPqkY at2ZdZ4zXWT+0fyVYVk8rAQ7q9BhGJ2AWg2DmGOTTGcW40e6CusEAZkdC67gCWYZHYq9 GNMk/Kj8ME/u7Gvr8zkyIhaAlKD9oxFTJS0DK/IaEMQpa8gSlIai27qkQYURwagU+fkb dIAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uqtUirrA6RBMRqwGn2IHf5VsqwHfBMe4uA1fE38P5zQ=; b=i14ZNbnr2IpfjpVfn9/el/rRpkjyp+Hvz2PvBTgZvErEE98Fj8BlGI74feB1alqxkf rpcnJC1h9IpWpMALUVHhDfH9mbBNZ0Kj2TUvsxzy7kjCGAeJImlpE9A0fJYFLIwuBrTX ZM/JV5eojip7Pqt4SDHyheurNbdXNJx2WpzmGB6raOBBmFWX60Df2/a3+NtVzqjVYlXF pURwlFCNtSeJsVfMVQ5vakU+VR065rvpTOhSzQnPkaYRIWKRxV4bH5+ZtUuyDqXjKxam eNHCTf0DY4sv1jaDkvxClwV5xtUv9xzESMmAOJSlTVjKvyPgCKV6qv4ewjhq+dVHLr4G 9efQ== X-Gm-Message-State: AOAM531JfO7T36QeydFH+F2osUVK3SfWfxIE8q5JZTMHoh9GME933ing f9HQluV4UZYcoq2pYfmbZ9J5tdNfS2JfkQ== X-Google-Smtp-Source: ABdhPJw4e+8IZ8HjiTQt0xC3GqLm5+0ABG5LxSQWKVKPI0dgLwUJr7bm4j1nCivfyeBgJ/23JNG9Wg== X-Received: by 2002:a5d:5906:: with SMTP id v6mr2034451wrd.194.1627637702045; Fri, 30 Jul 2021 02:35:02 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id t17sm1089903wru.94.2021.07.30.02.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 02:35:01 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Nicolas Morey-Chaisemartin , "Tom G . Christensen" , Mischa POSLAWSKY , Johannes Schindelin , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v3 1/7] http: drop support for curl < 7.11.1 Date: Fri, 30 Jul 2021 11:31:53 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.1069.g516d52f3d85 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King Drop support for this ancient version of curl and simplify the code by allowing us get rid of some "#ifdef"'s. Git will not build with vanilla curl older than 7.11.1 due our use of CURLOPT_POSTFIELDSIZE in 37ee680d9b (http.postbuffer: allow full range of ssize_t values, 2017-04-11). This field was introduced in curl 7.11.1. We could solve these compilation problems with more #ifdefs, but it's not worth the trouble. Version 7.11.1 came out in March of 2004, over 17 years ago. Let's declare that too old and drop any existing ifdefs that go further back. One obvious benefit is that we'll have fewer conditional bits cluttering the code. This patch drops all #ifdefs that reference older versions (note that curl's preprocessor macros are in hex, so we're looking for 070b01, not 071101). Signed-off-by: Jeff King Signed-off-by: Ævar Arnfjörð Bjarmason --- http.c | 53 --------------------------------------------------- http.h | 12 +----------- remote-curl.c | 3 --- 3 files changed, 1 insertion(+), 67 deletions(-) diff --git a/http.c b/http.c index 8119247149a..56182a89e25 100644 --- a/http.c +++ b/http.c @@ -19,19 +19,11 @@ static struct trace_key trace_curl = TRACE_KEY_INIT(CURL); static int trace_curl_data = 1; static int trace_curl_redact = 1; -#if LIBCURL_VERSION_NUM >= 0x070a08 long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER; -#else -long int git_curl_ipresolve; -#endif int active_requests; int http_is_verbose; ssize_t http_post_buffer = 16 * LARGE_PACKET_MAX; -#if LIBCURL_VERSION_NUM >= 0x070a06 -#define LIBCURL_CAN_HANDLE_AUTH_ANY -#endif - static int min_curl_sessions = 1; static int curl_session_count; #ifdef USE_CURL_MULTI @@ -68,15 +60,9 @@ static struct { { "tlsv1.3", CURL_SSLVERSION_TLSv1_3 }, #endif }; -#if LIBCURL_VERSION_NUM >= 0x070903 static const char *ssl_key; -#endif -#if LIBCURL_VERSION_NUM >= 0x070908 static const char *ssl_capath; -#endif -#if LIBCURL_VERSION_NUM >= 0x071304 static const char *curl_no_proxy; -#endif #if LIBCURL_VERSION_NUM >= 0x072c00 static const char *ssl_pinnedkey; #endif @@ -101,9 +87,7 @@ static struct { { "digest", CURLAUTH_DIGEST }, { "negotiate", CURLAUTH_GSSNEGOTIATE }, { "ntlm", CURLAUTH_NTLM }, -#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY { "anyauth", CURLAUTH_ANY }, -#endif /* * CURLAUTH_DIGEST_IE has no corresponding command-line option in * curl(1) and is not included in CURLAUTH_ANY, so we leave it out @@ -143,7 +127,6 @@ enum http_follow_config http_follow_config = HTTP_FOLLOW_INITIAL; static struct credential cert_auth = CREDENTIAL_INIT; static int ssl_cert_password_required; -#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY static unsigned long http_auth_methods = CURLAUTH_ANY; static int http_auth_methods_restricted; /* Modes for which empty_auth cannot actually help us. */ @@ -153,7 +136,6 @@ static unsigned long empty_auth_useless = | CURLAUTH_DIGEST_IE #endif | CURLAUTH_DIGEST; -#endif static struct curl_slist *pragma_header; static struct curl_slist *no_pragma_header; @@ -237,12 +219,8 @@ static void finish_active_slot(struct active_request_slot *slot) if (slot->results != NULL) { slot->results->curl_result = slot->curl_result; slot->results->http_code = slot->http_code; -#if LIBCURL_VERSION_NUM >= 0x070a08 curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL, &slot->results->auth_avail); -#else - slot->results->auth_avail = 0; -#endif curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CONNECTCODE, &slot->results->http_connectcode); @@ -305,14 +283,10 @@ static int http_options(const char *var, const char *value, void *cb) return git_config_string(&ssl_version, var, value); if (!strcmp("http.sslcert", var)) return git_config_pathname(&ssl_cert, var, value); -#if LIBCURL_VERSION_NUM >= 0x070903 if (!strcmp("http.sslkey", var)) return git_config_pathname(&ssl_key, var, value); -#endif -#if LIBCURL_VERSION_NUM >= 0x070908 if (!strcmp("http.sslcapath", var)) return git_config_pathname(&ssl_capath, var, value); -#endif if (!strcmp("http.sslcainfo", var)) return git_config_pathname(&ssl_cainfo, var, value); if (!strcmp("http.sslcertpasswordprotected", var)) { @@ -461,12 +435,6 @@ static int curl_empty_auth_enabled(void) if (curl_empty_auth >= 0) return curl_empty_auth; -#ifndef LIBCURL_CAN_HANDLE_AUTH_ANY - /* - * Our libcurl is too old to do AUTH_ANY in the first place; - * just default to turning the feature off. - */ -#else /* * In the automatic case, kick in the empty-auth * hack as long as we would potentially try some @@ -479,7 +447,6 @@ static int curl_empty_auth_enabled(void) if (http_auth_methods_restricted && (http_auth_methods & ~empty_auth_useless)) return 1; -#endif return 0; } @@ -552,7 +519,6 @@ static void init_curl_proxy_auth(CURL *result) var_override(&http_proxy_authmethod, getenv("GIT_HTTP_PROXY_AUTHMETHOD")); -#if LIBCURL_VERSION_NUM >= 0x070a07 /* CURLOPT_PROXYAUTH and CURLAUTH_ANY */ if (http_proxy_authmethod) { int i; for (i = 0; i < ARRAY_SIZE(proxy_authmethods); i++) { @@ -570,7 +536,6 @@ static void init_curl_proxy_auth(CURL *result) } else curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY); -#endif } static int has_cert_password(void) @@ -879,12 +844,8 @@ static CURL *get_curl_handle(void) } #endif -#if LIBCURL_VERSION_NUM >= 0x070907 curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); -#endif -#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY); -#endif #ifdef CURLGSSAPI_DELEGATION_FLAG if (curl_deleg) { @@ -940,14 +901,10 @@ static CURL *get_curl_handle(void) curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert); if (has_cert_password()) curl_easy_setopt(result, CURLOPT_KEYPASSWD, cert_auth.password); -#if LIBCURL_VERSION_NUM >= 0x070903 if (ssl_key != NULL) curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key); -#endif -#if LIBCURL_VERSION_NUM >= 0x070908 if (ssl_capath != NULL) curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath); -#endif #if LIBCURL_VERSION_NUM >= 0x072c00 if (ssl_pinnedkey != NULL) curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey); @@ -1180,12 +1137,8 @@ void http_init(struct remote *remote, const char *url, int proactive_auth) curl_ssl_verify = 0; set_from_env(&ssl_cert, "GIT_SSL_CERT"); -#if LIBCURL_VERSION_NUM >= 0x070903 set_from_env(&ssl_key, "GIT_SSL_KEY"); -#endif -#if LIBCURL_VERSION_NUM >= 0x070908 set_from_env(&ssl_capath, "GIT_SSL_CAPATH"); -#endif set_from_env(&ssl_cainfo, "GIT_SSL_CAINFO"); set_from_env(&user_agent, "GIT_HTTP_USER_AGENT"); @@ -1367,12 +1320,8 @@ struct active_request_slot *get_active_slot(void) else curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0); -#if LIBCURL_VERSION_NUM >= 0x070a08 curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve); -#endif -#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods); -#endif if (http_auth.password || curl_empty_auth_enabled()) init_curl_http_auth(slot->curl); @@ -1654,13 +1603,11 @@ static int handle_curl_result(struct slot_results *results) credential_reject(&http_auth); return HTTP_NOAUTH; } else { -#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE; if (results->auth_avail) { http_auth_methods &= results->auth_avail; http_auth_methods_restricted = 1; } -#endif return HTTP_REAUTH; } } else { diff --git a/http.h b/http.h index bf3d1270ad8..d2f8cc56617 100644 --- a/http.h +++ b/http.h @@ -22,13 +22,7 @@ #define DEFAULT_MAX_REQUESTS 5 #endif -#if LIBCURL_VERSION_NUM < 0x070704 -#define curl_global_cleanup() do { /* nothing */ } while (0) -#endif - -#if LIBCURL_VERSION_NUM < 0x070800 -#define curl_global_init(a) do { /* nothing */ } while (0) -#elif LIBCURL_VERSION_NUM >= 0x070c00 +#if LIBCURL_VERSION_NUM >= 0x070c00 #define curl_global_init(a) curl_global_init_mem(a, xmalloc, free, \ xrealloc, xstrdup, xcalloc) #endif @@ -37,10 +31,6 @@ #define NO_CURL_EASY_DUPHANDLE #endif -#if LIBCURL_VERSION_NUM < 0x070a03 -#define CURLE_HTTP_RETURNED_ERROR CURLE_HTTP_NOT_FOUND -#endif - #if LIBCURL_VERSION_NUM < 0x070c03 #define NO_CURL_IOCTL #endif diff --git a/remote-curl.c b/remote-curl.c index 6c320d57045..e738ae2c48a 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -185,8 +185,6 @@ static int set_option(const char *name, const char *value) strbuf_detach(&unquoted, NULL)); } return 0; - -#if LIBCURL_VERSION_NUM >= 0x070a08 } else if (!strcmp(name, "family")) { if (!strcmp(value, "ipv4")) git_curl_ipresolve = CURL_IPRESOLVE_V4; @@ -197,7 +195,6 @@ static int set_option(const char *name, const char *value) else return -1; return 0; -#endif /* LIBCURL_VERSION_NUM >= 0x070a08 */ } else if (!strcmp(name, "from-promisor")) { options.from_promisor = 1; return 0; From patchwork Fri Jul 30 09:31:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12410845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F6C0C4338F for ; Fri, 30 Jul 2021 09:35:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DD2A61019 for ; Fri, 30 Jul 2021 09:35:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238378AbhG3JfL (ORCPT ); Fri, 30 Jul 2021 05:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238226AbhG3JfJ (ORCPT ); Fri, 30 Jul 2021 05:35:09 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6DE9C061765 for ; Fri, 30 Jul 2021 02:35:04 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id u15so5561906wmj.1 for ; Fri, 30 Jul 2021 02:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QrvIgMz0f5A7wkEgvFqc/d9GTvUbCb5ATGRsX+ZZXq8=; b=ZX94n9RXCzCoF5WQyTVvUj8KLRkLZcXeKQsiOplDil1Fq680wt/5WktBE2b6cDc5Em /2foWeUJaZUBolSJmTMJMZhzccdJB/4muI5h9Prle7jws0CrMVIguDo1sEzsJvaq2HzE 11+8XI/V90L811VUFHgaoMq02zR/D5hEutYPU2gLyUeLHvC3/zv7EC0x6scywbCtcGWl 5IwuD7fR5xNUn5/cdF0VfDJIMialnNY7meDhravcKnAGrorXPqosHMgfqz6dm5Cmqabr kAJztOUIWpblA4WfZxx9wrv3B+zfNyiTf2ZrUKFW8vWdApVxlr4EcoQQ57UphzZ6kfyK o9WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QrvIgMz0f5A7wkEgvFqc/d9GTvUbCb5ATGRsX+ZZXq8=; b=YMCsvwUPNzLr69BqwO6s8Y+dMWoZ868qHe8O441Vt2MdA5X36S3kwXaMZSxyKww/h1 UsTvwAwloVSrNYnh105E02bZfCi4Y6++76sLLpSKPNMm0zxIelXVjpdiuEzXr05cSC0D +m1TAD7Gr/R9ai9h97LR/LDYFVbau4e2b99fRvLQFsxf02KefvXOsbFiH6ZX1eYHU1GS 4L5BgtcsG35KJxtXjYJStFx/94VR5O6PEfpmAwQ3g7gu74ktbyqhAHZl9EMJ2dClfsdh 5O15pht/JTNqawILYB9Mdzfmj3BYABSLMgGglSkYDfhwBlXDAFNSwKydbFYcjN//TYjz cGfw== X-Gm-Message-State: AOAM530E0BsNuNjtrQu9sFg9u7JXKtriIMwWPA8VKGL3RZ4xc6Vysrfr QckS9N9sJPROuKgaKtIyX9hRbAIHqgC+fA== X-Google-Smtp-Source: ABdhPJxoW0X75mr+wC04K7AQzuYeeRsJsWl0CmPCv2x3v46WQtlIxyKr/96z7UHbPqgxfslNc1f0pw== X-Received: by 2002:a1c:5449:: with SMTP id p9mr1986979wmi.101.1627637702934; Fri, 30 Jul 2021 02:35:02 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id t17sm1089903wru.94.2021.07.30.02.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 02:35:02 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Nicolas Morey-Chaisemartin , "Tom G . Christensen" , Mischa POSLAWSKY , Johannes Schindelin , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v3 2/7] http: drop support for curl < 7.16.0 Date: Fri, 30 Jul 2021 11:31:54 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.1069.g516d52f3d85 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King In the last commit we dropped support for curl < 7.11.1, let's continue that and drop support for versions older than 7.16.0. This allows us to get rid of some now-obsolete #ifdefs. Choosing 7.16.0 is a somewhat arbitrary cutoff: 1. It came out in October of 2006, almost 15 years ago. Besides being a nice round number, around 10 years is a common end-of-life support period, even for conservative distributions. 2. That version introduced the curl_multi interface, which gives us a lot of bang for the buck in removing #ifdefs RHEL 5 came with curl 7.15.5[1] (released in August 2006). RHEL 5's extended life cycle program ended on 2020-11-30[1]. RHEL 6 comes with curl 7.19.7 (released in November 2009), and RHEL 7 comes with 7.29.0 (released in February 2013). 1. http://lore.kernel.org/git/873e1f31-2a96-5b72-2f20-a5816cad1b51@jupiterrise.com Signed-off-by: Jeff King Signed-off-by: Ævar Arnfjörð Bjarmason --- http-push.c | 23 --------------------- http-walker.c | 12 ----------- http.c | 56 +-------------------------------------------------- http.h | 25 +---------------------- imap-send.c | 4 ---- remote-curl.c | 4 ---- 6 files changed, 2 insertions(+), 122 deletions(-) diff --git a/http-push.c b/http-push.c index d7cb1675a2d..aa3de7c1086 100644 --- a/http-push.c +++ b/http-push.c @@ -203,10 +203,8 @@ static void curl_setup_http(CURL *curl, const char *url, curl_easy_setopt(curl, CURLOPT_INFILE, buffer); curl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len); curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer); -#ifndef NO_CURL_IOCTL curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer); curl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer); -#endif curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn); curl_easy_setopt(curl, CURLOPT_NOBODY, 0); curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req); @@ -249,8 +247,6 @@ static void process_response(void *callback_data) finish_request(request); } -#ifdef USE_CURL_MULTI - static void start_fetch_loose(struct transfer_request *request) { struct active_request_slot *slot; @@ -299,7 +295,6 @@ static void start_mkcol(struct transfer_request *request) FREE_AND_NULL(request->url); } } -#endif static void start_fetch_packed(struct transfer_request *request) { @@ -605,7 +600,6 @@ static void finish_request(struct transfer_request *request) } } -#ifdef USE_CURL_MULTI static int is_running_queue; static int fill_active_slot(void *unused) { @@ -629,7 +623,6 @@ static int fill_active_slot(void *unused) } return 0; } -#endif static void get_remote_object_list(unsigned char parent); @@ -658,10 +651,8 @@ static void add_fetch_request(struct object *obj) request->next = request_queue_head; request_queue_head = request; -#ifdef USE_CURL_MULTI fill_active_slots(); step_active_slots(); -#endif } static int add_send_request(struct object *obj, struct remote_lock *lock) @@ -696,10 +687,8 @@ static int add_send_request(struct object *obj, struct remote_lock *lock) request->next = request_queue_head; request_queue_head = request; -#ifdef USE_CURL_MULTI fill_active_slots(); step_active_slots(); -#endif return 1; } @@ -1682,21 +1671,15 @@ static int delete_remote_branch(const char *pattern, int force) static void run_request_queue(void) { -#ifdef USE_CURL_MULTI is_running_queue = 1; fill_active_slots(); add_fill_function(NULL, fill_active_slot); -#endif do { finish_all_active_slots(); -#ifdef USE_CURL_MULTI fill_active_slots(); -#endif } while (request_queue_head && !aborted); -#ifdef USE_CURL_MULTI is_running_queue = 0; -#endif } int cmd_main(int argc, const char **argv) @@ -1770,10 +1753,6 @@ int cmd_main(int argc, const char **argv) break; } -#ifndef USE_CURL_MULTI - die("git-push is not available for http/https repository when not compiled with USE_CURL_MULTI"); -#endif - if (!repo->url) usage(http_push_usage); @@ -1786,9 +1765,7 @@ int cmd_main(int argc, const char **argv) http_init(NULL, repo->url, 1); -#ifdef USE_CURL_MULTI is_running_queue = 0; -#endif /* Verify DAV compliance/lock support */ if (!locking_available()) { diff --git a/http-walker.c b/http-walker.c index 90d8ecb57ef..19e31623f04 100644 --- a/http-walker.c +++ b/http-walker.c @@ -127,7 +127,6 @@ static void release_object_request(struct object_request *obj_req) free(obj_req); } -#ifdef USE_CURL_MULTI static int fill_active_slot(struct walker *walker) { struct object_request *obj_req; @@ -146,7 +145,6 @@ static int fill_active_slot(struct walker *walker) } return 0; } -#endif static void prefetch(struct walker *walker, unsigned char *sha1) { @@ -163,10 +161,8 @@ static void prefetch(struct walker *walker, unsigned char *sha1) http_is_verbose = walker->get_verbosely; list_add_tail(&newreq->node, &object_queue_head); -#ifdef USE_CURL_MULTI fill_active_slots(); step_active_slots(); -#endif } static int is_alternate_allowed(const char *url) @@ -357,11 +353,9 @@ static void fetch_alternates(struct walker *walker, const char *base) * wait for them to arrive and return to processing this request's * curl message */ -#ifdef USE_CURL_MULTI while (cdata->got_alternates == 0) { step_active_slots(); } -#endif /* Nothing to do if they've already been fetched */ if (cdata->got_alternates == 1) @@ -505,12 +499,8 @@ static int fetch_object(struct walker *walker, unsigned char *hash) return 0; } -#ifdef USE_CURL_MULTI while (obj_req->state == WAITING) step_active_slots(); -#else - start_object_request(walker, obj_req); -#endif /* * obj_req->req might change when fetching alternates in the callback @@ -623,9 +613,7 @@ struct walker *get_http_walker(const char *url) walker->cleanup = cleanup; walker->data = data; -#ifdef USE_CURL_MULTI add_fill_function(walker, (int (*)(void *)) fill_active_slot); -#endif return walker; } diff --git a/http.c b/http.c index 56182a89e25..ef00e930232 100644 --- a/http.c +++ b/http.c @@ -26,10 +26,8 @@ ssize_t http_post_buffer = 16 * LARGE_PACKET_MAX; static int min_curl_sessions = 1; static int curl_session_count; -#ifdef USE_CURL_MULTI static int max_requests = -1; static CURLM *curlm; -#endif #ifndef NO_CURL_EASY_DUPHANDLE static CURL *curl_default; #endif @@ -117,14 +115,6 @@ static int curl_empty_auth = -1; enum http_follow_config http_follow_config = HTTP_FOLLOW_INITIAL; -#if LIBCURL_VERSION_NUM >= 0x071700 -/* Use CURLOPT_KEYPASSWD as is */ -#elif LIBCURL_VERSION_NUM >= 0x070903 -#define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD -#else -#define CURLOPT_KEYPASSWD CURLOPT_SSLCERTPASSWD -#endif - static struct credential cert_auth = CREDENTIAL_INIT; static int ssl_cert_password_required; static unsigned long http_auth_methods = CURLAUTH_ANY; @@ -168,7 +158,6 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_) return size / eltsize; } -#ifndef NO_CURL_IOCTL curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp) { struct buffer *buffer = clientp; @@ -185,7 +174,6 @@ curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp) return CURLIOE_UNKNOWNCMD; } } -#endif size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_) { @@ -233,12 +221,9 @@ static void finish_active_slot(struct active_request_slot *slot) static void xmulti_remove_handle(struct active_request_slot *slot) { -#ifdef USE_CURL_MULTI curl_multi_remove_handle(curlm, slot->curl); -#endif } -#ifdef USE_CURL_MULTI static void process_curl_messages(void) { int num_messages; @@ -266,7 +251,6 @@ static void process_curl_messages(void) curl_message = curl_multi_info_read(curlm, &num_messages); } } -#endif static int http_options(const char *var, const char *value, void *cb) { @@ -315,18 +299,14 @@ static int http_options(const char *var, const char *value, void *cb) if (!strcmp("http.minsessions", var)) { min_curl_sessions = git_config_int(var, value); -#ifndef USE_CURL_MULTI if (min_curl_sessions > 1) min_curl_sessions = 1; -#endif return 0; } -#ifdef USE_CURL_MULTI if (!strcmp("http.maxrequests", var)) { max_requests = git_config_int(var, value); return 0; } -#endif if (!strcmp("http.lowspeedlimit", var)) { curl_low_speed_limit = (long)git_config_int(var, value); return 0; @@ -574,7 +554,7 @@ static void set_curl_keepalive(CURL *c) curl_easy_setopt(c, CURLOPT_TCP_KEEPALIVE, 1); } -#elif LIBCURL_VERSION_NUM >= 0x071000 +#else static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type) { int ka = 1; @@ -595,12 +575,6 @@ static void set_curl_keepalive(CURL *c) { curl_easy_setopt(c, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); } - -#else -static void set_curl_keepalive(CURL *c) -{ - /* not supported on older curl versions */ -} #endif static void redact_sensitive_header(struct strbuf *header) @@ -1121,7 +1095,6 @@ void http_init(struct remote *remote, const char *url, int proactive_auth) no_pragma_header = curl_slist_append(http_copy_default_headers(), "Pragma:"); -#ifdef USE_CURL_MULTI { char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS"); if (http_max_requests != NULL) @@ -1131,7 +1104,6 @@ void http_init(struct remote *remote, const char *url, int proactive_auth) curlm = curl_multi_init(); if (!curlm) die("curl_multi_init failed"); -#endif if (getenv("GIT_SSL_NO_VERIFY")) curl_ssl_verify = 0; @@ -1154,10 +1126,8 @@ void http_init(struct remote *remote, const char *url, int proactive_auth) curl_ssl_verify = 1; curl_session_count = 0; -#ifdef USE_CURL_MULTI if (max_requests < 1) max_requests = DEFAULT_MAX_REQUESTS; -#endif set_from_env(&http_proxy_ssl_cert, "GIT_PROXY_SSL_CERT"); set_from_env(&http_proxy_ssl_key, "GIT_PROXY_SSL_KEY"); @@ -1201,9 +1171,7 @@ void http_cleanup(void) curl_easy_cleanup(curl_default); #endif -#ifdef USE_CURL_MULTI curl_multi_cleanup(curlm); -#endif curl_global_cleanup(); string_list_clear(&extra_http_headers, 0); @@ -1250,7 +1218,6 @@ struct active_request_slot *get_active_slot(void) struct active_request_slot *slot = active_queue_head; struct active_request_slot *newslot; -#ifdef USE_CURL_MULTI int num_transfers; /* Wait for a slot to open up if the queue is full */ @@ -1259,7 +1226,6 @@ struct active_request_slot *get_active_slot(void) if (num_transfers < active_requests) process_curl_messages(); } -#endif while (slot != NULL && slot->in_use) slot = slot->next; @@ -1330,7 +1296,6 @@ struct active_request_slot *get_active_slot(void) int start_active_slot(struct active_request_slot *slot) { -#ifdef USE_CURL_MULTI CURLMcode curlm_result = curl_multi_add_handle(curlm, slot->curl); int num_transfers; @@ -1348,11 +1313,9 @@ int start_active_slot(struct active_request_slot *slot) * something. */ curl_multi_perform(curlm, &num_transfers); -#endif return 1; } -#ifdef USE_CURL_MULTI struct fill_chain { void *data; int (*fill)(void *); @@ -1411,11 +1374,9 @@ void step_active_slots(void) fill_active_slots(); } } -#endif void run_active_slot(struct active_request_slot *slot) { -#ifdef USE_CURL_MULTI fd_set readfds; fd_set writefds; fd_set excfds; @@ -1428,7 +1389,6 @@ void run_active_slot(struct active_request_slot *slot) step_active_slots(); if (slot->in_use) { -#if LIBCURL_VERSION_NUM >= 0x070f04 long curl_timeout; curl_multi_timeout(curlm, &curl_timeout); if (curl_timeout == 0) { @@ -1440,10 +1400,6 @@ void run_active_slot(struct active_request_slot *slot) select_timeout.tv_sec = curl_timeout / 1000; select_timeout.tv_usec = (curl_timeout % 1000) * 1000; } -#else - select_timeout.tv_sec = 0; - select_timeout.tv_usec = 50000; -#endif max_fd = -1; FD_ZERO(&readfds); @@ -1466,12 +1422,6 @@ void run_active_slot(struct active_request_slot *slot) select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout); } } -#else - while (slot->in_use) { - slot->curl_result = curl_easy_perform(slot->curl); - finish_active_slot(slot); - } -#endif } static void release_active_slot(struct active_request_slot *slot) @@ -1485,9 +1435,7 @@ static void release_active_slot(struct active_request_slot *slot) curl_session_count--; } } -#ifdef USE_CURL_MULTI fill_active_slots(); -#endif } void finish_all_active_slots(void) @@ -1613,12 +1561,10 @@ static int handle_curl_result(struct slot_results *results) } else { if (results->http_connectcode == 407) credential_reject(&proxy_auth); -#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; } } diff --git a/http.h b/http.h index d2f8cc56617..cb092622a73 100644 --- a/http.h +++ b/http.h @@ -10,31 +10,12 @@ #include "remote.h" #include "url.h" -/* - * We detect based on the cURL version if multi-transfer is - * usable in this implementation and define this symbol accordingly. - * This shouldn't be set by the Makefile or by the user (e.g. via CFLAGS). - */ -#undef USE_CURL_MULTI - -#if LIBCURL_VERSION_NUM >= 0x071000 -#define USE_CURL_MULTI #define DEFAULT_MAX_REQUESTS 5 -#endif - -#if LIBCURL_VERSION_NUM >= 0x070c00 -#define curl_global_init(a) curl_global_init_mem(a, xmalloc, free, \ - xrealloc, xstrdup, xcalloc) -#endif -#if (LIBCURL_VERSION_NUM < 0x070c04) || (LIBCURL_VERSION_NUM == 0x071000) +#if LIBCURL_VERSION_NUM == 0x071000 #define NO_CURL_EASY_DUPHANDLE #endif -#if LIBCURL_VERSION_NUM < 0x070c03 -#define NO_CURL_IOCTL -#endif - /* * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4, * and the constants were known as CURLFTPSSL_* @@ -72,9 +53,7 @@ struct buffer { size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf); size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf); size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf); -#ifndef NO_CURL_IOCTL curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp); -#endif /* Slot lifecycle functions */ struct active_request_slot *get_active_slot(void); @@ -91,11 +70,9 @@ void finish_all_active_slots(void); int run_one_slot(struct active_request_slot *slot, struct slot_results *results); -#ifdef USE_CURL_MULTI void fill_active_slots(void); void add_fill_function(void *data, int (*fill)(void *)); void step_active_slots(void); -#endif void http_init(struct remote *remote, const char *url, int proactive_auth); diff --git a/imap-send.c b/imap-send.c index a0540ba5cf4..49a5f8aa597 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1517,11 +1517,7 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server, if (cred.username) { if (res == CURLE_OK) credential_approve(&cred); -#if LIBCURL_VERSION_NUM >= 0x070d01 else if (res == CURLE_LOGIN_DENIED) -#else - else -#endif credential_reject(&cred); } diff --git a/remote-curl.c b/remote-curl.c index e738ae2c48a..09f09aeece3 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -706,7 +706,6 @@ static size_t rpc_out(void *ptr, size_t eltsize, return avail; } -#ifndef NO_CURL_IOCTL static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp) { struct rpc_state *rpc = clientp; @@ -727,7 +726,6 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp) return CURLIOE_UNKNOWNCMD; } } -#endif struct check_pktline_state { char len_buf[4]; @@ -946,10 +944,8 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece rpc->initial_buffer = 1; curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out); curl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc); -#ifndef NO_CURL_IOCTL curl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl); curl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc); -#endif if (options.verbosity > 1) { fprintf(stderr, "POST %s (chunked)\n", rpc->service_name); fflush(stderr); From patchwork Fri Jul 30 09:31:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12410847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E341C4338F for ; Fri, 30 Jul 2021 09:35:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 003F560EFD for ; Fri, 30 Jul 2021 09:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238413AbhG3JfQ (ORCPT ); Fri, 30 Jul 2021 05:35:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238260AbhG3JfK (ORCPT ); Fri, 30 Jul 2021 05:35:10 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FBBFC0613C1 for ; Fri, 30 Jul 2021 02:35:05 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id j2so10452333wrx.9 for ; Fri, 30 Jul 2021 02:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pNdC/WwBBc1/PI2H4e+vgdiS2UAH7L7vhzHRVL7rSxE=; b=CAPFoC97m1pClb81nqMy8N/OuTa667aEvgYrT9Ft2fpqFvlR0FhylDnEqsW1O5w97n I6jOH1FJ36tu+B1DhxxrwFsshPbmU2ifHB9rL317Oo7eBBIYvEZxF7RpSsup5Ulz/LOV aJwrWUSqu+JeI6XWF4IyYg+fRtkYQ9oNTJ1aTOTJc9/lHRFGv9fGlFTXGZy1bY3XlUaw XhLuT2P6khz6ObhgStwBxWlp3+FSU2Sn98S97wvlvhvLeG6SLOfB0z+UrTYkjYZTTNaz lZZ0KeV+dvYVqA/3tWBsBNzp++grQ/jSYbSdugp4mluQ1rhDGDweV/QuDnspvUyBDm4b ePgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pNdC/WwBBc1/PI2H4e+vgdiS2UAH7L7vhzHRVL7rSxE=; b=Ts4slGM9YmJWBdnxMK7iNtL3kP6o7ySgxEJtvKeJyPjbw2PytD72uDq3bd+hEjor6K gDjDswIOLgeREc2BX1GW1pIW09V/CWs0t+Jk1NEx+tjBziyr+AG9sakOLmMwpHCrtRqt wzEbd8XZoJ7rYAvL+L0ALNcDj8nFAd3F7u1vMxhq6+0Q30oj+QFLXCrxE2O1r1EbIPUr 2N0GbohmIAshAH26obbZWsFY5eJoxVFTsLOGOEj2ZeOutyy6760ge0iwWlekwTHGq3dB I7a7eW61+ZGpFuo5Q5jL1IUBNklo+WTedvWIk7GWLyRqRg0xC1C04lIzqF+Vi200Iy1k JJHQ== X-Gm-Message-State: AOAM530u/Sh3YjHKbWomR2Mlc7IKay+gao7m4pA1Yhz85FYYdBadGEUK T3/3KAn2oeS0PuTU3IfEuvwuNTkWXFUZig== X-Google-Smtp-Source: ABdhPJxb42dzCGaehvXgdl9wEnTg6yCZu8rEDjEGSMIb5sevDftsLHxX2d9nG7VvTJzTyylZBKMckQ== X-Received: by 2002:adf:ed50:: with SMTP id u16mr2014956wro.174.1627637703764; Fri, 30 Jul 2021 02:35:03 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id t17sm1089903wru.94.2021.07.30.02.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 02:35:03 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Nicolas Morey-Chaisemartin , "Tom G . Christensen" , Mischa POSLAWSKY , Johannes Schindelin , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v3 3/7] http: drop support for curl < 7.19.4 Date: Fri, 30 Jul 2021 11:31:55 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.1069.g516d52f3d85 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King In the last commit we dropped support for curl < 7.16.0, let's continue that and drop support for versions older than 7.19.4. This allows us to simplify the code by getting rid of some "#ifdef"'s. Git was broken with vanilla curl < 7.19.4 from v2.12.0 until v2.15.0. Compiling with it was broken by using CURLPROTO_* outside any "#ifdef" in aeae4db174 (http: create function to get curl allowed protocols, 2016-12-14), and fixed in v2.15.0 in f18777ba6ef (http: fix handling of missing CURLPROTO_*, 2017-08-11). It's unclear how much anyone was impacted by that in practice, since as noted in [1] RHEL versions using curl older than that still compiled, because RedHat backported some features. Perhaps other vendors did the same. Still, it's one datapoint indicating that it wasn't in active use at the time. That (the v2.12.0 release) was in Feb 24, 2017, with v2.15.0 on Oct 30, 2017, it's now mid-2021. 1. http://lore.kernel.org/git/c8a2716d-76ac-735c-57f9-175ca3acbcb0@jupiterrise.com; followed-up by f18777ba6ef (http: fix handling of missing CURLPROTO_*, 2017-08-11) Signed-off-by: Jeff King Signed-off-by: Ævar Arnfjörð Bjarmason --- http.c | 50 -------------------------------------------------- http.h | 4 ---- 2 files changed, 54 deletions(-) diff --git a/http.c b/http.c index ef00e930232..1f0d7664d35 100644 --- a/http.c +++ b/http.c @@ -28,9 +28,7 @@ static int min_curl_sessions = 1; static int curl_session_count; static int max_requests = -1; static CURLM *curlm; -#ifndef NO_CURL_EASY_DUPHANDLE static CURL *curl_default; -#endif #define PREV_BUF_SIZE 4096 @@ -440,24 +438,8 @@ static void init_curl_http_auth(CURL *result) credential_fill(&http_auth); -#if LIBCURL_VERSION_NUM >= 0x071301 curl_easy_setopt(result, CURLOPT_USERNAME, http_auth.username); curl_easy_setopt(result, CURLOPT_PASSWORD, http_auth.password); -#else - { - static struct strbuf up = STRBUF_INIT; - /* - * Note that we assume we only ever have a single set of - * credentials in a given program run, so we do not have - * to worry about updating this buffer, only setting its - * initial value. - */ - if (!up.len) - strbuf_addf(&up, "%s:%s", - http_auth.username, http_auth.password); - curl_easy_setopt(result, CURLOPT_USERPWD, up.buf); - } -#endif } /* *var must be free-able */ @@ -471,22 +453,10 @@ static void var_override(const char **var, char *value) static void set_proxyauth_name_password(CURL *result) { -#if LIBCURL_VERSION_NUM >= 0x071301 curl_easy_setopt(result, CURLOPT_PROXYUSERNAME, proxy_auth.username); curl_easy_setopt(result, CURLOPT_PROXYPASSWORD, proxy_auth.password); -#else - struct strbuf s = STRBUF_INIT; - - strbuf_addstr_urlencode(&s, proxy_auth.username, - is_rfc3986_unreserved); - strbuf_addch(&s, ':'); - strbuf_addstr_urlencode(&s, proxy_auth.password, - is_rfc3986_unreserved); - curl_proxyuserpwd = strbuf_detach(&s, NULL); - curl_easy_setopt(result, CURLOPT_PROXYUSERPWD, curl_proxyuserpwd); -#endif } static void init_curl_proxy_auth(CURL *result) @@ -748,7 +718,6 @@ void setup_curl_trace(CURL *handle) curl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL); } -#ifdef CURLPROTO_HTTP static long get_curl_allowed_protocols(int from_user) { long allowed_protocols = 0; @@ -764,7 +733,6 @@ static long get_curl_allowed_protocols(int from_user) return allowed_protocols; } -#endif #if LIBCURL_VERSION_NUM >=0x072f00 static int get_curl_http_version_opt(const char *version_string, long *opt) @@ -906,19 +874,11 @@ static CURL *get_curl_handle(void) } curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20); -#if LIBCURL_VERSION_NUM >= 0x071301 curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL); -#elif LIBCURL_VERSION_NUM >= 0x071101 - curl_easy_setopt(result, CURLOPT_POST301, 1); -#endif -#ifdef CURLPROTO_HTTP curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS, get_curl_allowed_protocols(0)); curl_easy_setopt(result, CURLOPT_PROTOCOLS, get_curl_allowed_protocols(-1)); -#else - warning(_("Protocol restrictions not supported with cURL < 7.19.4")); -#endif if (getenv("GIT_CURL_VERBOSE")) http_trace_curl_no_data(); setup_curl_trace(result); @@ -1012,11 +972,9 @@ static CURL *get_curl_handle(void) die("Invalid proxy URL '%s'", curl_http_proxy); curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host); -#if LIBCURL_VERSION_NUM >= 0x071304 var_override(&curl_no_proxy, getenv("NO_PROXY")); var_override(&curl_no_proxy, getenv("no_proxy")); curl_easy_setopt(result, CURLOPT_NOPROXY, curl_no_proxy); -#endif } init_curl_proxy_auth(result); @@ -1147,9 +1105,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth) ssl_cert_password_required = 1; } -#ifndef NO_CURL_EASY_DUPHANDLE curl_default = get_curl_handle(); -#endif } void http_cleanup(void) @@ -1167,9 +1123,7 @@ void http_cleanup(void) } active_queue_head = NULL; -#ifndef NO_CURL_EASY_DUPHANDLE curl_easy_cleanup(curl_default); -#endif curl_multi_cleanup(curlm); curl_global_cleanup(); @@ -1248,11 +1202,7 @@ struct active_request_slot *get_active_slot(void) } if (slot->curl == NULL) { -#ifdef NO_CURL_EASY_DUPHANDLE - slot->curl = get_curl_handle(); -#else slot->curl = curl_easy_duphandle(curl_default); -#endif curl_session_count++; } diff --git a/http.h b/http.h index cb092622a73..19f19dbe74c 100644 --- a/http.h +++ b/http.h @@ -12,10 +12,6 @@ #define DEFAULT_MAX_REQUESTS 5 -#if LIBCURL_VERSION_NUM == 0x071000 -#define NO_CURL_EASY_DUPHANDLE -#endif - /* * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4, * and the constants were known as CURLFTPSSL_* From patchwork Fri Jul 30 09:31:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12410851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E1D1C4338F for ; Fri, 30 Jul 2021 09:35:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 597D760EFD for ; Fri, 30 Jul 2021 09:35:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238241AbhG3JfW (ORCPT ); Fri, 30 Jul 2021 05:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230522AbhG3JfL (ORCPT ); Fri, 30 Jul 2021 05:35:11 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C07C061765 for ; Fri, 30 Jul 2021 02:35:06 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id c16so10448837wrp.13 for ; Fri, 30 Jul 2021 02:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tcsh00QOQf+qysdPnrhEpOfwU5gWW3FuwQOuDiE/zw4=; b=IloGr6YruR3m/jj37m7KMEKuOEL0K3rIzBcH0aogONMGcId+UJeO11+TrwR8ejrSHm ZW+dVWTzlZRjirIyteRLkbkqa5yvoRhwDDuoEb7Z+8/YzECndMwdgqX0ZruxDVod48X9 Yy1THJbQv6gSLUo9yc6eC6yrulf/hGttpgypdFrPsUXMDpkRXiGa7CqayGz7R6tlH2pg 1gAEsu9j7h0ZAb4ZrimGGFwQhXY0XiWPS2P7XlqTo3QcDelfQ3dZkivkNU4oCxVThus0 mZNKXLQiOSqwzBBUpAHsc8yQb9Hiv0ocn9gvXYpT2CGUaJgqmf5FkzvPBKC4BSKYWG8l 3GnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tcsh00QOQf+qysdPnrhEpOfwU5gWW3FuwQOuDiE/zw4=; b=JHngNnCkk2DfKSc5YkDfX2CNPnD9Wp3Zw77/JTInAxB6XOwxlTFmNrYe0shLMtrB0J 92ZoFIv0NZdgb/sNZ/vtJEiz+YIqWEAyi8XPQu2dWqI1t+OaPtH+Y4Ry1XSDj4icZL7l eIYaEBcJnsj24SOMkOPgY29RnIByydZ9B7CcLQOMotMjfYUZaI5oDYZd5vtcd/1uxcte SA3benSYWYS79V5rUWqZbTsbCXnaatAfYK5BCdVB7dV+3B6CBBqz1YG0+JavX6cNZKhT QDd3GQLJIRSOw0OTTfL1m6W0q+tXD07Dq/PPDCZY65X/ONXpi7oGj1p5WSQBZ7Jke6Yf +SpQ== X-Gm-Message-State: AOAM533migMJdkZKZczEbytf90mu5P+4VmY3gj1ZC2FXexy7KSVsQovF zJYdftMsHw7/eJAAQmJOreGaB9HtbIecWw== X-Google-Smtp-Source: ABdhPJyygJboU2kxiNvMb/PTiX4X7bT0ifO7ts9WAy5L46m7VPe/COWBR3KNjr6nuY4QpThsjZX/vA== X-Received: by 2002:a5d:4688:: with SMTP id u8mr2021315wrq.65.1627637704684; Fri, 30 Jul 2021 02:35:04 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id t17sm1089903wru.94.2021.07.30.02.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 02:35:04 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Nicolas Morey-Chaisemartin , "Tom G . Christensen" , Mischa POSLAWSKY , Johannes Schindelin , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v3 4/7] http: drop support for curl < 7.19.3 and <= 7.16.4 (or <7.17.0) (again) Date: Fri, 30 Jul 2021 11:31:56 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.1069.g516d52f3d85 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the conditional use of CURLAUTH_DIGEST_IE and CURLOPT_USE_SSL. These two have been split from earlier simpler checks against LIBCURL_VERSION_NUM for ease of review. The CURLAUTH_DIGEST_IE flag was added in 7.19.3[1], and CURLOPT_USE_SSL in 7.16.4[2] or 7.17.0[3], depending on the source. As noted in [2] it was then renamed around that time from the older CURLOPT_FTP_SSL. 1. https://curl.se/libcurl/c/CURLOPT_HTTPAUTH.html 2. https://curl.se/libcurl/c/CURLOPT_USE_SSL.html 3. https://github.com/curl/curl/blob/master/docs/libcurl/symbols-in-versions Signed-off-by: Ævar Arnfjörð Bjarmason --- http.c | 4 ---- http.h | 9 --------- 2 files changed, 13 deletions(-) diff --git a/http.c b/http.c index 1f0d7664d35..e9446850a62 100644 --- a/http.c +++ b/http.c @@ -120,9 +120,7 @@ static int http_auth_methods_restricted; /* Modes for which empty_auth cannot actually help us. */ static unsigned long empty_auth_useless = CURLAUTH_BASIC -#ifdef CURLAUTH_DIGEST_IE | CURLAUTH_DIGEST_IE -#endif | CURLAUTH_DIGEST; static struct curl_slist *pragma_header; @@ -893,10 +891,8 @@ static CURL *get_curl_handle(void) if (curl_ftp_no_epsv) curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0); -#ifdef CURLOPT_USE_SSL if (curl_ssl_try) curl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY); -#endif /* * CURL also examines these variables as a fallback; but we need to query diff --git a/http.h b/http.h index 19f19dbe74c..3db5a0cf320 100644 --- a/http.h +++ b/http.h @@ -12,15 +12,6 @@ #define DEFAULT_MAX_REQUESTS 5 -/* - * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4, - * and the constants were known as CURLFTPSSL_* -*/ -#if !defined(CURLOPT_USE_SSL) && defined(CURLOPT_FTP_SSL) -#define CURLOPT_USE_SSL CURLOPT_FTP_SSL -#define CURLUSESSL_TRY CURLFTPSSL_TRY -#endif - struct slot_results { CURLcode curl_result; long http_code; From patchwork Fri Jul 30 09:31:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12410849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31F22C432BE for ; Fri, 30 Jul 2021 09:35:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0371A61019 for ; Fri, 30 Jul 2021 09:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238226AbhG3JfV (ORCPT ); Fri, 30 Jul 2021 05:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238383AbhG3JfL (ORCPT ); Fri, 30 Jul 2021 05:35:11 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 348A6C0613CF for ; Fri, 30 Jul 2021 02:35:07 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id b7so10478826wri.8 for ; Fri, 30 Jul 2021 02:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QjLlhSd8jpa9eE9Fi6inh2kZu/6i1DtCn1uu8xh0xkU=; b=ovPgFo2KJ+8+Pw6zmQiRqTrqrfSWyQF5qEDGU/famXmms55pfnN9AFInbjriq++bLQ ImLYJvQblr+UbMYwYN1SbJVUIVty0Y8T7Vn4MU3sWAhcdB2kMc6Tbx24jycoZ4oKVvQV OmQSrzVL/nBvpzpr7KtBHuakYm/21SbG6MNK8HZnqRTEAaFbmeQHXJ6kNdlZw9bLusGA mmKrikRsxWag/qwCInx/BRxHGEYy5Z54IV3OZ4OJgT2WgMjSyFxcGss5dQaYnT2xabE9 MiRvs81198c18dol7fxIuJNMHKE3DGDPpQ9Bsfs46YhaasJt66EKOE4FJ0Gg/sGptg8z tiHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QjLlhSd8jpa9eE9Fi6inh2kZu/6i1DtCn1uu8xh0xkU=; b=seqWsFQycIPu2MtVKLpK7lJ3jOPz0OzeCSOTwtu80+xmchN2gGFSZ1074Xouf3HxVe HKxq1jYJngaYTLkJ55AOIZzO1eitlQp5ICOLONZdniq7y8fJAAvj1AZGsihItar6l9LE 6d9uctBTy9yt/lVKwkSlrXzJbrElXhtVO5z6sW17BoS2L+Izpe9WJpxcNEqddfzUcqMc hhOwtqM1VZX15tt2GL+GpVUMjybxrDNF1a4yY6CL/35XuvPf6ELJqxHJQQccbybC1Eky yUny5hxwF9efn0QA315G+goUY7T4x2z+8WWohtkd/aAhV4ux4hdvOAPOdF83wI0OdtWY nedw== X-Gm-Message-State: AOAM532yl8LsAfFFilijqNtAqLOzy5kt/WJEvHPgiyeioSvHMNOgyM17 UEPGZKjCqVunTp5aQQ4aDBENOABGZgukjQ== X-Google-Smtp-Source: ABdhPJzAQp5W8M2C7G5wQVfRph+702bFtoKQsC7bI8DP2jvyhgJN8T0KdW+UZ7H0YL5+H3w981aHhQ== X-Received: by 2002:a5d:674c:: with SMTP id l12mr2053010wrw.112.1627637705624; Fri, 30 Jul 2021 02:35:05 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id t17sm1089903wru.94.2021.07.30.02.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 02:35:05 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Nicolas Morey-Chaisemartin , "Tom G . Christensen" , Mischa POSLAWSKY , Johannes Schindelin , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v3 5/7] http: drop support for curl < 7.18.0 (again) Date: Fri, 30 Jul 2021 11:31:57 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.1069.g516d52f3d85 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a preceding commit we dropped support for curl < 7.19.4, so we can drop support for this non-obvious dependency on curl < 7.18.0. It's non-obvious because in curl's hex version notation 0x071800 is version 7.24.0, *not* 7.18.0, so at a glance this patch looks incorrect. But it's correct, because the existing version check being removed here is wrong. The check guards use of the following curl defines: CURLPROXY_SOCKS4 7.10 CURLPROXY_SOCKS4A 7.18.0 CURLPROXY_SOCKS5 7.10 CURLPROXY_SOCKS5_HOSTNAME 7.18.0 I.e. the oldest version that has these is in fact 7.18.0, not 7.24.0. That we were checking 7.24.0 is just an mistake in 6d7afe07f29 (remote-http(s): support SOCKS proxies, 2015-10-26), i.e. its author confusing base 10 and base 16. Signed-off-by: Ævar Arnfjörð Bjarmason --- http.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/http.c b/http.c index e9446850a62..477bf591141 100644 --- a/http.c +++ b/http.c @@ -927,7 +927,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,7 +939,6 @@ 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 else if (starts_with(curl_http_proxy, "https")) { curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS); From patchwork Fri Jul 30 09:31:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12410853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B893CC432BE for ; Fri, 30 Jul 2021 09:35:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90D1C60EFD for ; Fri, 30 Jul 2021 09:35:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238409AbhG3JfZ (ORCPT ); Fri, 30 Jul 2021 05:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238395AbhG3JfM (ORCPT ); Fri, 30 Jul 2021 05:35:12 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1817FC061796 for ; Fri, 30 Jul 2021 02:35:08 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id p5so10473443wro.7 for ; Fri, 30 Jul 2021 02:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eEXeBKHIUwCUIIZc1vWFhEIlhiwH0AhirZzsUsDqYNk=; b=J0yB+qYfmYiUQqxU/SNL4n8UIMEDJ0lDyNhnQHAa/KibFtRD3X0waJOY46CCVvEPhm pzfcXl3uEQ+6js1/MyPk9i4qaOwwQJTHa1Bdt5GOlkFJ5ecmOjKY6rHi58vwCiE4C16/ YFIMkLhC1o4e6FB90skYUJlhKLONb2mqGbA5q94zu3Sc5sh/xKe6mkqGgKHGI+xGf/2w DWovEWa3ZfujjcoZdhr+X1BhYvUypwPu5CUY1AFBi4xkeMR3s92V5SLVynmrq3/o2oq6 VXDUi2hU4H/6fDotm03js6T/s85jmLDeswUYPvuNbEDDfBG9Y3UpA54LAFzw7gxoRULg dliQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eEXeBKHIUwCUIIZc1vWFhEIlhiwH0AhirZzsUsDqYNk=; b=LZr2S5QxAD/lak2SSLKDq0cvDU/k8JXxzUvi8zSzu+DagxeA4URY79RHOYq/tddhph WeOQbJVLD2LI2CXU/ooFxZCeurtXQ0FwsuF6IzBIPB6Ky5ZBaBnZp2fUYaz5cDFmpf25 oFty7em+EyyG3mk5d+bQWx82spYueWdQbVX8iJs1k8GGSfcfFHmShGbU21XxT53GjjPC +Jz6m9C66RXa3hiwZ+ebZXGQB7+DrVkCliNbucc5xxsWIgD9fyXElCqbzfC4qyA8wspB V+XuzMb2NuEXKY3H8sckEaJvwsy2+LKUl0k4aUQhv1qIV9oWYIsXTT9mZv2tNUOmXK+9 ByNg== X-Gm-Message-State: AOAM531HrBYi/MMEW0KVG+jZuNvXwcWqHznPghBAxyH/aqM+alDzsHhU ZF8xV9CmZVy2BP6d7PUTlhPQ2Erl01U1qg== X-Google-Smtp-Source: ABdhPJwNMh8iJm558TLvhPwl+YSOTfndHQvl/hMxJOk65hNKWUnIIH4ltE+3TWyeScF9H4UTO/MRGw== X-Received: by 2002:adf:d20c:: with SMTP id j12mr2037143wrh.74.1627637706437; Fri, 30 Jul 2021 02:35:06 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id t17sm1089903wru.94.2021.07.30.02.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 02:35:06 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Nicolas Morey-Chaisemartin , "Tom G . Christensen" , Mischa POSLAWSKY , Johannes Schindelin , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v3 6/7] http: rename CURLOPT_FILE to CURLOPT_WRITEDATA Date: Fri, 30 Jul 2021 11:31:58 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.1069.g516d52f3d85 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The CURLOPT_FILE name is an alias for CURLOPT_WRITEDATA, the CURLOPT_WRITEDATA name has been preferred since curl 7.9.7, released in May 2002[1]. 1. https://curl.se/libcurl/c/CURLOPT_WRITEDATA.html Signed-off-by: Ævar Arnfjörð Bjarmason --- http-push.c | 6 +++--- http-walker.c | 2 +- http.c | 6 +++--- remote-curl.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/http-push.c b/http-push.c index aa3de7c1086..3309aaf004a 100644 --- a/http-push.c +++ b/http-push.c @@ -883,7 +883,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout) slot->results = &results; curl_setup_http(slot->curl, url, DAV_LOCK, &out_buffer, fwrite_buffer); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers); - curl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer); + curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &in_buffer); CALLOC_ARRAY(lock, 1); lock->timeout = -1; @@ -1142,7 +1142,7 @@ static void remote_ls(const char *path, int flags, curl_setup_http(slot->curl, url, DAV_PROPFIND, &out_buffer, fwrite_buffer); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers); - curl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer); + curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &in_buffer); if (start_active_slot(slot)) { run_active_slot(slot); @@ -1216,7 +1216,7 @@ static int locking_available(void) curl_setup_http(slot->curl, repo->url, DAV_PROPFIND, &out_buffer, fwrite_buffer); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers); - curl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer); + curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &in_buffer); if (start_active_slot(slot)) { run_active_slot(slot); diff --git a/http-walker.c b/http-walker.c index 19e31623f04..910fae539b8 100644 --- a/http-walker.c +++ b/http-walker.c @@ -378,7 +378,7 @@ static void fetch_alternates(struct walker *walker, const char *base) alt_req.walker = walker; slot->callback_data = &alt_req; - curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer); + curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer); curl_easy_setopt(slot->curl, CURLOPT_URL, url.buf); diff --git a/http.c b/http.c index 477bf591141..56856178bfe 100644 --- a/http.c +++ b/http.c @@ -1767,7 +1767,7 @@ static int http_request(const char *url, curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1); } else { curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0); - curl_easy_setopt(slot->curl, CURLOPT_FILE, result); + curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, result); if (target == HTTP_REQUEST_FILE) { off_t posn = ftello(result); @@ -2184,7 +2184,7 @@ struct http_pack_request *new_direct_http_pack_request( } preq->slot = get_active_slot(); - curl_easy_setopt(preq->slot->curl, CURLOPT_FILE, preq->packfile); + curl_easy_setopt(preq->slot->curl, CURLOPT_WRITEDATA, preq->packfile); curl_easy_setopt(preq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite); curl_easy_setopt(preq->slot->curl, CURLOPT_URL, preq->url); curl_easy_setopt(preq->slot->curl, CURLOPT_HTTPHEADER, @@ -2355,7 +2355,7 @@ struct http_object_request *new_http_object_request(const char *base_url, freq->slot = get_active_slot(); - curl_easy_setopt(freq->slot->curl, CURLOPT_FILE, freq); + curl_easy_setopt(freq->slot->curl, CURLOPT_WRITEDATA, freq); curl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0); curl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file); curl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr); diff --git a/remote-curl.c b/remote-curl.c index 09f09aeece3..598cff7cde6 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -853,7 +853,7 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results) curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer); - curl_easy_setopt(slot->curl, CURLOPT_FILE, &buf); + curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &buf); err = run_slot(slot, results); @@ -1016,7 +1016,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece rpc_in_data.slot = slot; rpc_in_data.check_pktline = stateless_connect; memset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state)); - curl_easy_setopt(slot->curl, CURLOPT_FILE, &rpc_in_data); + curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &rpc_in_data); curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0); From patchwork Fri Jul 30 09:31:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12410855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4205FC4338F for ; Fri, 30 Jul 2021 09:35:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2804A603E9 for ; Fri, 30 Jul 2021 09:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238350AbhG3Jfc (ORCPT ); Fri, 30 Jul 2021 05:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238260AbhG3JfR (ORCPT ); Fri, 30 Jul 2021 05:35:17 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07307C061798 for ; Fri, 30 Jul 2021 02:35:09 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id p5so10473498wro.7 for ; Fri, 30 Jul 2021 02:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3ILv9UhtlUCYHUNNELduf5g2fPWJrl6CXDzT+n8a1U8=; b=H9n+WEZ3BRByGh0BVI3WWvf2P3j+3MX93X5umVGXXv8q7+56BOsLHRE97MkEftdxqz /+UAGPLWCuyWl9/0i0Q59isERk8MgSQNgGQplTFSg7Gh2YpPqLch1bE+DOLd/u2HzIxy KWEp9cc1BTgQ+9EnMBFBdEfZLiI0geB128ewHHqFefzFdSdayx27b2oJVDKBKgdiS1j0 TG14zRnSewitiBP02PQUqShfBLzXc5LmlJARAHc47ymXmK5P06sU+qUeyQAFb/DQjowY qt+boqJQmxjJ2/FN9bGWAqzpe4jYAph52CWd/XLhplthIGBZQfyzxqAZ2DJXdVMutbdB m1Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3ILv9UhtlUCYHUNNELduf5g2fPWJrl6CXDzT+n8a1U8=; b=ehkqJoza6gqiNc+wm6le+cyvFypGsJgmVJnZQyYMf8XcBr94+l6okm9FrgWzb6wRyF LKwFojMy74v8VmdJroQGFL1eUofJpR8y9kVhLM8HwrJ53LHS7JQ+laIIik68FzmzwrEJ Dal6semK9WjHza8LZ5kHel0ym/YOPXCyV140EZzsVYwxLjArADgMREtJMmlNUfoj0Gxz sDXouy0MwHkColhRPRXFaNMDn67J3A5yFVuVf/pT10SUahNs1MifLnfDbi5J5IlXYVp/ 00nX4K9hI/8tGcMgLGK3+eaJcnZlVOKDWjL7nWmliaR7l3PrLRtSQOkU6jhu8U277ysT NTVQ== X-Gm-Message-State: AOAM532TO9mhRW7NMImKqonareLFpFGh1+IwF7a5yvTPaL7F3MsTr0XF xdeXymz2YNRcai92P395OquipxQdcI/DSQ== X-Google-Smtp-Source: ABdhPJzVpUSrY6VZ2YYxT/Km5MkHPDNI0FFFx2De9GVdyhw56r7VKbQGfQbAmJ58UJMUUKtGYTAU4A== X-Received: by 2002:adf:e6cf:: with SMTP id y15mr1968555wrm.217.1627637707333; Fri, 30 Jul 2021 02:35:07 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id t17sm1089903wru.94.2021.07.30.02.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 02:35:06 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Nicolas Morey-Chaisemartin , "Tom G . Christensen" , Mischa POSLAWSKY , Johannes Schindelin , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v3 7/7] http: centralize the accounting of libcurl dependencies Date: Fri, 30 Jul 2021 11:31:59 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.1069.g516d52f3d85 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As noted in preceding commits checking against LIBCURL_VERSION_NUM isn't as reliable as checking specific defines in curl, as some distros have been known to backport features. Furthermore we had at least one case of someone confusing base 10 for base 16 in comparing the version. Let's add a git-curl-compat.h header that'll keep track of these dependencies, and make the next round of deprecations easier. This patch is mostly obvious, with the following exceptions: - In aeff8a61216 (http: implement public key pinning, 2016-02-15) a dependency and warning() was added if curl older than 7.44.0 was used, but the relevant code depended on CURLOPT_PINNEDPUBLICKEY, introduced in 7.39.0. - We did not use CURL_SOCKOPT_OK and instead hardcoded its value in a15d069a198 (http: enable keepalive on TCP sockets, 2013-10-12), let's use it and guard its use by a new GITCURL_HAVE_* check. - We guarded the support for http.version with a check for curl 7.47.0, looking at the history of how that happen reveals that an earlier on-list version of d73019feb44 (http: add support selecting http version, 2018-11-08) depended on CURL_HTTP_VERSION_2TLS (which was added in 7.47.0). But the version this code depended on was in fact 7.43.0, since that's when CURL_HTTP_VERSION_2_0 was added. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-curl-compat.h | 119 ++++++++++++++++++++++++++++++++++++++++++++++ http.c | 41 ++++++++-------- imap-send.c | 6 +-- 3 files changed, 143 insertions(+), 23 deletions(-) create mode 100644 git-curl-compat.h diff --git a/git-curl-compat.h b/git-curl-compat.h new file mode 100644 index 00000000000..554f244034e --- /dev/null +++ b/git-curl-compat.h @@ -0,0 +1,119 @@ +#ifndef GIT_CURL_COMPAT_H +#define GIT_CURL_COMPAT_H + +/** + * This header centralized 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 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 check if it exists and + * declare our own GIT_CURl_HAVE_X, or if it's for both X and Y + * GIT_CURl_HAVE_X_and_Y, where the "Y" in "X_and_Y" is only the part + * of the symbol name that "X" and "Y" don't have in common. + * + * We avoid comparisons against LIBCURL_VERSION_NUM, enterprise + * distros have been known to backport symbols to their older curl + * versions. + * + * Keep any symbols in date order of when their support was + * introduced, oldest first. + */ + +/** + * CURL_SOCKOPT_OK was added in 7.21.5, released in April 2011. + */ +#ifdef CURL_SOCKOPT_OK +#define GITCURL_HAVE_CURL_SOCKOPT_OK 1 +#endif + +/** + * CURLOPT_TCP_KEEPALIVE was added in 7.25.0, released in March 2012. + */ +#ifdef CURLOPT_TCP_KEEPALIVE +#define GITCURL_HAVE_CURLOPT_TCP_KEEPALIVE 1 +#endif + + +/** + * CURLOPT_LOGIN_OPTIONS was added in 7.34.0, released in December + * 2013. + */ +#ifdef CURLOPT_LOGIN_OPTIONS +#define GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS 1 +#endif + +/** + * CURL_SSLVERSION_TLSv1_[012] was added in 7.34.0, released in + * December 2013. + */ +#if defined(CURL_SSLVERSION_TLSv1_0) && \ + defined(CURL_SSLVERSION_TLSv1_1) && \ + defined(CURL_SSLVERSION_TLSv1_2) +#define GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0_and_1_and_2 +#endif + +/** + * CURLOPT_PINNEDPUBLICKEY was added in 7.39.0, released in November + * 2014. + */ +#ifdef CURLOPT_PINNEDPUBLICKEY +#define GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY 1 +#endif + +/** + * CURL_HTTP_VERSION_2 was added in 7.43.0, released in June 2015. + */ +#ifdef CURL_HTTP_VERSION_2 +#define GIT_CURL_HAVE_CURL_HTTP_VERSION_2 1 +#endif + +/** + * CURLSSLOPT_NO_REVOKE was added in 7.44.0, released in August 2015. + */ +#ifdef CURLSSLOPT_NO_REVOKE +#define GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE 1 +#endif + +/** + * CURLOPT_PROXY_CAINFO was added in 7.52.0, released in August 2017. + */ +#ifdef CURLOPT_PROXY_CAINFO +#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 defined(CURLOPT_PROXY_KEYPASSWD) && \ + defined(CURLOPT_PROXY_SSLCERT) && \ + defined(CURLOPT_PROXY_SSLKEY) +#define GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD_and_SSLCERT_and_SSLKEY 1 +#endif + +/** + * CURL_SSLVERSION_TLSv1_3 was added in 7.53.0, released in February + * 2017. + */ +#ifdef CURL_SSLVERSION_TLSv1_3 +#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 defined(CURLSSLSET_NO_BACKENDS) && \ + defined(CURLSSLSET_OK) && \ + defined(CURLSSLSET_TOO_LATE) && \ + defined(CURLSSLSET_UNKNOWN_BACKEND) +#define GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS_and_OK_and_TOO_LATE_and_UNKNOWN_BACKEND 1 +#endif + +#endif diff --git a/http.c b/http.c index 56856178bfe..e8939a1ccf6 100644 --- a/http.c +++ b/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,21 +48,19 @@ static struct { { "sslv2", CURL_SSLVERSION_SSLv2 }, { "sslv3", CURL_SSLVERSION_SSLv3 }, { "tlsv1", CURL_SSLVERSION_TLSv1 }, -#if LIBCURL_VERSION_NUM >= 0x072200 +#if GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0_AND_1_AND_2 { "tlsv1.0", CURL_SSLVERSION_TLSv1_0 }, { "tlsv1.1", CURL_SSLVERSION_TLSv1_1 }, { "tlsv1.2", CURL_SSLVERSION_TLSv1_2 }, #endif -#if LIBCURL_VERSION_NUM >= 0x073400 +#if 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 static const char *ssl_pinnedkey; -#endif static const char *ssl_cainfo; static long curl_low_speed_limit = -1; static long curl_low_speed_time = -1; @@ -373,12 +372,10 @@ static int http_options(const char *var, const char *value, void *cb) } if (!strcmp("http.pinnedpubkey", var)) { -#if LIBCURL_VERSION_NUM >= 0x072c00 - return git_config_pathname(&ssl_pinnedkey, var, value); -#else - warning(_("Public key pinning not supported with cURL < 7.44.0")); - return 0; +#ifndef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY + warning(_("Public key pinning not supported with cURL < 7.39.0")); #endif + return git_config_pathname(&ssl_pinnedkey, var, value); } if (!strcmp("http.extraheader", var)) { @@ -500,7 +497,7 @@ static int has_cert_password(void) return 1; } -#if LIBCURL_VERSION_NUM >= 0x073400 +#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD_and_SSLCERT_and_SSLKEY static int has_proxy_cert_password(void) { if (http_proxy_ssl_cert == NULL || proxy_ssl_cert_password_required != 1) @@ -516,7 +513,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 +533,11 @@ 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 */ +#ifdef GITCURL_HAVE_CURL_SOCKOPT_OK + return CURL_SOCKOPT_OK; +#else + return 0; +#endif } 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 @@ -939,7 +940,7 @@ static CURL *get_curl_handle(void) else if (starts_with(curl_http_proxy, "socks")) curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); -#if LIBCURL_VERSION_NUM >= 0x073400 +#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD_and_SSLCERT_and_SSLKEY else if (starts_with(curl_http_proxy, "https")) { curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS); @@ -1004,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_and_OK_and_TOO_LATE_and_UNKNOWN_BACKEND if (http_ssl_backend) { const curl_ssl_backend **backends; struct strbuf buf = STRBUF_INIT; diff --git a/imap-send.c b/imap-send.c index 49a5f8aa597..2da96a9532f 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1441,14 +1441,14 @@ 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 - warning("No LOGIN_OPTIONS support in this cURL version"); -#else +#ifdef GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS struct strbuf auth = STRBUF_INIT; strbuf_addstr(&auth, "AUTH="); strbuf_addstr(&auth, server.auth_method); curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, auth.buf); strbuf_release(&auth); +#else + warning("No LOGIN_OPTIONS support in this cURL version"); #endif }