git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ssh signing: return an error when signature cannot be read
@ 2022-10-03  9:24 Phillip Wood via GitGitGadget
  2022-10-03 16:13 ` Junio C Hamano
  2022-10-04 10:01 ` [PATCH v2] " Phillip Wood via GitGitGadget
  0 siblings, 2 replies; 6+ messages in thread
From: Phillip Wood via GitGitGadget @ 2022-10-03  9:24 UTC (permalink / raw)
  To: git; +Cc: Fabian Stelzer, Phillip Wood, Phillip Wood

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.

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
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-10-06 14:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).