Skip to content

Commit 9379548

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Unbreak interactive GPG prompt upon signing
With the recent update in efee955 (gpg-interface: check gpg signature creation status, 2016-06-17), we ask GPG to send all status updates to stderr, and then catch the stderr in an strbuf. But GPG might fail, and send error messages to stderr. And we simply do not show them to the user. Even worse: this swallows any interactive prompt for a passphrase. And detaches stderr from the tty so that the passphrase cannot be read. So while the first problem could be fixed (by printing the captured stderr upon error), the second problem cannot be easily fixed, and presents a major regression. So let's just revert commit efee955. This fixes #871 Cc: Michael J Gruber <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9236315 commit 9379548

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

gpg-interface.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,9 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
432432
struct child_process gpg = CHILD_PROCESS_INIT;
433433
int ret;
434434
size_t i, j, bottom;
435-
struct strbuf gpg_status = STRBUF_INIT;
436435

437436
argv_array_pushl(&gpg.args,
438437
use_format->program,
439-
"--status-fd=2",
440438
"-bsau", signing_key,
441439
NULL);
442440

@@ -448,12 +446,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
448446
*/
449447
sigchain_push(SIGPIPE, SIG_IGN);
450448
ret = pipe_command(&gpg, buffer->buf, buffer->len,
451-
signature, 1024, &gpg_status, 0);
449+
signature, 1024, NULL, 0);
452450
sigchain_pop(SIGPIPE);
453451

454-
ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
455-
strbuf_release(&gpg_status);
456-
if (ret)
452+
if (ret || signature->len == bottom)
457453
return error(_("gpg failed to sign the data"));
458454

459455
/* Strip CR from the line endings, in case we are on Windows. */

t/t7004-tag.sh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,26 +1365,13 @@ test_expect_success GPG \
13651365
'test_config user.signingkey BobTheMouse &&
13661366
test_must_fail git tag -s -m tail tag-gpg-failure'
13671367

1368-
# try to produce invalid signature
1369-
test_expect_success GPG \
1370-
'git tag -s fails if gpg is misconfigured (bad signature format)' \
1371-
'test_config gpg.program echo &&
1372-
test_must_fail git tag -s -m tail tag-gpg-failure'
1373-
13741368
# try to sign with bad user.signingkey
13751369
test_expect_success GPGSM \
13761370
'git tag -s fails if gpgsm is misconfigured (bad key)' \
13771371
'test_config user.signingkey BobTheMouse &&
13781372
test_config gpg.format x509 &&
13791373
test_must_fail git tag -s -m tail tag-gpg-failure'
13801374

1381-
# try to produce invalid signature
1382-
test_expect_success GPGSM \
1383-
'git tag -s fails if gpgsm is misconfigured (bad signature format)' \
1384-
'test_config gpg.x509.program echo &&
1385-
test_config gpg.format x509 &&
1386-
test_must_fail git tag -s -m tail tag-gpg-failure'
1387-
13881375
# try to verify without gpg:
13891376

13901377
rm -rf gpghome

0 commit comments

Comments
 (0)