From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Jiang Xin <worldhello.net@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
Bernhard Reiter <ockham@raz.or.at>,
Remi Pommarel <repk@triplefau.lt>
Subject: Re: [PATCH v2 6/6] imap-send: correctly report "host" when using "tunnel"
Date: Sun, 05 Feb 2023 22:51:04 +0100 [thread overview]
Message-ID: <230205.86ilgf7osb.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <Y94866yd3adoC1o9@coredump.intra.peff.net>
On Sat, Feb 04 2023, Jeff King wrote:
> On Fri, Feb 03, 2023 at 10:12:27PM +0100, Ævar Arnfjörð Bjarmason wrote:
> [...]
>> I agree that "give this to the auth helper" might be useful in general,
>> but our current documentation says:
>>
>> To use the tool, `imap.folder` and either `imap.tunnel` or `imap.host` must be set
>> to appropriate values.
>>
>> And the docs for "imap.tunnel" say "Required when imap.host is not set",
>> and "imap.host" says "Ignored when imap.tunnel is set, but required
>> otherwise".
>>
>> Perhaps we should bless this as an accidental feature instead of my
>> proposed patch, but that's why I made this change. It seemed like an
>> unintentional bug that nobody intended.
>
> Yes, I agree that the scenario I'm giving is contrary to what the docs
> say. But IMHO it is worth preferring what the code does now versus what
> the docs say. The current behavior misbehaves if you configure things
> badly (accidentally mix and match imap.host and imap.tunnel). Your new
> behavior misbehaves if you have two correctly-configure imap stanzas
> (both with a host/tunnel combo). Those are both fairly unlikely
> scenarios, and the outcomes are similar (we mix up credentials), but:
>
> 1. In general, all things being equal, I'd rather trust the code as
> the status quo. People will complain if you break their working
> setup. They won't if you fix the documentation.
>
> 2. In the current behavior, if it's doing the wrong thing, your next
> step is to fix your configuration (don't mix and match imap.host
> and imap.tunnel). In your proposed behavior, there is no fix. You
> are simply not allowed to use two different imap tunnels with
> credential helpers, because the helpers don't receive enough
> context to distinguish them.
>
> And that is not even "two imap tunnels in the same config". It is
> really per user. If I have two repositories, each with
> "imap.tunnel" in their local config, they will still invoke the
> same credential helpers, and both will just see host=tunnel. The
> namespace for "host" really is global and should be unique (ideally
> across the Internet, but at the very least among the hosts that the
> user contacts).
>
> One fix would be to pass the tunnel command as the hostname. But even
> that has potential problems. Certainly you'd have to tweak it (it's a
> shell command, and hostnames have syntactic restrictions, including
> forbidding newlines). And you'd probably want to swap out protocol=imap
> for something else. But I'm not sure if helpers may complain (e.g., I
> seem to recall that the osxkeychain helper translates protocol strings
> into integer constants that the keychain API understands).
>
>> Especially as you're focusing on the case where it contrary to the docs
>> would do what you mean, but consider (same as the doc examples, but the
>> domains are changed):
>>
>> [imap]
>> folder = "INBOX.Drafts"
>> host = imap://imap.bar.com
>> user = bob
>> pass = p4ssw0rd
>>
>> [imap]
>> folder = "INBOX.Drafts"
>> tunnel = "ssh -q -C user@foo.com /usr/bin/imapd ./Maildir 2> /dev/null"
>>
>> I.e. I have a config for "bar.com" I tried earlier, but now I'm trying
>> to connect to "foo.com", because I read the docs and notice it prefers
>> "tunnel" to "host" I think it's going to ignore that "imap.host", but
>> it's going to provide the password for bar.com to foo.com if challenged.
>
> Yes, that's a rather unfortunate effect of the way we do config parsing
> (it looks to the user like stanzas, but we don't parse it that way; the
> second stanza could even be in a different file!).
>
> Though as I said above, I still think this case does not justify making
> the code change, I do think it's the most compelling argument, and would
> make sense to include in the commit message if we did want to do this.
>
>> So I think if we want to keep this it would be better to have a
>> imap.tunnel.credentialHost or something, to avoid conflating the two.
>
> Yes, there are many config schemes that would avoid this problem. If you
> are going to tie the two together, I think it would make sense to use
> real subsections based on the host-name, like:
>
> # hostname is the subsection key; it also becomes a label when
> # necessary
> [imap "example.com"]
>
> # does not even need to mention a hostname. We'll assume example.com
> # here.
> tunnel = "any-command"
>
> # assumes example.com as hostname; not needed if you are using a
> # tunnel, of course
> protocol = imaps
>
> But I would not bother going to that work myself. IMHO imap-send is
> somewhat of an abomination, and I'd actually be just as happy if it went
> away. But what you are doing seems to go totally in the wrong direction
> to me (keeping it, but breaking a rare but working use case to the
> benefit of a rare but broken misconfiguration).
>
>> > Of course if you don't set imap.host, then we don't have anything useful
>> > to say. But as you saw, in that case imap-send will default the host
>> > field to the word "tunnel".
>>
>> Isn't that more of a suggestion that nobody cares about this? Presumably
>> if we had users trying to get this to work someone would have complained
>> that they wanted a custom string rather than "tunnel", as the auth
>> helper isn't very helpful in that case...
>
> Not if they did:
>
> [imap]
> host = example.com
> tunnel = some-command
Yes, but how would they have ended up doing that? By discarding the
documentation and throwing things at the wall & hoping they'd stick?
I take all your general points above, and generally agree with them. Re
#1 we should generally prefer current behavior over the docs, and re #2:
Yes, I agree this might be useful in princple, and hardcoding
"host=tunnel" doesn't leave a way to pass a custom "host to the auth
helper.
I also don't care enough to argue about it, so I'll leave the first hunk
here out of any re-roll. We'll continue to pass "host" down in that
case, i.e. I'll only adjust the error messages.
I just don't get how anyone could have come to rely on this so that we'd
care about supporting it.
Because mutt has a feature that looks similar, users might have
configured git-imap-send thinking it might do the same thing, and gotten
lucky?
I guess in principle that could be true, but I think it's more likely
that nobody's ever had reason to use it that way. I.e. if you use the
"tunnel" the way the docs suggest you won't hit the credential helper,
as you're authenticating with "ssh", and using "imapd" to directly
operate on a Maildir path.
next prev parent reply other threads:[~2023-02-05 22:03 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 11:31 [PATCH 1/2] Makefile: not use mismatched curl_config to check version Jiang Xin
2023-02-01 11:31 ` [PATCH 2/2] imap-send: not define USE_CURL_FOR_IMAP_SEND in Makefile Jiang Xin
2023-02-01 23:04 ` [PATCH] imap-send: replace auto-probe libcurl with hard dependency Ævar Arnfjörð Bjarmason
2023-02-01 23:22 ` Junio C Hamano
2023-02-01 23:56 ` Ævar Arnfjörð Bjarmason
2023-02-02 1:32 ` Junio C Hamano
2023-02-01 23:59 ` Jeff King
2023-02-02 0:20 ` Ævar Arnfjörð Bjarmason
2023-02-02 9:44 ` [PATCH v2 0/6] " Ævar Arnfjörð Bjarmason
2023-02-02 9:44 ` [PATCH v2 1/6] imap-send: note "auth_method", not "host" on auth method failure Ævar Arnfjörð Bjarmason
2023-02-02 19:11 ` Junio C Hamano
2023-02-02 9:44 ` [PATCH v2 2/6] imap-send doc: the imap.sslVerify is used with imap.tunnel Ævar Arnfjörð Bjarmason
2023-02-02 9:44 ` [PATCH v2 3/6] imap-send: replace auto-probe libcurl with hard dependency Ævar Arnfjörð Bjarmason
2023-02-02 19:33 ` Junio C Hamano
2023-02-02 9:44 ` [PATCH v2 4/6] imap-send: make --curl no-optional Ævar Arnfjörð Bjarmason
2023-02-02 20:42 ` Junio C Hamano
2023-02-03 21:46 ` Ævar Arnfjörð Bjarmason
2023-02-04 5:22 ` Junio C Hamano
2023-02-02 9:44 ` [PATCH v2 5/6] imap-send: remove old --no-curl codepath Ævar Arnfjörð Bjarmason
2023-02-02 20:43 ` Junio C Hamano
2023-02-02 9:44 ` [PATCH v2 6/6] imap-send: correctly report "host" when using "tunnel" Ævar Arnfjörð Bjarmason
2023-02-02 20:56 ` Junio C Hamano
2023-02-03 17:53 ` Jeff King
2023-02-03 21:12 ` Ævar Arnfjörð Bjarmason
2023-02-04 11:09 ` Jeff King
2023-02-05 21:51 ` Ævar Arnfjörð Bjarmason [this message]
2023-02-07 18:30 ` Jeff King
2023-02-07 20:39 ` Ævar Arnfjörð Bjarmason
2023-02-07 21:26 ` Junio C Hamano
2023-02-07 22:04 ` Ævar Arnfjörð Bjarmason
2023-02-07 22:16 ` Jeff King
2023-02-07 22:15 ` Jeff King
2023-02-07 22:24 ` Junio C Hamano
2023-02-08 1:06 ` Ævar Arnfjörð Bjarmason
2023-02-17 20:50 ` Jeff King
2023-02-06 21:41 ` Junio C Hamano
2023-02-01 18:06 ` [PATCH 1/2] Makefile: not use mismatched curl_config to check version Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=230205.86ilgf7osb.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ockham@raz.or.at \
--cc=peff@peff.net \
--cc=repk@triplefau.lt \
--cc=worldhello.net@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).