Skip to content

Commit b095566

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 3c97c87 commit b095566

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
@@ -1345,26 +1345,13 @@ test_expect_success GPG \
13451345
'test_config user.signingkey BobTheMouse &&
13461346
test_must_fail git tag -s -m tail tag-gpg-failure'
13471347

1348-
# try to produce invalid signature
1349-
test_expect_success GPG \
1350-
'git tag -s fails if gpg is misconfigured (bad signature format)' \
1351-
'test_config gpg.program echo &&
1352-
test_must_fail git tag -s -m tail tag-gpg-failure'
1353-
13541348
# try to sign with bad user.signingkey
13551349
test_expect_success GPGSM \
13561350
'git tag -s fails if gpgsm is misconfigured (bad key)' \
13571351
'test_config user.signingkey BobTheMouse &&
13581352
test_config gpg.format x509 &&
13591353
test_must_fail git tag -s -m tail tag-gpg-failure'
13601354

1361-
# try to produce invalid signature
1362-
test_expect_success GPGSM \
1363-
'git tag -s fails if gpgsm is misconfigured (bad signature format)' \
1364-
'test_config gpg.x509.program echo &&
1365-
test_config gpg.format x509 &&
1366-
test_must_fail git tag -s -m tail tag-gpg-failure'
1367-
13681355
# try to verify without gpg:
13691356

13701357
rm -rf gpghome

0 commit comments

Comments
 (0)