Skip to content

Commit 99cf324

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 ec53539 commit 99cf324

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

gpg-interface.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,9 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
160160
struct child_process gpg = CHILD_PROCESS_INIT;
161161
int ret;
162162
size_t i, j, bottom;
163-
struct strbuf gpg_status = STRBUF_INIT;
164163

165164
argv_array_pushl(&gpg.args,
166165
gpg_program,
167-
"--status-fd=2",
168166
"-bsau", signing_key,
169167
NULL);
170168

@@ -176,12 +174,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
176174
*/
177175
sigchain_push(SIGPIPE, SIG_IGN);
178176
ret = pipe_command(&gpg, buffer->buf, buffer->len,
179-
signature, 1024, &gpg_status, 0);
177+
signature, 1024, NULL, 0);
180178
sigchain_pop(SIGPIPE);
181179

182-
ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
183-
strbuf_release(&gpg_status);
184-
if (ret)
180+
if (ret || signature->len == bottom)
185181
return error(_("gpg failed to sign the data"));
186182

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

t/t7004-tag.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,17 +1202,10 @@ test_expect_success GPG,RFC1991 \
12021202
# try to sign with bad user.signingkey
12031203
git config user.signingkey BobTheMouse
12041204
test_expect_success GPG \
1205-
'git tag -s fails if gpg is misconfigured (bad key)' \
1205+
'git tag -s fails if gpg is misconfigured' \
12061206
'test_must_fail git tag -s -m tail tag-gpg-failure'
12071207
git config --unset user.signingkey
12081208

1209-
# try to produce invalid signature
1210-
test_expect_success GPG \
1211-
'git tag -s fails if gpg is misconfigured (bad signature format)' \
1212-
'test_config gpg.program echo &&
1213-
test_must_fail git tag -s -m tail tag-gpg-failure'
1214-
1215-
12161209
# try to verify without gpg:
12171210

12181211
rm -rf gpghome

0 commit comments

Comments
 (0)