From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 6C72F1FA12 for ; Wed, 21 Jul 2021 22:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230086AbhGUVlw (ORCPT ); Wed, 21 Jul 2021 17:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbhGUVlt (ORCPT ); Wed, 21 Jul 2021 17:41:49 -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 C1724C0613C1 for ; Wed, 21 Jul 2021 15:22:24 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id f17so3754121wrt.6 for ; Wed, 21 Jul 2021 15:22:24 -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=TACC9ysPC52bUkj1hBVK/5G6tthYhpggI0bp4Px3x+M=; b=rhmYTDvFpO0XSn6NAN2EMY6gKMqPvw7+hp5aC38sZTzEu4Tow1z/Mpih+1adiFWHp+ 2TfBKjiJX8oOXDfmFRDNtLKMSCC4491ZMtRqKKe9GdD6wDu9lT/NoAlbNqNQKOSoDc7P I4mMEMVLuQyLt3RcsVxnYULSXWmkFqaXvSUWGhWVJn6c5idkFhG3JhMIQTMXHbsSOiji cZHDrzB+Q4S7By3VB9QE+j7NWWTXihJjZvIiIqFm8g+eBgtdBcgvveY/Ler4WsUCkZ5b Tt+yMIdaIb0MC0vkbeDc5Obssq7Cx5K9SlmDB4i8erkoZiV5N58OkzHreQQRKv6GvqgC ro/w== 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=TACC9ysPC52bUkj1hBVK/5G6tthYhpggI0bp4Px3x+M=; b=kXgx1V0IN0iBEWUChy9xUhNsDM7vjtp0V2ktLkidNvy2tKDuEFKPsmd/x8/f90JYFj mdIpsEHMZrRC6cBB64HpMuQE7wEn7tFBt76yv9vVzdZ6uCLuDED+2hNFnrlanTcK02xP qmE8DQid9Z5YAEZueXAY0DhF5PT6/xnp4JUkYvCwO70TXJzL6oW2+Wzu+i+GeqeDd1SD JNXMUb9puiSAKHMVjX8H1/prEIDtVgsEmDv4cBNVqfeZpn+UFtgCd8CfGmHP8dl/XpJG upW2sm4vYzJrMhFD20uoBIdeY/pmHAFSY/Lw6HYC/CPn1D7MfO5SCgUiBFUGmid5qaH5 6yMQ== X-Gm-Message-State: AOAM531Qolq/uNKFrV2zEj7Q/Kn1DUZViLlGU35iTddpfxtxk/PXrCY/ emn3ZlqfplXEZ91GBjeM2ktIfogM7PqJzg== X-Google-Smtp-Source: ABdhPJymvk+iLq8Kj/2r8IdJyUVPNB1eaxTxZdUwAcA/hF5R8GPHZV1KK2knwfiOK4mzQrehJ8R6Ig== X-Received: by 2002:a5d:6a05:: with SMTP id m5mr45549690wru.253.1626906143162; Wed, 21 Jul 2021 15:22:23 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id d9sm27792132wrx.76.2021.07.21.15.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 15:22:22 -0700 (PDT) From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Nicolas Morey-Chaisemartin , "Tom G . Christensen" , Mischa POSLAWSKY , Johannes Schindelin , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Subject: [PATCH v2 3/5] http: drop support for curl < 7.19.4 Date: Thu, 22 Jul 2021 00:22:14 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.874.ge7a9d58bfcf In-Reply-To: References: <20170809120024.7phdjzjv54uv5dpz@sigill.intra.peff.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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_* -- 2.32.0.874.ge7a9d58bfcf