git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	"Karel Kočí" <karel.koci@nic.cz>,
	"Santiago Torres" <santiago@nyu.edu>,
	"Vojtech Myslivec" <vojtech.myslivec@nic.cz>,
	git@vger.kernel.org
Subject: Re: [PATCH 1/1] verify-tag/verify-commit should exit unsuccessfully when signature is not trusted
Date: Thu, 9 Aug 2018 13:12:19 -0400	[thread overview]
Message-ID: <20180809171219.GF1439@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqtvo3d0by.fsf@gitster-ct.c.googlers.com>

On Thu, Aug 09, 2018 at 08:30:25AM -0700, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > There was a patch at the start of this thread, but it specifically
> > checks for "sigc->result == U".  That's probably OK, since I think it
> > restores the behavior in earlier versions of Git. But I wonder if we
> > should simply be storing the fact that gpg exited non-zero and relaying
> > that. That would fix this problem and truly make the rule "if gpg
> > reported an error, we propagate that".
> 
> Yeah, I like that.  Something like this, perhaps?  Points to note:
> 
>  * status gets the return value from verify_signed_buffer(), which
>    essentially is what wait_or_whine() gives us for the "gpg
>    --verify" process.
> 
>  * Even if status says "failed", we still need to parse the output
>    to set sigc->result.  We used to use sigc->result as the sole
>    source of our return value, but now we turn 'status' into 'bad'
>    (i.e. non-zero) after parsing and finding it is not mechanically
>    good (which is the same criteria as we have always used before).
>    An already bad status is left as bad.
> 
>  * And we return 'status'.

Yeah, this is exactly what I had in mind. And the size of the code
change is much smaller than I feared. The case that I thought might be
complicated is still reading the output after we've seen the non-zero
status, but the existing "if (status && !gpg_output.len)" covers that.

> If we choose to blindly trust the exit status of "gpg --verify" and
> not interpret the result ourselves, we can lose the "smudge status
> to be bad if not G/U" bit, which I offhand do not think makes much
> difference either way.  I just left it there because showing what
> can be removed and saying it can be dropped is easier than showing
> the result of removal and saying it can be added--simply because I
> need to describe "it" if I go the latter route.

I guess leaving it serves as a sort of cross-check if gpg would return a
zero exit code but indicate in the status result that the signature was
not good. Sort of a belt-and-suspenders, I guess (which might not be
that implausible if we think about somebody wrapping gpg with a sloppy
bit of shell code that loses the exit code -- it's their fault, but it
might be nice for us to err on the conservative side).

Probably it should go back to just "result != G" then, though (thus
bringing the whole conversation full circle :) ).

I could live with or without it, though.

-Peff

  reply	other threads:[~2018-08-09 17:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31 20:05 [PATCH 1/1] verify-tag/verify-commit should exit unsuccessfully when signature is not trusted Vojtech Myslivec
2018-08-01  0:19 ` brian m. carlson
2018-08-01  0:25   ` Santiago Torres
2018-08-03 13:36     ` Karel Kočí
2018-08-03 15:43       ` Santiago Torres
2018-08-03 16:06         ` Jeff King
2018-08-04  8:43           ` Karel Kočí
2018-08-08 23:04             ` Jeff King
2018-08-08 23:12               ` brian m. carlson
2018-08-09  0:59                 ` Junio C Hamano
2018-08-09  1:43                   ` brian m. carlson
2018-08-09 14:30                     ` Jeff King
2018-08-09 15:30                       ` Junio C Hamano
2018-08-09 17:12                         ` Jeff King [this message]
2018-08-09 18:40                           ` Junio C Hamano
2018-08-09 19:50                             ` Jeff King
2018-08-10  2:27                             ` brian m. carlson
2018-08-13 15:14                             ` Vojtech Myslivec
2018-08-03 17:32         ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180809171219.GF1439@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karel.koci@nic.cz \
    --cc=sandals@crustytoothpaste.net \
    --cc=santiago@nyu.edu \
    --cc=vojtech.myslivec@nic.cz \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).