Bug 217332 - b4: executable sendemail.smtpserver and b4 --reflect
Summary: b4: executable sendemail.smtpserver and b4 --reflect
Status: RESOLVED CODE_FIX
Alias: None
Product: Tools
Classification: Unclassified
Component: Infra (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: Konstantin Ryabitsev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-12 19:26 UTC by Bugspray Bot
Modified: 2023-08-04 15:08 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Bugspray Bot 2023-04-12 19:26:23 UTC
Nick Desaulniers <ndesaulniers@google.com> writes:

Hi Konstantin,
I was following along
https://people.kernel.org/monsieuricon/introducing-b4-and-patch-attestation
eager to try using b4 to send a patch series.  When I got to

$ b4 send --reflect

it seems that my series was sent to the list, surprisingly!
https://lore.kernel.org/llvm/20230412-no_stackp-v1-0-46a69b507a4b@google.com/

Internally at my employer, I must use a command line utility to send
email outside of the blessed GUI.  As such, my ~/.gitconfig looks
like:

...
[user]
        name = Nick Desaulniers
        email = ndesaulniers@google.com
[sendemail]
        from = Nick Desaulniers <ndesaulniers@google.com>
        smtpserver = /usr/bin/sendgmr
...

From a discussion with you and Matthew on IRC, it sounds like this
company-internal sendgmr utility might not be respecting some header
b4 adds to the eml file (envelope-from?)?

I can file a bug internally, but I'm not well versed on how to clarify
precisely what's going wrong.  Is there anything to be done in b4
itself, or help me word such a report I can file internally?

I also noticed that my name wasn't being sent on the From: field to
LKML. I assume that's an orthogonal issue, but is there anything else
I should be doing there?

(via https://msgid.link/CAKwvOdn6_J%2B9BppRbXEtDc8CW-qqoat7VJ521oWnqXCXHb_d6A%40mail.gmail.com)
Comment 1 Bugspray Bot 2023-04-12 19:26:27 UTC
Nick Desaulniers <ndesaulniers@google.com> writes:

On Wed, Apr 12, 2023 at 12:00 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> Hi Konstantin,
> I was following along
> https://people.kernel.org/monsieuricon/introducing-b4-and-patch-attestation
> eager to try using b4 to send a patch series.  When I got to
>
> $ b4 send --reflect
>
> it seems that my series was sent to the list, surprisingly!
> https://lore.kernel.org/llvm/20230412-no_stackp-v1-0-46a69b507a4b@google.com/

Ah, forgot to attach the log of what I ran and observed from the
command line, in case that helps:
https://paste.debian.net/1277133/

>
> Internally at my employer, I must use a command line utility to send
> email outside of the blessed GUI.  As such, my ~/.gitconfig looks
> like:
>
> ...
> [user]
>         name = Nick Desaulniers
>         email = ndesaulniers@google.com
> [sendemail]
>         from = Nick Desaulniers <ndesaulniers@google.com>
>         smtpserver = /usr/bin/sendgmr
> ...
>
> From a discussion with you and Matthew on IRC, it sounds like this
> company-internal sendgmr utility might not be respecting some header
> b4 adds to the eml file (envelope-from?)?
>
> I can file a bug internally, but I'm not well versed on how to clarify
> precisely what's going wrong.  Is there anything to be done in b4
> itself, or help me word such a report I can file internally?
>
> I also noticed that my name wasn't being sent on the From: field to
> LKML. I assume that's an orthogonal issue, but is there anything else
> I should be doing there?
> --
> Thanks,
> ~Nick Desaulniers

(via https://msgid.link/CAKwvOdmqageZXw8cxETPaWyST-TfAp%2BbDa8vxfKEVksf35-qLA%40mail.gmail.com)
Comment 2 Bugspray Bot 2023-04-12 19:26:30 UTC
Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:

On Wed, Apr 12, 2023 at 12:00:09PM -0700, Nick Desaulniers wrote:
> $ b4 send --reflect
> 
> it seems that my series was sent to the list, surprisingly!
> https://lore.kernel.org/llvm/20230412-no_stackp-v1-0-46a69b507a4b@google.com/

Yes, this is bad, as the warning message specifically says that this won't
happen.

bugbot assign to me

> Internally at my employer, I must use a command line utility to send
> email outside of the blessed GUI.  As such, my ~/.gitconfig looks
> like:
> 
> ...
> [user]
>         name = Nick Desaulniers
>         email = ndesaulniers@google.com
> [sendemail]
>         from = Nick Desaulniers <ndesaulniers@google.com>
>         smtpserver = /usr/bin/sendgmr
> ...
> 
> From a discussion with you and Matthew on IRC, it sounds like this
> company-internal sendgmr utility might not be respecting some header
> b4 adds to the eml file (envelope-from?)?

What happens is that we expect that whatever we talk to will ignore the To/Cc
headers in the message and only send the message to the recipients specified
during the outer exchange (e.g. SMTP ignores anything in these headers and
only pays attention to the recipients passed in "RCPT TO"; the same is true
for actual "sendmail" command). 

The safe course of action is to bail on --reflect when we recognize that a
local executable is being used, because there is no guarantee that it will be
compatible with our expectations that To: and Cc: headers in the message will
be ignored.

> I can file a bug internally, but I'm not well versed on how to clarify
> precisely what's going wrong.  Is there anything to be done in b4
> itself, or help me word such a report I can file internally?

I'm not sure it's worth your effort for this particular case, as sendgmr
doesn't claim to be sendmail-compatible, it's a tool to use with
git-send-email and *deliberately* pays attention to To: and Cc: headers in the
message. To be sendmail-compatible, it would need to ignore To: and Cc:
headers in the message and only pay to recipients passed as command-line
arguments, unless -t is specified (e.g. see
https://man7.org/linux/man-pages/man8/sendmail.8.html).

> I also noticed that my name wasn't being sent on the From: field to
> LKML. I assume that's an orthogonal issue, but is there anything else
> I should be doing there?

Do you have "from = " set in your [sendemail] section?

-K

(via https://msgid.link/20230412-smokiness-portal-833f99%40meerkat)
Comment 3 Bugspray Bot 2023-04-12 19:42:50 UTC
Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:

On Wed, Apr 12, 2023 at 12:00:09PM -0700, Nick Desaulniers wrote:
> ...
> [user]
>         name = Nick Desaulniers
>         email = ndesaulniers@google.com
> [sendemail]
>         from = Nick Desaulniers <ndesaulniers@google.com>
>         smtpserver = /usr/bin/sendgmr

Oh, you actually provided what I was asking. I'll check why we're not putting
the full name into the From: header.

-K

(via https://msgid.link/20230412-awkward-bobble-2a9614%40meerkat)
Comment 4 Bugspray Bot 2023-04-19 18:15:09 UTC
Konstantin Ryabitsev writes in commit eff3eca47b798a501d079f7d25165d0415551edc:

ez: do not trust local commands to properly reflect

As we just discovered, Google's sendgmr is not properly compatible with
sendmail flags, and will ignore addresses passed via the CLI, instead
always using the ones from the headers.

This is opposite to what --reflect is designed to do, so bail out with a
loud error, but give a way to override it via a custom variable.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217332
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>

(via https://git.kernel.org/pub/scm/utils/b4/b4.git/commit/?id=eff3eca47b79)
Comment 5 Nick Desaulniers 2023-04-19 18:26:12 UTC
Wonderful, thanks as always Konstantin!
Comment 6 Bugspray Bot 2023-04-19 18:36:42 UTC
Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:

On Wed, Apr 12, 2023 at 12:00:09PM -0700, Nick Desaulniers wrote:
> I also noticed that my name wasn't being sent on the From: field to
> LKML. I assume that's an orthogonal issue, but is there anything else
> I should be doing there?

I don't think it's b4 that is doing this. I think Matthew mentioned that
sendgmr will rewrite some headers to match your internal authentication,
perhaps that's what is replacing the From: header?

-K

(via https://msgid.link/20230419-closure-polymer-f7a6ac@meerkat)
Comment 7 Bugspray Bot 2023-04-28 18:36:34 UTC
Nick Desaulniers <ndesaulniers@google.com> replies to comment #6:

On Wed, Apr 19, 2023 at 11:30 AM Konstantin Ryabitsev
<konstantin@linuxfoundation.org> wrote:
>
> On Wed, Apr 12, 2023 at 12:00:09PM -0700, Nick Desaulniers wrote:
> > I also noticed that my name wasn't being sent on the From: field to
> > LKML. I assume that's an orthogonal issue, but is there anything else
> > I should be doing there?
>
> I don't think it's b4 that is doing this. I think Matthew mentioned that
> sendgmr will rewrite some headers to match your internal authentication,
> perhaps that's what is replacing the From: header?

I see:

$ b4 send
...
Sending via "/usr/bin/sendgmr -i -f ndesaulniers@google.com"

Should this be using `/usr/bin/sendgmr -i -f 'Nick Desaulniers
<ndesaulniers@google.com>'`?

(via https://msgid.link/CAKwvOd%3Dh2TeX6_WqHtK8Tf1MqmOB_ao%2BJfJpnoSmwXUB0qkaug@mail.gmail.com)
Comment 8 Bugspray Bot 2023-04-28 18:47:27 UTC
Konstantin Ryabitsev <konstantin@linuxfoundation.org> replies to comment #7:

On Fri, Apr 28, 2023 at 11:34:23AM -0700, Nick Desaulniers wrote:
> > I don't think it's b4 that is doing this. I think Matthew mentioned that
> > sendgmr will rewrite some headers to match your internal authentication,
> > perhaps that's what is replacing the From: header?
> 
> I see:
> 
> $ b4 send
> ...
> Sending via "/usr/bin/sendgmr -i -f ndesaulniers@google.com"
> 
> Should this be using `/usr/bin/sendgmr -i -f 'Nick Desaulniers
> <ndesaulniers@google.com>'`?

No, the addresses passed via -f are for the envelope-from, not for the message
headers (the envelope-from is used during the SMTP negotiation and this is
where the message should bounce to if it's not delivered).

That said, I don't know how sendgmr works internally, and since it doesn't
claim to be sendmail-compatible, the flags and how it treats them can be
anything, really.

-K

(via https://msgid.link/20230428-guidance-unvented-692ee1@meerkat)
Comment 9 Nick Desaulniers 2023-05-15 21:42:33 UTC
I spoke with the maintainer of our internal `sendgmr` tool; they recommended that the `-t` flag be used.

https://man7.org/linux/man-pages/man8/sendmail.8.html

Can `b4 send` add `-t`?
Comment 10 Bugspray Bot 2023-05-15 21:55:26 UTC
Konstantin Ryabitsev <konstantin@linuxfoundation.org> replies to comment #9:

On Mon, May 15, 2023 at 09:44:44PM +0000, Kernel.org Bugbot wrote:
> I spoke with the maintainer of our internal `sendgmr` tool; they recommended
> that the `-t` flag be used.
> 
> https://man7.org/linux/man-pages/man8/sendmail.8.html
> 
> Can `b4 send` add `-t`?

Sorry, I'm not sure why we'd want to do that. The purpose of "reflect" mode is
specifically NOT to send to to addresses in the message headers, only to the
addresses we pass on the command line. So, adding -t would be the opposite of
what we want to do.

-K

(via https://msgid.link/20230515-version-unnatural-8d0592@meerkat)
Comment 11 Bugspray Bot 2023-05-15 23:06:51 UTC
Nick Desaulniers <ndesaulniers@google.com> replies to comment #10:

On Mon, May 15, 2023 at 2:50 PM Konstantin Ryabitsev
<konstantin@linuxfoundation.org> wrote:
>
> On Mon, May 15, 2023 at 09:44:44PM +0000, Kernel.org Bugbot wrote:
> > I spoke with the maintainer of our internal `sendgmr` tool; they
> recommended that the `-t` flag be used.
> >
> > https://man7.org/linux/man-pages/man8/sendmail.8.html
> >
> > Can `b4 send` add `-t`?
>
> Sorry, I'm not sure why we'd want to do that. The purpose of "reflect" mode
> is
> specifically NOT to send to to addresses in the message headers, only to the
> addresses we pass on the command line. So, adding -t would be the opposite of
> what we want to do.

This is not for reflect mode; sorry for not clarifying.

>
> -K

(via https://msgid.link/CAKwvOd%3Dsw6nXw1SohLqJsBnzjRsQrgswdfyZY22R6Dh93sbXLw@mail.gmail.com)
Comment 12 Nick Desaulniers 2023-05-16 22:54:31 UTC
(In reply to Bugbot from comment #0)
> Nick Desaulniers <ndesaulniers@google.com> writes:
> I also noticed that my name wasn't being sent on the From: field to
> LKML. I assume that's an orthogonal issue, but is there anything else
> I should be doing there?

(In reply to Nick Desaulniers from comment #9)
> I spoke with the maintainer of our internal `sendgmr` tool; they recommended
> that the `-t` flag be used.
> 
> https://man7.org/linux/man-pages/man8/sendmail.8.html
> 
> Can `b4 send` add `-t`?

...specifically not when using --reflect? (Happy to file a second bug to track this second issue, since it's orthogonal to --reflect).
Comment 13 Nick Desaulniers 2023-08-03 20:54:37 UTC
I think https://git.kernel.org/pub/scm/utils/b4/b4.git/commit/?id=8382882b9fb6c50737b6e19198a259850527d2a6 resolves this issue for us.  Look forward to the formal release that contains that. Thanks Konstantin!

(I don't think I'm able to change the status of this report in bugzilla to Fixed)

Note You need to log in before you can comment on or make changes to this bug.