From patchwork Thu Feb 2 09:44:12 2023 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: 13125661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76B2EC63797 for ; Thu, 2 Feb 2023 09:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232602AbjBBJpQ (ORCPT ); Thu, 2 Feb 2023 04:45:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232604AbjBBJo5 (ORCPT ); Thu, 2 Feb 2023 04:44:57 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 503CD875AB for ; Thu, 2 Feb 2023 01:44:26 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id m14so1092947wrg.13 for ; Thu, 02 Feb 2023 01:44:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WWcCaX2blm8nfgTGsiNz3wflSNtwAhgXBOFbIOfg37g=; b=Q/9qMKAF3Ih9rlH9eCZkTPjfD132SpHxlYPNuSbglrZBfsW/x+prtYj1/qNAq0Oaw7 L3S4SjlfxMJ4Gt0Z1BO/EwOSntsPx+H/8dBQhDXW0LDxSDs1LQIGjb2q5Wm3l3aix1jL DPm7BmNyE1rrW82X+VBk4UEJDcKP5zTpkt+fWDhzlY+uxnSwveIIZBi2pz2rNTv4tdgV x0qIyTtW3nM0jFO+2SCCQHdbLwHKC6mbeNEHRH2DcO+yGqo6CvNdBUzJ4gaG3eEUv3KW CCSdgTpxNeUZiG5J1u91/jvMB3FLvO/b5pneAqrGffIQJE2vQfPpYqsXkh1HSjdSZo74 vGUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WWcCaX2blm8nfgTGsiNz3wflSNtwAhgXBOFbIOfg37g=; b=ZEnnkwPejkowVGpsqADr4jW1xpBshI/a77RRslU4DATgpd0flbmApgOAGIgq7jNPqO TK7r5y401EQUEvOHRhY8jQvingqDi3WDNmVeg8cM6kV5NSOjQj4r+zA/OKOHzMTVbpFe WvbaEojZByhZRJiFJcV5dContOMNMl13WhxTy2/7frVAIOIf2FdG3etZJOPIwTJTBkkq piuDDihi5tZBRoNThAJq9+ggvlyvPp7mICghNxqXevDj6YVOgfM3mZElCoaHMpNsUstp fXLokIAwQacHDpQ1vTsU+GYK2thDXS0Uo63agnbC6KinZwBwAHG7tJb++YseZeszO9FH d3oQ== X-Gm-Message-State: AO0yUKWnsd4U/R+Oexv57m060FbX66YSG8GnvP+d0j0ATTiQ4tQ8WfCT VKqfxd8MINF0WM22a+HG54KHGBio9hdt171x X-Google-Smtp-Source: AK7set+/41GJ5KcQzaTcjlYqBtzKXbyAXesB/94dKxaThl5TTSC+EZlafltId+9U2q4OoY5aEdXscw== X-Received: by 2002:a05:6000:10c3:b0:2bf:b113:8ae2 with SMTP id b3-20020a05600010c300b002bfb1138ae2mr5222497wrx.15.1675331063978; Thu, 02 Feb 2023 01:44:23 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b14-20020a05600010ce00b0029e1aa67fd2sm19487938wrx.115.2023.02.02.01.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:44:23 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Bernhard Reiter , Remi Pommarel , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 1/6] imap-send: note "auth_method", not "host" on auth method failure Date: Thu, 2 Feb 2023 10:44:12 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix error reporting added in ae9c606ed22 (imap-send: support CRAM-MD5 authentication, 2010-02-15), the use of "srvc->host" here was seemingly copy/pasted from other uses added in the same commit. But here we're complaining about the "auth_method" being incorrect, so let's note it, and not the hostname. In a subsequent commit we'll alter other uses of "host" here after getting rid of the non-tunnel OpenSSL codepath. This preparatory fix makes that subsequent change smaller. Signed-off-by: Ævar Arnfjörð Bjarmason --- imap-send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imap-send.c b/imap-send.c index a50af56b827..b7902babd4c 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1121,7 +1121,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const c goto bail; } } else { - fprintf(stderr, "Unknown authentication method:%s\n", srvc->host); + fprintf(stderr, "Unknown authentication method:%s\n", srvc->auth_method); goto bail; } } else { From patchwork Thu Feb 2 09:44:13 2023 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: 13125663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C82AAC636D4 for ; Thu, 2 Feb 2023 09:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232234AbjBBJpU (ORCPT ); Thu, 2 Feb 2023 04:45:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232620AbjBBJpB (ORCPT ); Thu, 2 Feb 2023 04:45:01 -0500 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 02639659D for ; Thu, 2 Feb 2023 01:44:32 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id h16so1099824wrz.12 for ; Thu, 02 Feb 2023 01:44:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TWiYexL7LMeUZ3YiAnb4rCGHnEv0h+K9CVMnd7y+q/o=; b=QVVBD2rE1LE0GE5iyY+oCyUQvTJWNzO5Cscd1bq+ZOhSmIJ8DCUs+rZ/5SGQ+ljpok Xdbw76jBPvuAG7dgXSevOo+5at68+jIxOWPfGN3taxR+b7z5coLQL60B0gSBfmtDbwC6 TFZyhdYeFX/NbBy1Ei1u4doRIaUqbUYwcs3VOAJOl1KfeR1kek9+ohn2dHX2evoJc7Go 9XRpJJYZMkPHCD63WNN4wGheom2X56L5bI1hg6CTZeTYAqrtElBtF+0uXC2NwSOaFGN7 nMzzyXJhh6d39+Rt26GTCOp/SNnIPuOJgEVk6I6OHrFFfLnJaVfT9t66oJ9sY8G2VAAE y5Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TWiYexL7LMeUZ3YiAnb4rCGHnEv0h+K9CVMnd7y+q/o=; b=Rh1vihWzlpnICx+D5+hjWXGkNt45bPA8yH8YMdfmPpERrTNLMPTcWazmbE7CtGvmCy 3X7UPUd+CnIJqZ9YAwxsyofkVV1AmPXpP7l0cevppVA+Rdb9GSV3gKVFHNBJ6IYXzNgj IDJF3WlQJ8ZEBrmP6nj1Qj5pFJHcr0yj7wXZGWezyKGZ8UC+6YoTQdtmFrMCq/0TjTYr HUaA/rq53sFw2XkpA2M3/SqjYSjnuvWKzRfnKm0kscRd5oLcOi/O33ZpmFv7DxUnafUp 6oiak5NhiRU++X66M3rjRgFFdTS0wK4gVHpsRwLe0X9/2CM+Ehvpy4i5Wq81nKd2F+mA iAeA== X-Gm-Message-State: AO0yUKV5P3iCsFJOjZX8NuYNd22N7aWKedlV4m/nVg7Hiz7PSPMHZ4G5 u9CxKFEPcScRjLO0FuVCCRany7Lria0tuker X-Google-Smtp-Source: AK7set8e/Zoo/kU6r1sfJ9GpkOCz9a4bNyFogazAOGCcyEHJXkA2Qp02nbXnYabs4xnEKoFTvv/6WQ== X-Received: by 2002:adf:fe86:0:b0:2bf:f6b7:7a63 with SMTP id l6-20020adffe86000000b002bff6b77a63mr5883411wrr.0.1675331065071; Thu, 02 Feb 2023 01:44:25 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b14-20020a05600010ce00b0029e1aa67fd2sm19487938wrx.115.2023.02.02.01.44.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:44:24 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Bernhard Reiter , Remi Pommarel , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 2/6] imap-send doc: the imap.sslVerify is used with imap.tunnel Date: Thu, 2 Feb 2023 10:44:13 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This documentation added in [1] claims that imap.{host,port,sslVerify} is ignored if imap.tunnel is set. That's correct in the first two cases, but not for imap.sslVerify. When we're using the tunnel feature we'll call ssl_socket_connect() with a 3rd "verify" argument set to the value of the "imap.sslVerify" config if we're on the !preauth path. There is also a call to ssl_socket_connect() that's specific to the non-tunnel codepath. Perhaps the documentation added in [1] was written for an earlier version of [2] (which was introduced in the same series). There is an earlier version of the patch on-list[3] where there's still a "FIXME" comment indicating that we should read the config in the future before setting "SSL_VERIFY_PEER", which is what we'll do if "imap.sslVerify" is set. 1. c82b0748e53 (Documentation: Improve documentation for git-imap-send(1), 2008-07-09) 2. 684ec6c63cd (git-imap-send: Support SSL, 2008-07-09) 3. https://lore.kernel.org/git/1096648c0806010829n71de92dcmc19ddb87da19931d@mail.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/config/imap.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/config/imap.txt b/Documentation/config/imap.txt index 06166fb5c04..96b1c0927d8 100644 --- a/Documentation/config/imap.txt +++ b/Documentation/config/imap.txt @@ -26,8 +26,7 @@ imap.port:: imap.sslverify:: A boolean to enable/disable verification of the server certificate - used by the SSL/TLS connection. Default is `true`. Ignored when - imap.tunnel is set. + used by the SSL/TLS connection. imap.preformattedHTML:: A boolean to enable/disable the use of html encoding when sending From patchwork Thu Feb 2 09:44:14 2023 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: 13125664 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B363FC05027 for ; Thu, 2 Feb 2023 09:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232662AbjBBJpW (ORCPT ); Thu, 2 Feb 2023 04:45:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbjBBJpP (ORCPT ); Thu, 2 Feb 2023 04:45:15 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 423AB6B022 for ; Thu, 2 Feb 2023 01:44:35 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id h12so1106099wrv.10 for ; Thu, 02 Feb 2023 01:44:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8La0wN/xIHK2Ufbt/xjrR/pRqVsyLn9u6RPoOlzSo3A=; b=czFHbZUlaLbxmPUp5dfYAgWk7SubycRUXMuxzydFcTPXqO5xEpmxQmKCMe9rSVwb8X aSjqzQE/UNDVINOVhlRl5YZPFVzyEm3g4xcMQhNbnoNgdfo6TpeTKMXJnQxWcLAgK4iD 3k96zJbf+ymffldqdsI/JGL+Ac1Z7LX4MjD3nKyQHMSeVGHUth6WS0T8aUFtsicSJ4kf Yjy4kFq0DWFWv9wNlT6U17ydeTjt3E1nOYnY1+dkUAYcHf1sgYQ40fKh9aT3+vss8oPL 8DF+cJReYwPv7+KzN3iptH8a4A5XV76KDdp9IkJE5ZF+y0gHOVXhjRq4AIkMO07aMo6y Jofw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8La0wN/xIHK2Ufbt/xjrR/pRqVsyLn9u6RPoOlzSo3A=; b=BliWhRy9+lwDqRMd8xqajYHVa9bBYnRYylz7yeqO1fevXsyZRg1BIWSYxVUKy4345p cq7n01k0GKjZW7xt0FyS/n7DkOGDRW1pG47oszLVDkVSQer4F9P2BmqEGVOpYH6wXRbh gL7Ly+jpdOfG4jX544u8NTboevu/X9USg3Pl3TUZmlc/eR15W5dZ6Co8mPJ10tXxLJ6F ciciopPEP+p93lK3KVjZ7xLoJiidxBuOSbEohF5t2z49fRSSFzhXMIStWml5kX3oSttb dEQKDTpkYgC3rH4kalKRJOCCDDHRtJYw0yrVV9FRFvadHLAQxUjNwyhG8xeATi1eOtQw 1jwg== X-Gm-Message-State: AO0yUKUx9ctYxw0LFO75RrkjNBSYeSKUQwjo6dGEI8LJleUS/SJMHZPZ PwpcQ//ZyoAxIc0P05ItdKaX4ct5EI1M113U X-Google-Smtp-Source: AK7set/PEH1TD9IBxtgj1Y3Nrcy7MfODeB+8ZNaNFAVztriR7kMvSm7ty35Xmxm61/kgcS3KCsN0RQ== X-Received: by 2002:a05:6000:182:b0:2c3:57c5:d17d with SMTP id p2-20020a056000018200b002c357c5d17dmr4798808wrx.49.1675331066078; Thu, 02 Feb 2023 01:44:26 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b14-20020a05600010ce00b0029e1aa67fd2sm19487938wrx.115.2023.02.02.01.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:44:25 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Bernhard Reiter , Remi Pommarel , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 3/6] imap-send: replace auto-probe libcurl with hard dependency Date: Thu, 2 Feb 2023 10:44:14 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the "imap-send" command to have a hard dependency on libcurl, before this it had an optional dependency on both libcurl and OpenSSL, now only the OpenSSL dependency is optional. This simplifies our dependency matrix by getting rid of yet another special-case. Given the prevalence of libcurl and portability of libcurl it seems reasonable to say that "git imap-send" cannot be used without libcurl, almost everyone building git needs to be able to push or pull over http(s), so they'll be building with libcurl already. So let's remove the previous "USE_CURL_FOR_IMAP_SEND" knob. Whether we build git-imap-send or not is now controlled by the "NO_CURL" knob. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/config/imap.txt | 3 +-- Documentation/git-imap-send.txt | 3 +-- INSTALL | 8 ++++---- Makefile | 18 +++++------------- imap-send.c | 23 ++--------------------- 5 files changed, 13 insertions(+), 42 deletions(-) diff --git a/Documentation/config/imap.txt b/Documentation/config/imap.txt index 96b1c0927d8..7f30080c409 100644 --- a/Documentation/config/imap.txt +++ b/Documentation/config/imap.txt @@ -37,7 +37,6 @@ imap.preformattedHTML:: imap.authMethod:: Specify authenticate method for authentication with IMAP server. - If Git was built with the NO_CURL option, or if your curl version is older - than 7.34.0, or if you're running git-imap-send with the `--no-curl` + If you're running git-imap-send with the `--no-curl` option, the only supported method is 'CRAM-MD5'. If this is not set then 'git imap-send' uses the basic IMAP plaintext LOGIN command. diff --git a/Documentation/git-imap-send.txt b/Documentation/git-imap-send.txt index f7b18515141..202e3e59094 100644 --- a/Documentation/git-imap-send.txt +++ b/Documentation/git-imap-send.txt @@ -44,8 +44,7 @@ OPTIONS --no-curl:: Talk to the IMAP server using git's own IMAP routines instead of - using libcurl. Ignored if Git was built with the NO_OPENSSL option - set. + using libcurl. CONFIGURATION diff --git a/INSTALL b/INSTALL index d5694f8c470..d9538bbcb45 100644 --- a/INSTALL +++ b/INSTALL @@ -129,13 +129,13 @@ Issues of note: itself, e.g. Digest::MD5, File::Spec, File::Temp, Net::Domain, Net::SMTP, and Time::HiRes. - - git-imap-send needs the OpenSSL library to talk IMAP over SSL if - you are using libcurl older than 7.34.0. Otherwise you can use - NO_OPENSSL without losing git-imap-send. + - git-imap-send needs libcurl 7.34.0 or newer, in addition + OpenSSL is needed if using the "imap.tunnel" open to tunnel + over SSL. Define NO_OPENSSL to omit the OpenSSL prerequisite. - "libcurl" library is used for fetching and pushing repositories over http:// or https://, as well as by - git-imap-send if the curl version is >= 7.34.0. If you do + git-imap-send. If you do not need that functionality, use NO_CURL to build without it. diff --git a/Makefile b/Makefile index 45bd6ac9c3e..b08a855198c 100644 --- a/Makefile +++ b/Makefile @@ -773,7 +773,9 @@ PROGRAMS += $(EXTRA_PROGRAMS) PROGRAM_OBJS += daemon.o PROGRAM_OBJS += http-backend.o +ifndef NO_CURL PROGRAM_OBJS += imap-send.o +endif PROGRAM_OBJS += sh-i18n--envsubst.o PROGRAM_OBJS += shell.o .PHONY: program-objs @@ -1583,7 +1585,6 @@ ifdef HAVE_ALLOCA_H BASIC_CFLAGS += -DHAVE_ALLOCA_H endif -IMAP_SEND_BUILDDEPS = IMAP_SEND_LDFLAGS = ifdef NO_CURL @@ -1592,6 +1593,7 @@ ifdef NO_CURL REMOTE_CURL_ALIASES = REMOTE_CURL_NAMES = EXCLUDED_PROGRAMS += git-http-fetch git-http-push + EXCLUDED_PROGRAMS += git-imap-send else ifdef CURLDIR # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case. @@ -1617,19 +1619,9 @@ else REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES) PROGRAM_OBJS += http-fetch.o PROGRAMS += $(REMOTE_CURL_NAMES) + IMAP_SEND_LDFLAGS += $(CURL_LIBCURL) ifndef NO_EXPAT PROGRAM_OBJS += http-push.o - endif - curl_check := $(shell (echo 072200; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p) - ifeq "$(curl_check)" "072200" - USE_CURL_FOR_IMAP_SEND = YesPlease - endif - ifdef USE_CURL_FOR_IMAP_SEND - BASIC_CFLAGS += -DUSE_CURL_FOR_IMAP_SEND - IMAP_SEND_BUILDDEPS = http.o - IMAP_SEND_LDFLAGS += $(CURL_LIBCURL) - endif - ifndef NO_EXPAT ifdef EXPATDIR BASIC_CFLAGS += -I$(EXPATDIR)/include EXPAT_LIBEXPAT = -L$(EXPATDIR)/$(lib) $(CC_LD_DYNPATH)$(EXPATDIR)/$(lib) -lexpat @@ -2786,7 +2778,7 @@ endif git-%$X: %.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) -git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS) +git-imap-send$X: imap-send.o http.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(IMAP_SEND_LDFLAGS) $(LIBS) diff --git a/imap-send.c b/imap-send.c index b7902babd4c..26f8f01e97a 100644 --- a/imap-send.c +++ b/imap-send.c @@ -30,20 +30,10 @@ #if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG) typedef void *SSL; #endif -#ifdef USE_CURL_FOR_IMAP_SEND #include "http.h" -#endif - -#if defined(USE_CURL_FOR_IMAP_SEND) -/* Always default to curl if it's available. */ -#define USE_CURL_DEFAULT 1 -#else -/* We don't have curl, so continue to use the historical implementation */ -#define USE_CURL_DEFAULT 0 -#endif static int verbosity; -static int use_curl = USE_CURL_DEFAULT; +static int use_curl = 1; static const char * const imap_send_usage[] = { "git imap-send [-v] [-q] [--[no-]curl] < ", NULL }; @@ -1396,7 +1386,6 @@ static int append_msgs_to_imap(struct imap_server_conf *server, return 0; } -#ifdef USE_CURL_FOR_IMAP_SEND static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred) { CURL *curl; @@ -1515,7 +1504,6 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server, return res != CURLE_OK; } -#endif int cmd_main(int argc, const char **argv) { @@ -1531,12 +1519,7 @@ int cmd_main(int argc, const char **argv) if (argc) usage_with_options(imap_send_usage, imap_send_options); -#ifndef USE_CURL_FOR_IMAP_SEND - if (use_curl) { - warning("--curl not supported in this build"); - use_curl = 0; - } -#elif defined(NO_OPENSSL) +#if defined(NO_OPENSSL) if (!use_curl) { warning("--no-curl not supported in this build"); use_curl = 1; @@ -1580,10 +1563,8 @@ int cmd_main(int argc, const char **argv) if (server.tunnel) return append_msgs_to_imap(&server, &all_msgs, total); -#ifdef USE_CURL_FOR_IMAP_SEND if (use_curl) return curl_append_msgs_to_imap(&server, &all_msgs, total); -#endif return append_msgs_to_imap(&server, &all_msgs, total); } From patchwork Thu Feb 2 09:44:15 2023 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: 13125665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4624C05027 for ; Thu, 2 Feb 2023 09:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232675AbjBBJpb (ORCPT ); Thu, 2 Feb 2023 04:45:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232542AbjBBJpP (ORCPT ); Thu, 2 Feb 2023 04:45:15 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA2A088CCF for ; Thu, 2 Feb 2023 01:44:36 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id o18so1135319wrj.3 for ; Thu, 02 Feb 2023 01:44:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ybrOW28B1qf/T6oBOxjTGvJfSqc+Ur+JsXhIiwdiLkQ=; b=IoZ3HMvkKpnHk0uTP2x+cNySxyRYY39ZWYHwh1Jiv4npPczf3W5PtZw3r/bCblYfBY 2bQMxIiyrI8xQvH5LXsdJpwM9k0EeBbQziJq05too3F7QFmlr1ADHF3g+hhllNQ2cOqe 0c6sOVB4gCKAc+fN+wVegzib7DZS5rPv0OB5G0phyRTHYRw12w8mvi8QGopLhAREz25i sGfOqVUNRSwgqitPutn/deoEWMgw9miljHMu22kHGgHN7xhSzGLVW7CaMRgNxDh7vIPO 0Ra7f4xZPrbfGG/MUDFpQI8aPsCQoHGrwEu6+CDUEUj4wT6CEzBX6v4ih2TkAQp2gmuB xKZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ybrOW28B1qf/T6oBOxjTGvJfSqc+Ur+JsXhIiwdiLkQ=; b=cpCNyJj5AmTj8D0Il2zGsDMHhXI/F0KvYxVEORKm006vLioTYFl15SZg7ZRT3IOU1y u+4cciM26Kp9zABqZCpo7oQ/RRMuEUgSKBkfk41vvy8WFSLbU+urDKqnH3GghRYmpQwU iSg5ycaAvLpk4gV54FWD2BlVGNgYssQlLbk7CisIT8Es61b32gCPmUWYFbBHz9JilRHw k2cXKocDw10+1BdceFjHfq3q8kQT2R4yVmEq8ZqoTqLC3s83pXx6cYeNjvwYyIl0PAUL JxYyx/fqy4/HWIzCnGdgLjq9GcyfLUJnKfZqW1BdHLjiqjYMQh8pi2zbVV0Gv+uoHnLq 73dw== X-Gm-Message-State: AO0yUKX04HZ0YQ4/OivdzFgF2V+M/8oIxiJ2p10fwDkRKTQdXjCzs/dd WNNu/vsDSj8MFWbIO2AY4mTCL3IFilbiHF76 X-Google-Smtp-Source: AK7set9kpl9tzm6jQ9ljgnpsNUsxCxIdi2XY0q87gI6sHlBw8GU3buiPYXXx/Tu2e6uIdDNoZVZY2w== X-Received: by 2002:adf:fccb:0:b0:2bf:ae19:d8e4 with SMTP id f11-20020adffccb000000b002bfae19d8e4mr5354221wrs.16.1675331067194; Thu, 02 Feb 2023 01:44:27 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b14-20020a05600010ce00b0029e1aa67fd2sm19487938wrx.115.2023.02.02.01.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:44:26 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Bernhard Reiter , Remi Pommarel , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 4/6] imap-send: make --curl no-optional Date: Thu, 2 Feb 2023 10:44:15 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the preceding commit the old "USE_CURL_FOR_IMAP_SEND" define became always true, as we now require libcurl for git-imap-send. But as we require OpenSSL for the "tunnel" mode we still need to keep the OpenSSL codepath around (ee [1] for an attempt to remove it). But we don't need to keep supporting "--no-curl" to bypass the curl codepath for the non-tunnel mode. As almost all users of "git" use a version of it built with libcurl we're making what's already the preferred & default codepath mandatory. The "imap.authMethod" documentation being changed here has always been incomplete. It only mentioned "--no-curl", but omitted mentioning that the same applied for "imap.tunnel". Let's fix it as we're amending it to be correct, now (as before) with "imap.tunnel" only "imap.authMethod=CRAM-MD5" is supported. 1. https://lore.kernel.org/git/ab866314-608b-eaca-b335-12cffe165526@morey-chaisemartin.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/config/imap.txt | 4 ++-- Documentation/git-imap-send.txt | 10 ---------- imap-send.c | 15 ++++----------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Documentation/config/imap.txt b/Documentation/config/imap.txt index 7f30080c409..5cc46d87216 100644 --- a/Documentation/config/imap.txt +++ b/Documentation/config/imap.txt @@ -37,6 +37,6 @@ imap.preformattedHTML:: imap.authMethod:: Specify authenticate method for authentication with IMAP server. - If you're running git-imap-send with the `--no-curl` - option, the only supported method is 'CRAM-MD5'. If this is not set + If you're using imap.tunnel, the only supported method is 'CRAM-MD5'. + If this is not set then 'git imap-send' uses the basic IMAP plaintext LOGIN command. diff --git a/Documentation/git-imap-send.txt b/Documentation/git-imap-send.txt index 202e3e59094..ddbbe819315 100644 --- a/Documentation/git-imap-send.txt +++ b/Documentation/git-imap-send.txt @@ -37,16 +37,6 @@ OPTIONS --quiet:: Be quiet. ---curl:: - Use libcurl to communicate with the IMAP server, unless tunneling - into it. Ignored if Git was built without the USE_CURL_FOR_IMAP_SEND - option set. - ---no-curl:: - Talk to the IMAP server using git's own IMAP routines instead of - using libcurl. - - CONFIGURATION ------------- diff --git a/imap-send.c b/imap-send.c index 26f8f01e97a..9d7cb22285d 100644 --- a/imap-send.c +++ b/imap-send.c @@ -39,7 +39,7 @@ static const char * const imap_send_usage[] = { "git imap-send [-v] [-q] [--[no- static struct option imap_send_options[] = { OPT__VERBOSITY(&verbosity), - OPT_BOOL(0, "curl", &use_curl, "use libcurl to communicate with the IMAP server"), + OPT_HIDDEN_BOOL(0, "curl", &use_curl, "use libcurl to communicate with the IMAP server"), OPT_END() }; @@ -1519,12 +1519,8 @@ int cmd_main(int argc, const char **argv) if (argc) usage_with_options(imap_send_usage, imap_send_options); -#if defined(NO_OPENSSL) - if (!use_curl) { - warning("--no-curl not supported in this build"); - use_curl = 1; - } -#endif + if (!use_curl) + die(_("the --no-curl option to imap-send has been deprecated")); if (!server.port) server.port = server.use_ssl ? 993 : 143; @@ -1560,10 +1556,7 @@ int cmd_main(int argc, const char **argv) /* write it to the imap server */ - if (server.tunnel) - return append_msgs_to_imap(&server, &all_msgs, total); - - if (use_curl) + if (!server.tunnel) return curl_append_msgs_to_imap(&server, &all_msgs, total); return append_msgs_to_imap(&server, &all_msgs, total); From patchwork Thu Feb 2 09:44:16 2023 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: 13125667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C52CC05027 for ; Thu, 2 Feb 2023 09:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232600AbjBBJpe (ORCPT ); Thu, 2 Feb 2023 04:45:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232592AbjBBJpQ (ORCPT ); Thu, 2 Feb 2023 04:45:16 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409D886A3 for ; Thu, 2 Feb 2023 01:44:40 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id q10so1130371wrm.4 for ; Thu, 02 Feb 2023 01:44:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xCWK+Xm9Mtj9MO/xbb4s4t9AAmgjyiKyjYIn2zcujpg=; b=qHnMHTUV1budSIWD//+gsWX5VIOrqC78ZBuOevNMCRcCVrjxR2yVJyKkxhcCdZsZmo LC2G1f4XTy7VbdkI7uYACq1ZJOjij8YU6AeXSy3pe6LTw15iqG5aZaJtF3LbP88kbyjr iRm4RZ+wLjlEMuZXEeym15JZsQOnQt0SCDnKQCNPb161k8qiEySq/QE6kBTKkRLL/skD g0DP3LObMNnsCd/6MfPvk/wWCP7jR8kdsUUwRO3jUrJ78qN6OdJfuMgAQZ5sVMpoI/gU MJZPHzqSUC0p67QRUGkl/QDK96t/DnN9Yi+xbZObkKWjDBMBrcA3rDjU88v7VT+9o87R Q7QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xCWK+Xm9Mtj9MO/xbb4s4t9AAmgjyiKyjYIn2zcujpg=; b=36x3r9G1miZRAGd2r3nhMwbrkf0q/9G4tRlyNqorretS2PW5o6X2ZOJj3wZ4rqza9a SGq8qLgvzia8YaXtKZF2efp77dse9zYPCGeJ9s4ezlR1S67CmTbShDL6x2A+loOT0ARL RRC0z5zWZ6XEsq/4b84P0nVAWl/ichenVRPmVYsUPZhC4AW6s5QizisPl3ZC7aUWGMru bz3oxXZn/RvE4tFaccf/NEAeg6sPn1bSisYukH2O1At07LNOJSy5fcUDxPHz6LqtMGCb msQYgcms93kY30X3BVHQw5VoAABzyns6dxbFPStQrCCwqKuQmKRnEKFqLZEVL9bhsc+3 7Fhg== X-Gm-Message-State: AO0yUKUlXgzk3QsSAf2CM4l1c4q9y7tfyfZcLFt926jwMZQi2SZbWpJD mQTcAXcxPW8GE/4ucNGlLzOPOiga8gvEG07u X-Google-Smtp-Source: AK7set/gC6+fpTuqb63crQMn60Jx/5P00kZxxmJGRiMn6BcgXQ2K6DuYZl6arNRyRPPcbCqYCIxboA== X-Received: by 2002:a5d:47a2:0:b0:2bf:b5bd:8f60 with SMTP id 2-20020a5d47a2000000b002bfb5bd8f60mr4384307wrb.61.1675331068127; Thu, 02 Feb 2023 01:44:28 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b14-20020a05600010ce00b0029e1aa67fd2sm19487938wrx.115.2023.02.02.01.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:44:27 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Bernhard Reiter , Remi Pommarel , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 5/6] imap-send: remove old --no-curl codepath Date: Thu, 2 Feb 2023 10:44:16 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the preceding the "--curl" codepath was made mandatory, so now we won't use the OpenSSL implementation codepaths in imap-send.c except for "imap.tunnel". So let's follow-up and delete the code on that path which was specific to the "imap.host" mode. Signed-off-by: Ævar Arnfjörð Bjarmason --- imap-send.c | 127 +++++++--------------------------------------------- 1 file changed, 16 insertions(+), 111 deletions(-) diff --git a/imap-send.c b/imap-send.c index 9d7cb22285d..9712a8d4f93 100644 --- a/imap-send.c +++ b/imap-send.c @@ -197,14 +197,7 @@ static void socket_perror(const char *func, struct imap_socket *sock, int ret) } } -#ifdef NO_OPENSSL -static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int verify) -{ - fprintf(stderr, "SSL requested but SSL support not compiled in\n"); - return -1; -} - -#else +#ifndef NO_OPENSSL static int host_matches(const char *host, const char *pattern) { @@ -253,7 +246,7 @@ static int verify_hostname(X509 *cert, const char *hostname) cname, hostname); } -static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int verify) +static int ssl_socket_connect(struct imap_socket *sock, int verify) { #if (OPENSSL_VERSION_NUMBER >= 0x10000000L) const SSL_METHOD *meth; @@ -279,8 +272,7 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve return -1; } - if (use_tls_only) - SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); + SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); if (verify) SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL); @@ -944,7 +936,8 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const c struct imap_store *ctx; struct imap *imap; char *arg, *rsp; - int s = -1, preauth; + int preauth; + struct child_process tunnel = CHILD_PROCESS_INIT; CALLOC_ARRAY(ctx, 1); @@ -953,107 +946,19 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const c imap->in_progress_append = &imap->in_progress; /* open connection to IMAP server */ + imap_info("Starting tunnel '%s'... ", srvc->tunnel); - if (srvc->tunnel) { - struct child_process tunnel = CHILD_PROCESS_INIT; - - imap_info("Starting tunnel '%s'... ", srvc->tunnel); - - strvec_push(&tunnel.args, srvc->tunnel); - tunnel.use_shell = 1; - tunnel.in = -1; - tunnel.out = -1; - if (start_command(&tunnel)) - die("cannot start proxy %s", srvc->tunnel); - - imap->buf.sock.fd[0] = tunnel.out; - imap->buf.sock.fd[1] = tunnel.in; - - imap_info("ok\n"); - } else { -#ifndef NO_IPV6 - struct addrinfo hints, *ai0, *ai; - int gai; - char portstr[6]; - - xsnprintf(portstr, sizeof(portstr), "%d", srvc->port); - - memset(&hints, 0, sizeof(hints)); - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - - imap_info("Resolving %s... ", srvc->host); - gai = getaddrinfo(srvc->host, portstr, &hints, &ai); - if (gai) { - fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(gai)); - goto bail; - } - imap_info("ok\n"); - - for (ai0 = ai; ai; ai = ai->ai_next) { - char addr[NI_MAXHOST]; - - s = socket(ai->ai_family, ai->ai_socktype, - ai->ai_protocol); - if (s < 0) - continue; + strvec_push(&tunnel.args, srvc->tunnel); + tunnel.use_shell = 1; + tunnel.in = -1; + tunnel.out = -1; + if (start_command(&tunnel)) + die("cannot start proxy %s", srvc->tunnel); - getnameinfo(ai->ai_addr, ai->ai_addrlen, addr, - sizeof(addr), NULL, 0, NI_NUMERICHOST); - imap_info("Connecting to [%s]:%s... ", addr, portstr); + imap->buf.sock.fd[0] = tunnel.out; + imap->buf.sock.fd[1] = tunnel.in; - if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0) { - close(s); - s = -1; - perror("connect"); - continue; - } - - break; - } - freeaddrinfo(ai0); -#else /* NO_IPV6 */ - struct hostent *he; - struct sockaddr_in addr; - - memset(&addr, 0, sizeof(addr)); - addr.sin_port = htons(srvc->port); - addr.sin_family = AF_INET; - - imap_info("Resolving %s... ", srvc->host); - he = gethostbyname(srvc->host); - if (!he) { - perror("gethostbyname"); - goto bail; - } - imap_info("ok\n"); - - addr.sin_addr.s_addr = *((int *) he->h_addr_list[0]); - - s = socket(PF_INET, SOCK_STREAM, 0); - - imap_info("Connecting to %s:%hu... ", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); - if (connect(s, (struct sockaddr *)&addr, sizeof(addr))) { - close(s); - s = -1; - perror("connect"); - } -#endif - if (s < 0) { - fputs("Error: unable to connect to server.\n", stderr); - goto bail; - } - - imap->buf.sock.fd[0] = s; - imap->buf.sock.fd[1] = dup(s); - - if (srvc->use_ssl && - ssl_socket_connect(&imap->buf.sock, 0, srvc->ssl_verify)) { - close(s); - goto bail; - } - imap_info("ok\n"); - } + imap_info("ok\n"); /* read the greeting string */ if (buffer_gets(&imap->buf, &rsp)) { @@ -1081,7 +986,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const c if (!srvc->use_ssl && CAP(STARTTLS)) { if (imap_exec(ctx, NULL, "STARTTLS") != RESP_OK) goto bail; - if (ssl_socket_connect(&imap->buf.sock, 1, + if (ssl_socket_connect(&imap->buf.sock, srvc->ssl_verify)) goto bail; /* capabilities may have changed, so get the new capabilities */ From patchwork Thu Feb 2 09:44:17 2023 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: 13125666 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB391C61DA4 for ; Thu, 2 Feb 2023 09:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232700AbjBBJpc (ORCPT ); Thu, 2 Feb 2023 04:45:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232584AbjBBJpP (ORCPT ); Thu, 2 Feb 2023 04:45:15 -0500 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 7398C88CF9 for ; Thu, 2 Feb 2023 01:44:40 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id a2so846165wrd.6 for ; Thu, 02 Feb 2023 01:44:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lOE+hk1BdpdFrxkt5hnQhDOoVqsysLPJSROMXBQdPyw=; b=W9WSnPRaEJjUIrxYJP2gnXRGvp+buXwoMVR2MNCGwGe6Ut7DCEfGs2lotgn0pbSU1B qEeAd1/7IJWsc+itjIy2TKkKaadsw817ErFcB5CO0R2ZM7PcAvnZPFqMqZRmjtYDJAce ifW+vVs8tG21HAdjsRFzOp7mNILjZpXA5M8hRiwCqciXdCqNEJSz3qI4b4/x0o0CPp9E oRDWDOA7quncrryJS3BMe95JZNbBHx3e2WLKwhU4NIGlwyFgdnWUy2W+KdmBvrnsNip6 dKl4cT4WbcTzF2Fr8noUb7Q8ZxNRyKOkhJNQtK9L4tPW/L/7KCKzpcOCzEhzEWQGZPu+ j+Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lOE+hk1BdpdFrxkt5hnQhDOoVqsysLPJSROMXBQdPyw=; b=3T0WPxkPpK0RCt52lwRKdEhxMcwysBJfU+tymIe4wrBCJAqxoozxaNCF5hcEkfqBhN 8QTEpIMYTYsAtWy3eO8vYC8hQhTYHYstY8jpzd4XRPxCkHy8eNcnFLgjKd7TGVaGCjIe sKBDoWIIWW+17WaFD35l1JInjeQFQdmWfkxDwhF5gNDXF4PK0n7WO34pMZSlrNJybmDA pCUbkX3sR6bSg6SH9DXtW7mXVQJ/BjHLRyjhnfHcvOKsDsYx0MOztF46jkJZS7B+mkm7 g6MsB1RFTrwmgIuH6cbB6rNlunH7G0+GLkpPdXvNm6U9/dVYJsg75VAoPaHVqmi5fSAl W7Yg== X-Gm-Message-State: AO0yUKWcDCg1D15Zc5B37oJtV7XkI6ymzMKUYdjtX0grtsBpCGxqEpYw TVhGLwY2PxdjlfPqbgjI2fJDzqG/G94NjAdf X-Google-Smtp-Source: AK7set+0yA9buz5YpQ+HN+EV0zTfFjbqu3SH+jT+OrS2j9BpbLPw3uGzgFXrz5BXvLgiKraNlGT8Qg== X-Received: by 2002:a05:6000:1c15:b0:2bf:b27f:c9b3 with SMTP id ba21-20020a0560001c1500b002bfb27fc9b3mr6005248wrb.32.1675331069130; Thu, 02 Feb 2023 01:44:29 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b14-20020a05600010ce00b0029e1aa67fd2sm19487938wrx.115.2023.02.02.01.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:44:28 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Bernhard Reiter , Remi Pommarel , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 6/6] imap-send: correctly report "host" when using "tunnel" Date: Thu, 2 Feb 2023 10:44:17 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Before [1] we'd force the "imap.host" to be set, even if the "imap.tunnel" was set, and then proceed to not use the "host" for establishing a connection, as we'd use the tunneling command. However, we'd still use the "imap.host" if it was set as the "host" field given to the credential helper, and in messages that were shared with the non-tunnel mode, until a preceding commit made these OpenSSL codepaths tunnel-only. Let's always give "host=tunnel" to the credential helper when in the "imap.tunnel" mode, and rephrase the relevant messages to indicate that we're tunneling. This changes the existing behavior, but that behavior was emergent and didn't make much sense. If we were using "imap.tunnel" the value in "imap.host" might be entirely unrelated to the host we're tunneling to. Let's not pretend to know more than we do in that case. 1. 34b5cd1fe9f (Don't force imap.host to be set when imap.tunnel is set, 2008-04-22) Signed-off-by: Ævar Arnfjörð Bjarmason --- imap-send.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/imap-send.c b/imap-send.c index 9712a8d4f93..24b30c143a7 100644 --- a/imap-send.c +++ b/imap-send.c @@ -917,7 +917,7 @@ static void server_fill_credential(struct imap_server_conf *srvc, struct credent return; cred->protocol = xstrdup(srvc->use_ssl ? "imaps" : "imap"); - cred->host = xstrdup(srvc->host); + cred->host = xstrdup(srvc->tunnel ? "tunnel" : srvc->host); cred->username = xstrdup_or_null(srvc->user); cred->password = xstrdup_or_null(srvc->pass); @@ -1004,7 +1004,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const c if (!CAP(AUTH_CRAM_MD5)) { fprintf(stderr, "You specified " "CRAM-MD5 as authentication method, " - "but %s doesn't support it.\n", srvc->host); + "but tunnel doesn't support it.\n"); goto bail; } /* CRAM-MD5 */ @@ -1021,8 +1021,8 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const c } } else { if (CAP(NOLOGIN)) { - fprintf(stderr, "Skipping account %s@%s, server forbids LOGIN\n", - srvc->user, srvc->host); + fprintf(stderr, "Skipping account %s, server forbids LOGIN\n", + srvc->user); goto bail; } if (!imap->buf.sock.ssl) @@ -1434,12 +1434,9 @@ int cmd_main(int argc, const char **argv) fprintf(stderr, "no imap store specified\n"); return 1; } - if (!server.host) { - if (!server.tunnel) { - fprintf(stderr, "no imap host specified\n"); - return 1; - } - server.host = "tunnel"; + if (!server.host && !server.tunnel) { + fprintf(stderr, "no imap host specified\n"); + return 1; } /* read the messages */