From patchwork Wed Sep 8 15:31:52 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: 12481363 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.7 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 F1F1AC433EF for ; Wed, 8 Sep 2021 15:32:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D93EF610E8 for ; Wed, 8 Sep 2021 15:32:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352106AbhIHPd0 (ORCPT ); Wed, 8 Sep 2021 11:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230090AbhIHPdL (ORCPT ); Wed, 8 Sep 2021 11:33:11 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABD80C061757 for ; Wed, 8 Sep 2021 08:32:03 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id n14-20020a05600c3b8e00b002f8bd2f8ab6so1936578wms.5 for ; Wed, 08 Sep 2021 08:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SpQsoKx18BbT4CkvCLWDRjOovXm2qc+ZFQQbmLo9usw=; b=LscmegjHY/TXWCiCCi8YVvWk1bekbcB/YHVUNNv3nVpGCOQfA9ZuCjc80gDDhpXdXf QCkLwM6lrzM+DHxjIpPM5zGL1us1GpZca4RQJmj+JtybrU7LkAb5XAISIGM1vawNX5Uv RyjCmLPAcsBEeX17nkrUM4sNVPqRYNI8RuRUnPGW0mYuo4hzD0XjPoCPgDshS258JoZm WwceOUx3FAmldoiPB+qtg4mowJu9ysrm2nM94pqbqDqeWWUmba6ut1fuY25/5M8I/n/M apiwR58EdgzXQfxO+k1c99MeuCLikTTXVUbiTZ2uIWTQbe3XrCBe+1U6BJOnN3Jbdi6J KjtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SpQsoKx18BbT4CkvCLWDRjOovXm2qc+ZFQQbmLo9usw=; b=YGgoFjw3B6V1V29RK4RkqxXtlPU0VkSfI0iqDLXKOurFCUWTCvbKCt8uk5jhCphn7R APcgJC6yfvMgMIsT43z3pjOqfEiAxykvuyy8Q/u5oW1IpdNXeJjFrP1IC8VTnaTJYgOn DptDc0Z1OJTk4hrIK5PdtR94pw6TTtJxEGevNG08NA/XLApi2YMzunevXar1X1EJaPWS CCakpMeIHYcYEzmViBD5EC+8FoT8VysrP5l5Z8YzzCIF3fQRDSIbFWojMpOn7XVCMA1p oWzX8CQZ2kCFIRSfduEAUjIm0nVur2NUPBdYL+/p+nj5hH5oJj6uvbPm3c04Bz52Dwh3 TTTg== X-Gm-Message-State: AOAM530UvR/m8vtGGEEsvRC8mU6k61u4LAPWEDjWVvgj1Wh+MA4n2iRn bO2UVrxShHJODcOleL4TOdclTkBTP9IDKw== X-Google-Smtp-Source: ABdhPJzWdRD/tcm6+X9RiSzrtAekM+8bo30KO4NTrtTb0TBDIZVF6cOs1TWzoAHXALuZQqEeQd0WNA== X-Received: by 2002:a05:600c:4f0b:: with SMTP id l11mr4156433wmq.126.1631115122048; Wed, 08 Sep 2021 08:32:02 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id j17sm2385580wrh.67.2021.09.08.08.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 08:32:01 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 1/5] http: drop support for curl < 7.18.0 (again) Date: Wed, 8 Sep 2021 17:31:52 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.825.g2bf60429931 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 644de29e220 (http: drop support for curl < 7.19.4, 2021-07-30) 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 a0f169d2fe5..56856178bfe 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 Wed Sep 8 15: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: 12481365 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.7 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 CEC35C433F5 for ; Wed, 8 Sep 2021 15:32:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6FBD610E9 for ; Wed, 8 Sep 2021 15:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352121AbhIHPdf (ORCPT ); Wed, 8 Sep 2021 11:33:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349619AbhIHPdN (ORCPT ); Wed, 8 Sep 2021 11:33:13 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E20CC0613C1 for ; Wed, 8 Sep 2021 08:32:04 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 192-20020a1c04c9000000b002f7a4ab0a49so1476699wme.0 for ; Wed, 08 Sep 2021 08:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UezT40KMIcX23ehphtMO5VMswgfsPjBmXZgy+GNeAQQ=; b=Uac2kRqhOKke8SqCGs23XgqFH75mvrOKrHa9SAAZtTTtjGH0SpRxu4a+D2UVeoXDY1 shL5M8Y7A2tDy2C49+SpomScTv+wYhR9XbTV3aSLNTa6v/oBjp8ICSnhPUI0GFtP8VNk N0kAAp9mumFfH5OkIrrV5KY5aZppWi5OynwwJZWRuwZ/XOnKUxDMreP6b9f19AvyRgL7 feeLGhGqkhSmEettmj1iqb3n95vGFgFfGSsXQ4zrQo+4ilyK3X0EN+ghXkd4+8drRTzN /zk8jWSXLs2o/OMhtb3Sd1b1C7os0V36fQs1uMryogyRvedRal1lbWCMAapWjpe3OSc8 pfvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UezT40KMIcX23ehphtMO5VMswgfsPjBmXZgy+GNeAQQ=; b=Fv1Q+73UH79qCkq6k49q55doazocgN7x7XNuTnbhIxMqIDisTGn3VA/gbi5d0TvX+a t7XiTNr6S+nCG/iRkgsiSEISoAqR13NzX7F94Wv4ibMFlxJoNlCSKglkBOGZrvY6oRq5 sczVzLe8wr6QD3KmJ7QfSy6Xq0lcMqGPkndX6HosyFQdQ7ZJn8zpBv0GQAOlmJOA9yM5 nuV17aQwc64FjnvdvnrbQbFjVxGgmcOhPIuyBnSK6u9UwdI3sg86QeQXJjOyNnou1+a1 bHExafMaDu24jtIRoVJ+LmFRtLHBDE8SmZkgbuDfdKyyiw77EuzwrbnrJrpHXq0uUvDl odxA== X-Gm-Message-State: AOAM530/gUCxBxPwJjruQxYLxcuIySGzRjkydsgypHiEn4m1s7JVuvui tZR7p4MzCshi+vII+HDvvvPPGro8KC7JlA== X-Google-Smtp-Source: ABdhPJyNAlXnugR6vQmk4i2UvIuJxUANogGDwk4MZLFOt5r33NPxbn8d7oim/VBF78uWzZPz+TPUPQ== X-Received: by 2002:a05:600c:3b26:: with SMTP id m38mr4135911wms.155.1631115122859; Wed, 08 Sep 2021 08:32:02 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id j17sm2385580wrh.67.2021.09.08.08.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 08:32:02 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 2/5] http: correct curl version check for CURLOPT_PINNEDPUBLICKEY Date: Wed, 8 Sep 2021 17:31:53 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.825.g2bf60429931 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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. Let's also remove the macro check before we declare the ssl_pinnedkey variable, the pattern for other such variables is to declare the static variable unconditionally, we just may not use it on older versions. This reduces macro verbosity. The reduction in verbosity comes at the small cost of issuing a warning about the unused variable if this code is compiled with curl versions older than 7.39.0. I think that's an acceptable trade-off, anyone compiling a new git with a 2014-era toolchain likely has at least other warning that'll have prompted them not to use -Werror, and if not maybe this'll prompt them to compile their new git with a more modern libcurl. Signed-off-by: Ævar Arnfjörð Bjarmason --- http.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/http.c b/http.c index 56856178bfe..f7d5b6a0776 100644 --- a/http.c +++ b/http.c @@ -59,9 +59,7 @@ static struct { 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,10 +371,10 @@ static int http_options(const char *var, const char *value, void *cb) } if (!strcmp("http.pinnedpubkey", var)) { -#if LIBCURL_VERSION_NUM >= 0x072c00 +#if LIBCURL_VERSION_NUM >= 0x072700 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 } @@ -845,7 +843,7 @@ 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 +#if LIBCURL_VERSION_NUM >= 0x072700 if (ssl_pinnedkey != NULL) curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey); #endif From patchwork Wed Sep 8 15: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: 12481367 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.7 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 2DB4EC433EF for ; Wed, 8 Sep 2021 15:32:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1140B610E9 for ; Wed, 8 Sep 2021 15:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352093AbhIHPdg (ORCPT ); Wed, 8 Sep 2021 11:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350469AbhIHPdN (ORCPT ); Wed, 8 Sep 2021 11:33:13 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FF9BC061575 for ; Wed, 8 Sep 2021 08:32:05 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id i3so2058713wmq.3 for ; Wed, 08 Sep 2021 08:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DyRocttpxy0z4l65WwiDwVEAYaVpNSCjQ3aziwmlWFM=; b=NnY1m62zJUE39d833fyhKopz4wQD+Bv9p1XZDjFSAqbNMnSrRCickWAFwHgzryGYu1 JNSY2zsSbR0BEYryow2CRx5VIYC7QPcfLBPyKp8JKL2LK3lzmgGtmaUkxlMjFM0yjum9 GJquMyQjp1AXQKv+EsLIT6uZlvV1i5XPWR1WamSUeBenaJ8tqpA7Vb75+u1OhatrO6BA c6imUAGFudzb2f3NmQ9WOuVEDu1ylHrbkLDRooN7eg20MMQnX34hqXTdaYIRjgNABvao SGyXLdpfmnGM8qH0LAOATy7cfIacujKcjHDRc8sCfGgDtj/lCkcD2cBUiiqLxAOhcDyH MHGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DyRocttpxy0z4l65WwiDwVEAYaVpNSCjQ3aziwmlWFM=; b=QI4VQTgf/xq3fSTJgeYHNW0z7TQIj+cBZezHQV7Ukx3HAsf1TzC0Z5N9DRv1SjwhmW tQrTJzCXSfNiV7KOXdXkUGRWAwR4K7nBtMPqBFHHGCwOksioACA4hqI48/tlwrYT4exa ssORqMwjRqIxuQ5ND+mMQ4QVaatWWWn690HGRjzRWk1ISA+7CFR84HBtgTtJG3fxBVDL 48QRg5g3UV9qLrZwJNWmWAPGrAHVjCe7BxredlZwPtV/l2Y/tHJiRXsBxlS6IxCWHAs4 53OccanoWdLZAWrOSZ3WF01Umld6xNmjZldT97RLm83/rt0/Viic08Z8F2oHsLh+U7aw pDcA== X-Gm-Message-State: AOAM531pQo8ewXvNwBzHqTfBmqMjA5rJ1MhyJV3/XwgXVPeUyOUmrBQX Re9p+/RkC1LVm/lFC80RtiVlYiTu3YIKNg== X-Google-Smtp-Source: ABdhPJy0liTJUwUFCmvztcopFv6qDrV9IFvJc0g764htDnuSaqMTBwsvXT3tSbEwQTZOorCsE+d19Q== X-Received: by 2002:a1c:c903:: with SMTP id f3mr4339716wmb.101.1631115123666; Wed, 08 Sep 2021 08:32:03 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id j17sm2385580wrh.67.2021.09.08.08.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 08:32:03 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 3/5] http: correct version check for CURL_HTTP_VERSION_2_0 Date: Wed, 8 Sep 2021 17:31:54 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.825.g2bf60429931 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In d73019feb44 (http: add support selecting http version, 2018-11-08) a dependency was added on CURL_HTTP_VERSION_2_0, but this feature was introduced in curl version 7.43.0, not 7.47.0, as the incorrect version check led us to believe. As looking through the history of that commit on the mailing list will reveal[1], the reason for this is that an earlier version of it depended on CURL_HTTP_VERSION_2TLS, which was introduced in libcurl 7.47.0. But the version that made it in in d73019feb44 had dropped the dependency on CURL_HTTP_VERSION_2TLS, but the corresponding version check was not corrected. 1. https://lore.kernel.org/git/pull.69.git.gitgitgadget@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http.c b/http.c index f7d5b6a0776..b19d0a697d8 100644 --- a/http.c +++ b/http.c @@ -730,7 +730,7 @@ static long get_curl_allowed_protocols(int from_user) return allowed_protocols; } -#if LIBCURL_VERSION_NUM >=0x072f00 +#if LIBCURL_VERSION_NUM >=0x072b00 static int get_curl_http_version_opt(const char *version_string, long *opt) { int i; @@ -772,7 +772,7 @@ static CURL *get_curl_handle(void) curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2); } -#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0 +#if LIBCURL_VERSION_NUM >= 0x072b00 if (curl_http_version) { long opt; if (!get_curl_http_version_opt(curl_http_version, &opt)) { From patchwork Wed Sep 8 15: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: 12481369 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.7 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 35D88C433FE for ; Wed, 8 Sep 2021 15:32:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FC1D610E9 for ; Wed, 8 Sep 2021 15:32:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352143AbhIHPdi (ORCPT ); Wed, 8 Sep 2021 11:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350684AbhIHPdO (ORCPT ); Wed, 8 Sep 2021 11:33:14 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C787C061757 for ; Wed, 8 Sep 2021 08:32:06 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id y132so2083354wmc.1 for ; Wed, 08 Sep 2021 08:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FAd5ckzY9krZmSYkRFxCbpY31OIlz77VP7GsMUu5860=; b=X7yCv72138ZzM3pHhCdIVPqaZwyK8HGClMyUgF8iVZNlbJHjvrnZ5Q1UUMJIGs+NTE FC4NZx/NiihTAngteqN9d6Hu/ZW4ruMer9xGw5AZyxXAe/Yo1wfTxV9VWJhdkQSig3Sa VwxbQLe9IJbGPSGxPgiRzFk8Nc6EwAdujuWOKiDUHgDgTsX8VGe0c9YkS1ouTadl34BA 90T8V15wYSfvm9tQp8RtK6IiUEUMVuBp/CzrsOcU61cTMGWB5YdtFCuh4URe1l7w1/F7 KcfBymWiGbGxZTBstqT/YYpDFwNYW0w6/0dE6CaU5mDNDoA8AhA/kAmkcWZzliONJcER v42A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FAd5ckzY9krZmSYkRFxCbpY31OIlz77VP7GsMUu5860=; b=6GrlVWrtzZOF14cPEi1CZNE2ANmCKKfg1oSkl0QYw7xFj/S5rmB5bcOT2nQQAYBVLB FhEvcw73dr1s2AtInQxFOCBshegWDEe/JxByrhjIQlp0fOJSE1oWn2N/NQVxh4MxCjZ5 J81aldL2FUyZYK28r6eXDZYP5WPg1LURLqhJJHtGsWsg/1kBS4vZOjAxWalle2CpHOzN PrU5IkpXl2ql8knM8PJB1t2kWe79lHNVOCY3ya8zz+EOqTWuY8rkDatkSqiT9RcfKsjK JgW3Rn+4JvNI43W201Cx6RvfmBkWrNUFGS2gN2xEmfm6fEtpboebiq5y1QtkSeXIYogQ W26A== X-Gm-Message-State: AOAM5331n5MjjSZ47/pTNmoK1APidyqBnk3No/aQn888qpG8gDF0smgG WkyeWLcNhyBCMmQQyA3ayNtc7XIboSSerw== X-Google-Smtp-Source: ABdhPJxreuUDgr+cC2C6RdcQQ9VotyY73sPeqqndhWc7S2eLN+ayekTkPpNZpBqDyxdqhZGKh7oRQg== X-Received: by 2002:a05:600c:4848:: with SMTP id j8mr4323883wmo.13.1631115124605; Wed, 08 Sep 2021 08:32:04 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id j17sm2385580wrh.67.2021.09.08.08.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 08:32:04 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 4/5] http: centralize the accounting of libcurl dependencies Date: Wed, 8 Sep 2021 17:31:55 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.825.g2bf60429931 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As discussed in 644de29e220 (http: drop support for curl < 7.19.4, 2021-07-30) 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 as shown in the preceding commit doing these version checks makes for hard to read and possibly buggy code, as shown by the bug fixed there where we were conflating base 10 for base 16 when comparing the version. Let's instead add a new git-curl-compat.h header that'll keep track of these dependencies. Following this pattern will also make it much easier to track when we should deprecate curl versions in the future, as we just did post-v2.33 e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24). Signed-off-by: Ævar Arnfjörð Bjarmason --- git-curl-compat.h | 112 ++++++++++++++++++++++++++++++++++++++++++++++ http.c | 31 +++++++------ imap-send.c | 2 +- 3 files changed, 128 insertions(+), 17 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..2bba7adefa6 --- /dev/null +++ b/git-curl-compat.h @@ -0,0 +1,112 @@ +#ifndef GIT_CURL_COMPAT_H +#define GIT_CURL_COMPAT_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 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, in the official version of cURL library. + */ + +/** + * 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 b19d0a697d8..e38fcc34d64 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,12 +48,12 @@ 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 }; @@ -371,12 +372,10 @@ static int http_options(const char *var, const char *value, void *cb) } if (!strcmp("http.pinnedpubkey", var)) { -#if LIBCURL_VERSION_NUM >= 0x072700 - return git_config_pathname(&ssl_pinnedkey, var, value); -#else +#ifndef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY warning(_("Public key pinning not supported with cURL < 7.39.0")); - return 0; #endif + return git_config_pathname(&ssl_pinnedkey, var, value); } if (!strcmp("http.extraheader", var)) { @@ -498,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) @@ -514,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); @@ -730,7 +729,7 @@ static long get_curl_allowed_protocols(int from_user) return allowed_protocols; } -#if LIBCURL_VERSION_NUM >=0x072b00 +#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2 static int get_curl_http_version_opt(const char *version_string, long *opt) { int i; @@ -772,7 +771,7 @@ static CURL *get_curl_handle(void) curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2); } -#if LIBCURL_VERSION_NUM >= 0x072b00 +#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2 if (curl_http_version) { long opt; if (!get_curl_http_version_opt(curl_http_version, &opt)) { @@ -803,7 +802,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")); @@ -843,20 +842,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 >= 0x072700 +#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 @@ -937,7 +936,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); @@ -1002,7 +1001,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..e6090a0346a 100644 --- a/imap-send.c +++ b/imap-send.c @@ -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; From patchwork Wed Sep 8 15: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: 12481371 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.7 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 B3D0DC433EF for ; Wed, 8 Sep 2021 15:32:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D7C8610C9 for ; Wed, 8 Sep 2021 15:32:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352111AbhIHPdi (ORCPT ); Wed, 8 Sep 2021 11:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352043AbhIHPdP (ORCPT ); Wed, 8 Sep 2021 11:33:15 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59DDBC06175F for ; Wed, 8 Sep 2021 08:32:07 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id k5-20020a05600c1c8500b002f76c42214bso1942521wms.3 for ; Wed, 08 Sep 2021 08:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uIH2ECZ28g/q3GopK7kpY3M8T4ZDJ2P0X0g1dFXaPC0=; b=mC4LnGgEJ0C7fR3cSFm4cvLEZxmgwI63ZTS53twrAiHyLrzjlVAelXz+i8j8BChr5b fy0DuQFDHxTACSl0Gy+xvyntGqvLwF9rP0r0kXMzctIFBbSF0NxJITYuG+tNSmVabccH TVLB05kIcbp1S2jBZHYScW23bOVRTWV6ActrZYZhzWt+VkI4eT1DVHAMTPsR7hQhgfVP JjdbVLhYgi6bQT8XSW0HYTeCwQCzmgEtK2O4fnc/PlQTkDPur9c9Mly7JFcK5vtdwMY9 Ekoo18/aEG3S6MgnWLqDLhBYlyeTndGksNdiq/utPDzUzmhvAQ3jSTJoVdAu6ZoiEdyx u1+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uIH2ECZ28g/q3GopK7kpY3M8T4ZDJ2P0X0g1dFXaPC0=; b=4B3b8TfvZZmUU1/r4HpP1NhGIdDFCFvIKmYBq0aOJ1oxcPmgzGkCYKTKJo5D1i49Qk GPfVV9gncBh2JwRyQaT7F2trECWLoI43QAzN+wWMRZIHwyl3+AlYjc4CvnFjgJ7v1x+c UmQABCVIlNsfnreACsZqqRbIZeJdCVal6SNytWUSmmhBumqv7X8TTMcRSZhKJfZgUdgm o6DxzAc/zRJNEmXol+gDSAghknJ8UTAVc4ZtkERQIedd/W9jwqMUY7FKzY4CRqrtkGgw lVBYQCU2fBMSt98Q/HaDwU/aBcYS9FWbnvDib6lwV3gAqGPpUpD/hnSVf8vrmUhDO1bO eozA== X-Gm-Message-State: AOAM530FFRxHnN1le3kE30+EhjVsYqLDqgq0zm31rkyGISOTxWC4iV2v lGB3LoJEIn2j/cCYLxxdU/92FwB4TJEYbg== X-Google-Smtp-Source: ABdhPJwfHMwlbVn7uhKqqZN9LOrmHfpOLKFvvnlEHOuX2nyABpfKVwtqa7k514jdQqfUSg8EWbETiw== X-Received: by 2002:a05:600c:2114:: with SMTP id u20mr4268783wml.65.1631115125693; Wed, 08 Sep 2021 08:32:05 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id j17sm2385580wrh.67.2021.09.08.08.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 08:32:04 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Bagas Sanjaya , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 5/5] http: don't hardcode the value of CURL_SOCKOPT_OK Date: Wed, 8 Sep 2021 17:31:56 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.825.g2bf60429931 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Use the new git-curl-compat.h header to define CURL_SOCKOPT_OK to its known value if we're on an older curl version that doesn't have it. It was hardcoded in http.c in a15d069a198 (http: enable keepalive on TCP sockets, 2013-10-12). Signed-off-by: Ævar Arnfjörð Bjarmason --- git-curl-compat.h | 11 +++++++++++ http.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/git-curl-compat.h b/git-curl-compat.h index 2bba7adefa6..bfa85711511 100644 --- a/git-curl-compat.h +++ b/git-curl-compat.h @@ -17,6 +17,10 @@ * 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 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. + * * We avoid comparisons against LIBCURL_VERSION_NUM, enterprise * distros have been known to backport symbols to their older curl * versions. @@ -25,6 +29,13 @@ * introduced, oldest first, in the official version of cURL library. */ +/** + * CURL_SOCKOPT_OK was added in 7.21.5, released in April 2011. + */ +#ifndef CURL_SOCKOPT_OK +#define CURL_SOCKOPT_OK 0 +#endif + /** * CURLOPT_TCP_KEEPALIVE was added in 7.25.0, released in March 2012. */ diff --git a/http.c b/http.c index e38fcc34d64..c40439d39ce 100644 --- a/http.c +++ b/http.c @@ -533,7 +533,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)