git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Fabian Stelzer <fs@gigacodes.de>,
	Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH] ssh signing: return an error when signature cannot be read
Date: Mon, 03 Oct 2022 09:13:36 -0700	[thread overview]
Message-ID: <xmqq1qroyjf3.fsf@gitster.g> (raw)
In-Reply-To: <pull.1371.git.1664789075343.gitgitgadget@gmail.com> (Phillip Wood via GitGitGadget's message of "Mon, 03 Oct 2022 09:24:35 +0000")

"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> If the signature file cannot be read we print an error message but do
> not return an error to the caller. In practice it seems unlikely that
> the file would be unreadable if the call to ssh-keygen succeeds. If we
> cannot read the file it may be missing so ignore any errors from
> unlink() when we try to remove it.

OK.  Not removing may help diagnose what the problem is, but going
that route needs to add code to report what file is deliberately
left for inspection.  I do not know how valuable that would be to
help human debuggers --- the user presumably have the original
material (e.g. a signed tag object) anyway, and the human debugger
probably needs to have access to both the original material and what
is fed to the gpg-interface API.  If they are chasing a reproducible
bug, the latter should be recreatable by the human debugger from the
former, so removing would not hurt the debuggability that much.

On the other hand, we can still report if the reason we cannot
remove is not ENOENT, though.

Thanks.

>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
>     ssh signing: return an error when signature cannot be read
>     
>     This patch is based on maint. In the longer term the code could be
>     simplified by using pipes rather than tempfiles as we do for gpg.
>     ssh-keygen has supported reading the data to be signed from stdin and
>     writing the signature to stdout since it introduced signing.
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1371%2Fphillipwood%2Fssh-signing-return-error-on-missing-signature-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1371/phillipwood/ssh-signing-return-error-on-missing-signature-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1371
>
>  gpg-interface.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gpg-interface.c b/gpg-interface.c
> index 947b58ad4da..d352bc286b6 100644
> --- a/gpg-interface.c
> +++ b/gpg-interface.c
> @@ -1043,9 +1043,11 @@ static int sign_buffer_ssh(struct strbuf *buffer, struct strbuf *signature,
>  	strbuf_addbuf(&ssh_signature_filename, &buffer_file->filename);
>  	strbuf_addstr(&ssh_signature_filename, ".sig");
>  	if (strbuf_read_file(signature, ssh_signature_filename.buf, 0) < 0) {
> -		error_errno(
> +		ret = error_errno(
>  			_("failed reading ssh signing data buffer from '%s'"),
>  			ssh_signature_filename.buf);
> +		unlink(ssh_signature_filename.buf);
> +		goto out;
>  	}
>  	unlink_or_warn(ssh_signature_filename.buf);
>  
>
> base-commit: a0feb8611d4c0b2b5d954efe4e98207f62223436

  reply	other threads:[~2022-10-03 16:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03  9:24 [PATCH] ssh signing: return an error when signature cannot be read Phillip Wood via GitGitGadget
2022-10-03 16:13 ` Junio C Hamano [this message]
2022-10-04 10:01 ` [PATCH v2] " Phillip Wood via GitGitGadget
2022-10-06  8:28   ` Fabian Stelzer
2022-10-06 13:05     ` Phillip Wood
2022-10-06 14:19       ` Fabian Stelzer

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=xmqq1qroyjf3.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=fs@gigacodes.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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).