Skip to content

Commit d21bb71

Browse files
committed
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 ca35ce5 commit d21bb71

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
@@ -296,11 +296,9 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
296296
struct child_process gpg = CHILD_PROCESS_INIT;
297297
int ret;
298298
size_t i, j, bottom;
299-
struct strbuf gpg_status = STRBUF_INIT;
300299

301300
argv_array_pushl(&gpg.args,
302301
use_format->program,
303-
"--status-fd=2",
304302
"-bsau", signing_key,
305303
NULL);
306304

@@ -312,12 +310,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
312310
*/
313311
sigchain_push(SIGPIPE, SIG_IGN);
314312
ret = pipe_command(&gpg, buffer->buf, buffer->len,
315-
signature, 1024, &gpg_status, 0);
313+
signature, 1024, NULL, 0);
316314
sigchain_pop(SIGPIPE);
317315

318-
ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
319-
strbuf_release(&gpg_status);
320-
if (ret)
316+
if (ret || signature->len == bottom)
321317
return error(_("gpg failed to sign the data"));
322318

323319
/* 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
@@ -1366,26 +1366,13 @@ test_expect_success GPG \
13661366
'test_config user.signingkey BobTheMouse &&
13671367
test_must_fail git tag -s -m tail tag-gpg-failure'
13681368

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

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

13911378
rm -rf gpghome

0 commit comments

Comments
 (0)