Skip to content

Commit 27b2622

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 4b16986 commit 27b2622

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
@@ -228,11 +228,9 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
228228
struct child_process gpg = CHILD_PROCESS_INIT;
229229
int ret;
230230
size_t i, j, bottom;
231-
struct strbuf gpg_status = STRBUF_INIT;
232231

233232
argv_array_pushl(&gpg.args,
234233
use_format->program,
235-
"--status-fd=2",
236234
"-bsau", signing_key,
237235
NULL);
238236

@@ -244,12 +242,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
244242
*/
245243
sigchain_push(SIGPIPE, SIG_IGN);
246244
ret = pipe_command(&gpg, buffer->buf, buffer->len,
247-
signature, 1024, &gpg_status, 0);
245+
signature, 1024, NULL, 0);
248246
sigchain_pop(SIGPIPE);
249247

250-
ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
251-
strbuf_release(&gpg_status);
252-
if (ret)
248+
if (ret || signature->len == bottom)
253249
return error(_("gpg failed to sign the data"));
254250

255251
/* 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)