| 347 | } |
| 348 | |
| 349 | static int verify_gpg_signed_buffer(struct signature_check *sigc, |
| 350 | struct gpg_format *fmt, |
| 351 | const char *signature, |
| 352 | size_t signature_size) |
| 353 | { |
| 354 | struct child_process gpg = CHILD_PROCESS_INIT; |
| 355 | struct tempfile *temp; |
| 356 | int ret; |
| 357 | struct strbuf gpg_stdout = STRBUF_INIT; |
| 358 | struct strbuf gpg_stderr = STRBUF_INIT; |
| 359 | |
| 360 | temp = mks_tempfile_t(".git_vtag_tmpXXXXXX"); |
| 361 | if (!temp) |
| 362 | return error_errno(_("could not create temporary file")); |
| 363 | if (write_in_full(temp->fd, signature, signature_size) < 0 || |
| 364 | close_tempfile_gently(temp) < 0) { |
| 365 | error_errno(_("failed writing detached signature to '%s'"), |
| 366 | temp->filename.buf); |
| 367 | delete_tempfile(&temp); |
| 368 | return -1; |
| 369 | } |
| 370 | |
| 371 | strvec_push(&gpg.args, fmt->program); |
| 372 | strvec_pushv(&gpg.args, fmt->verify_args); |
| 373 | strvec_pushl(&gpg.args, |
| 374 | "--status-fd=1", |
| 375 | "--verify", temp->filename.buf, "-", |
| 376 | NULL); |
| 377 | |
| 378 | sigchain_push(SIGPIPE, SIG_IGN); |
| 379 | ret = pipe_command(&gpg, sigc->payload, sigc->payload_len, &gpg_stdout, 0, |
| 380 | &gpg_stderr, 0); |
| 381 | sigchain_pop(SIGPIPE); |
| 382 | |
| 383 | delete_tempfile(&temp); |
| 384 | |
| 385 | ret |= !strstr(gpg_stdout.buf, "\n[GNUPG:] GOODSIG ") && |
| 386 | !strstr(gpg_stdout.buf, "\n[GNUPG:] EXPKEYSIG "); |
| 387 | sigc->output = strbuf_detach(&gpg_stderr, NULL); |
| 388 | sigc->gpg_status = strbuf_detach(&gpg_stdout, NULL); |
| 389 | |
| 390 | parse_gpg_output(sigc); |
| 391 | |
| 392 | strbuf_release(&gpg_stdout); |
| 393 | strbuf_release(&gpg_stderr); |
| 394 | |
| 395 | return ret; |
| 396 | } |
| 397 | |
| 398 | static void parse_ssh_output(struct signature_check *sigc) |
| 399 | { |
nothing calls this directly
no test coverage detected