Skip to content

Commit bd40e42

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 23ccdd8 commit bd40e42

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

gpg-interface.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,9 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
156156
struct child_process gpg = CHILD_PROCESS_INIT;
157157
int ret;
158158
size_t i, j, bottom;
159-
struct strbuf gpg_status = STRBUF_INIT;
160159

161160
argv_array_pushl(&gpg.args,
162161
gpg_program,
163-
"--status-fd=2",
164162
"-bsau", signing_key,
165163
NULL);
166164

@@ -172,12 +170,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
172170
*/
173171
sigchain_push(SIGPIPE, SIG_IGN);
174172
ret = pipe_command(&gpg, buffer->buf, buffer->len,
175-
signature, 1024, &gpg_status, 0);
173+
signature, 1024, NULL, 0);
176174
sigchain_pop(SIGPIPE);
177175

178-
ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
179-
strbuf_release(&gpg_status);
180-
if (ret)
176+
if (ret || signature->len == bottom)
181177
return error(_("gpg failed to sign the data"));
182178

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

t/t7004-tag.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,13 +1307,6 @@ test_expect_success GPG \
13071307
'test_config user.signingkey BobTheMouse &&
13081308
test_must_fail git tag -s -m tail tag-gpg-failure'
13091309

1310-
# try to produce invalid signature
1311-
test_expect_success GPG \
1312-
'git tag -s fails if gpg is misconfigured (bad signature format)' \
1313-
'test_config gpg.program echo &&
1314-
test_must_fail git tag -s -m tail tag-gpg-failure'
1315-
1316-
13171310
# try to verify without gpg:
13181311

13191312
rm -rf gpghome

0 commit comments

Comments
 (0)