Skip to content

Commit f756951

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 178d089 commit f756951

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
@@ -153,11 +153,9 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
153153
struct child_process gpg = CHILD_PROCESS_INIT;
154154
int ret;
155155
size_t i, j, bottom;
156-
struct strbuf gpg_status = STRBUF_INIT;
157156

158157
argv_array_pushl(&gpg.args,
159158
gpg_program,
160-
"--status-fd=2",
161159
"-bsau", signing_key,
162160
NULL);
163161

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

175-
ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
176-
strbuf_release(&gpg_status);
177-
if (ret)
173+
if (ret || signature->len == bottom)
178174
return error(_("gpg failed to sign the data"));
179175

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