summaryrefslogtreecommitdiff
path: root/gpg-interface.c
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2016-06-17 23:38:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-18 00:03:57 (GMT)
commitefee9553a4f97b2ecd8f49be19606dd4cf7d9c28 (patch)
tree1d1e5054f8de93e8ce06ba356336153e557e293c /gpg-interface.c
parent0581b546419627d4e82f7df8b195fa207ef42f6a (diff)
downloadgit-efee9553a4f97b2ecd8f49be19606dd4cf7d9c28.zip
git-efee9553a4f97b2ecd8f49be19606dd4cf7d9c28.tar.gz
git-efee9553a4f97b2ecd8f49be19606dd4cf7d9c28.tar.bz2
gpg-interface: check gpg signature creation status
When we create a signature, it may happen that gpg returns with "success" but not with an actual detached signature on stdout. Check for the correct signature creation status to catch these cases better. Really, --status-fd parsing is the only way to check gpg status reliably. We do the same for verify already. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r--gpg-interface.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gpg-interface.c b/gpg-interface.c
index 74f08a2..08356f9 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -153,9 +153,11 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
struct child_process gpg = CHILD_PROCESS_INIT;
int ret;
size_t i, j, bottom;
+ struct strbuf gpg_status = STRBUF_INIT;
argv_array_pushl(&gpg.args,
gpg_program,
+ "--status-fd=2",
"-bsau", signing_key,
NULL);
@@ -167,10 +169,12 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
*/
sigchain_push(SIGPIPE, SIG_IGN);
ret = pipe_command(&gpg, buffer->buf, buffer->len,
- signature, 1024, NULL, 0);
+ signature, 1024, &gpg_status, 0);
sigchain_pop(SIGPIPE);
- if (ret || signature->len == bottom)
+ ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
+ strbuf_release(&gpg_status);
+ if (ret)
return error(_("gpg failed to sign the data"));
/* Strip CR from the line endings, in case we are on Windows. */