git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gpg-interface: fix for gpgsm v2.3

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 3, 2022, 18:55 UTC
Message-ID
<xmqq7dabvkze.fsf@gitster.g>
In-Reply-To
<20220203123724.47529-1-fs@gigacodes.de>
Fabian Stelzer <fs@gigacodes.de> writes:
Show 9 quoted lines
> gpgsm v2.3 changed some details about its output:
>  - instead of displaying `fingerprint:` for keys it will print `sha1
>    fpr:` and `sha2 fpr:`
>  - some wording of errors has changed
>  - signing will omit an extra debug output line before the [GNUPG]: tag
>
> This change adjusts the gpgsm test prerequisite to work with v2.3 as
> well by accepting `sha1 fpr:` as well as `fingerprint:` and allows both
> variants of errors for unknown certs.

OK, so the change is meant to add support for the new behaviour without deprecating/removing the support for the older one. Good.

> Checking for successful signature creation will omit the leading NL in
> its search string.

I think this is to adjust for "will omit an extra debug output"; as long as we still ensure that the "[GNUPG:] SIG_CREATED" comes at the beginning of a line with some other means, I think that is a good change.

Show 7 quoted lines
> I am not a user of gpgsm but noticed that the GPGSM test prereq was disabled 
> on my runs so i investigated. The `fix` seems rather trivial and I tried to 
> test this as thorough as possible. I ran the test suite on machines 
> available to me (fedora35, centos8) and did a full CI run on github without 
> any issues.
> But if you actually use gpgsm with git please give this a go and let me know 
> if I missed anything.

Yup, thanks for a call for help. I am not gpgsm user either and testing by actual users is very much appreciated.

Show 6 quoted lines
> @@ -939,7 +939,7 @@ static int sign_buffer_gpg(struct strbuf *buffer, struct strbuf *signature,
>  			   signature, 1024, &gpg_status, 0);
>  	sigchain_pop(SIGPIPE);
>  
> -	ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
> +	ret |= !strstr(gpg_status.buf, "[GNUPG:] SIG_CREATED ");

This I am not sure about. I understand that the intention is to allow this at the beginning of gpg_status.buf, but not to allow the substring appear in the middle of an otherwise unrelated line. I am afraid that the new check is a bit too lose for that.

Totally untested but just to illustrate the idea...
 gpg-interface.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git c/gpg-interface.c w/gpg-interface.c
index b52eb0e2e0..4238e60dfa 100644
--- c/gpg-interface.c
+++ w/gpg-interface.c
@@ -920,6 +920,7 @@ static int sign_buffer_gpg(struct strbuf *buffer, struct strbuf *signature,
 	struct child_process gpg = CHILD_PROCESS_INIT;
 	int ret;
 	size_t bottom;
+	const char *cp;
 	struct strbuf gpg_status = STRBUF_INIT;
 
 	strvec_pushl(&gpg.args,
@@ -939,7 +940,13 @@ static int sign_buffer_gpg(struct strbuf *buffer, struct strbuf *signature,
 			   signature, 1024, &gpg_status, 0);
 	sigchain_pop(SIGPIPE);
 
-	ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
+	for (cp = gpg_status.buf;
+	     cp && (cp = strstr(cp, "[GNUPG:] SIG_CREATED "));
+	     cp++) {
+		if (cp == gpg_status.buf || cp[-1] == '\n')
+			break; /* found */
+	}
+	ret |= !cp;
 	strbuf_release(&gpg_status);
 	if (ret)
 		return error(_("gpg failed to sign the data"));
Previous: Fabian StelzerNext: Todd Zullinger
Message 2 of 24 in “gpg-interface: fix for gpgsm v2.3”
  1. gpg-interface: fix for gpgsm v2.3Fabian Stelzer, Feb 3, 2022
  2. Junio C HamanoFeb 3, 2022
  3. Todd ZullingerFeb 3, 2022
  4. Junio C HamanoFeb 3, 2022
  5. Todd ZullingerFeb 3, 2022
  6. Junio C HamanoFeb 3, 2022
  7. Fabian StelzerFeb 7, 2022
  8. Todd ZullingerFeb 7, 2022
  9. Fabian StelzerFeb 9, 2022
  10. Todd ZullingerFeb 9, 2022
  11. Fabian StelzerFeb 21, 2022
  12. Todd ZullingerFeb 23, 2022
  13. 2/3 t/lib-gpg: reload gpg components after updating trustlistFabian Stelzer, Feb 24, 2022
  14. 3/3 t/lib-gpg: kill all gpg components, not just gpg-agentFabian Stelzer, Feb 24, 2022
  15. 1/3 gpg-interface/gpgsm: fix for v2.3Fabian Stelzer, Feb 24, 2022
  16. Todd ZullingerFeb 28, 2022
  17. 1/3 gpg-interface/gpgsm: fix for v2.3Fabian Stelzer, Mar 2, 2022
  18. Junio C HamanoMar 2, 2022
  19. Fabian StelzerMar 3, 2022
  20. 1/3 gpg-interface/gpgsm: fix for v2.3Fabian Stelzer, Mar 4, 2022
  21. 3/3 t/lib-gpg: kill all gpg components, not just gpg-agentFabian Stelzer, Mar 4, 2022
  22. 2/3 t/lib-gpg: reload gpg components after updating trustlistFabian Stelzer, Mar 4, 2022
  23. 2/3 t/lib-gpg: reload gpg components after updating trustlistFabian Stelzer, Mar 2, 2022
  24. 3/3 t/lib-gpg: kill all gpg components, not just gpg-agentFabian Stelzer, Mar 2, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.