{"thread":{"id":"57206","subject":"[PATCH] t/gpg: simplify test for unknown key","startedAt":"2022-01-07T09:14:45Z","lastAt":"2022-01-14T03:52:29Z","messageCount":10,"participants":["Fabian Stelzer","Junio C Hamano","Ævar Arnfjörð Bjarmason","Taylor Blau","Josh Steadmon"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"445693","messageId":"20220107091432.581225-1-fs@gigacodes.de","threadId":"57206","inReplyTo":null,"subject":"[PATCH] t/gpg: simplify test for unknown key","fromName":"Fabian Stelzer","fromEmail":"fs@gigacodes.de","sentAt":"2022-01-07T09:14:32Z","receivedAt":"2022-01-07T09:14:45Z","isPatch":true,"sender":{"key":"fs@gigacodes.de","avatar":"https://avatars.githubusercontent.com/u/564858?v=4"},"body":"To test for a key that is completely unknown to the keyring we need one\nto sign the commit with. This was done by generating a new key and not\nadd it into the keyring. To avoid the key generation overhead and\nproblems where GPG did hang in CI during it, switch GNUPGHOME to an\nempty directory instead, therefore making all used keys unknown for this\nsingle `verify-commit` call.\n\nReported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nSigned-off-by: Fabian Stelzer <fs@gigacodes.de>\n---\nThis was reported by Ævar in <211222.86ilvhpbl0.gmgdl@evledraar.gmail.com>.\nJust using an empty keyring / gpg homedir should achieve the same effect and \nkeeps the stress of generating a gpg key out of the CI.\n\n\n t/t7510-signed-commit.sh | 22 ++--------------------\n 1 file changed, 2 insertions(+), 20 deletions(-)\n\ndiff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh\nindex 9882b69ae2..2d38580847 100755\n--- a/t/t7510-signed-commit.sh\n+++ b/t/t7510-signed-commit.sh\n@@ -71,25 +71,7 @@ test_expect_success GPG 'create signed commits' '\n \tgit tag eleventh-signed $(cat oid) &&\n \techo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid &&\n \ttest_line_count = 1 oid &&\n-\tgit tag twelfth-signed-alt $(cat oid) &&\n-\n-\tcat >keydetails <<-\\EOF &&\n-\tKey-Type: RSA\n-\tKey-Length: 2048\n-\tSubkey-Type: RSA\n-\tSubkey-Length: 2048\n-\tName-Real: Unknown User\n-\tName-Email: unknown@git.com\n-\tExpire-Date: 0\n-\t%no-ask-passphrase\n-\t%no-protection\n-\tEOF\n-\tgpg --batch --gen-key keydetails &&\n-\techo 13 >file && git commit -a -S\"unknown@git.com\" -m thirteenth &&\n-\tgit tag thirteenth-signed &&\n-\tDELETE_FINGERPRINT=$(gpg -K --with-colons --fingerprint --batch unknown@git.com | grep \"^fpr\" | head -n 1 | awk -F \":\" \"{print \\$10;}\") &&\n-\tgpg --batch --yes --delete-secret-keys $DELETE_FINGERPRINT &&\n-\tgpg --batch --yes --delete-keys unknown@git.com\n+\tgit tag twelfth-signed-alt $(cat oid)\n '\n \n test_expect_success GPG 'verify and show signatures' '\n@@ -129,7 +111,7 @@ test_expect_success GPG 'verify and show signatures' '\n '\n \n test_expect_success GPG 'verify-commit exits failure on unknown signature' '\n-\ttest_must_fail git verify-commit thirteenth-signed 2>actual &&\n+\tGNUPGHOME=./empty_home test_must_fail git verify-commit initial 2>actual &&\n \t! grep \"Good signature from\" actual &&\n \t! grep \"BAD signature from\" actual &&\n \tgrep -q -F -e \"No public key\" -e \"public key not found\" actual\n-- \n2.33.1\n\n"},{"id":"445751","messageId":"xmqqmtk76x2n.fsf@gitster.g","threadId":"57206","inReplyTo":"20220107091432.581225-1-fs@gigacodes.de","subject":"Re: [PATCH] t/gpg: simplify test for unknown key","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-07T21:43:44Z","receivedAt":"2022-01-07T21:43:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fabian Stelzer <fs@gigacodes.de> writes:\n\n> To test for a key that is completely unknown to the keyring we need one\n> to sign the commit with. This was done by generating a new key and not\n> add it into the keyring. To avoid the key generation overhead and\n> problems where GPG did hang in CI during it, switch GNUPGHOME to an\n> empty directory instead, therefore making all used keys unknown for this\n> single `verify-commit` call.\n>\n> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Signed-off-by: Fabian Stelzer <fs@gigacodes.de>\n> ---\n> This was reported by Ævar in <211222.86ilvhpbl0.gmgdl@evledraar.gmail.com>.\n> Just using an empty keyring / gpg homedir should achieve the same effect and \n> keeps the stress of generating a gpg key out of the CI.\n\nClever.  Losing lines of code and gaining more stability in CI is a\ngreat thing.\n\n>\n>\n>  t/t7510-signed-commit.sh | 22 ++--------------------\n>  1 file changed, 2 insertions(+), 20 deletions(-)\n>\n> diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh\n> index 9882b69ae2..2d38580847 100755\n> --- a/t/t7510-signed-commit.sh\n> +++ b/t/t7510-signed-commit.sh\n> @@ -71,25 +71,7 @@ test_expect_success GPG 'create signed commits' '\n>  \tgit tag eleventh-signed $(cat oid) &&\n>  \techo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid &&\n>  \ttest_line_count = 1 oid &&\n> -\tgit tag twelfth-signed-alt $(cat oid) &&\n> -\n> -\tcat >keydetails <<-\\EOF &&\n> -\tKey-Type: RSA\n> -\tKey-Length: 2048\n> -\tSubkey-Type: RSA\n> -\tSubkey-Length: 2048\n> -\tName-Real: Unknown User\n> -\tName-Email: unknown@git.com\n> -\tExpire-Date: 0\n> -\t%no-ask-passphrase\n> -\t%no-protection\n> -\tEOF\n> -\tgpg --batch --gen-key keydetails &&\n> -\techo 13 >file && git commit -a -S\"unknown@git.com\" -m thirteenth &&\n> -\tgit tag thirteenth-signed &&\n> -\tDELETE_FINGERPRINT=$(gpg -K --with-colons --fingerprint --batch unknown@git.com | grep \"^fpr\" | head -n 1 | awk -F \":\" \"{print \\$10;}\") &&\n> -\tgpg --batch --yes --delete-secret-keys $DELETE_FINGERPRINT &&\n> -\tgpg --batch --yes --delete-keys unknown@git.com\n> +\tgit tag twelfth-signed-alt $(cat oid)\n>  '\n>  \n>  test_expect_success GPG 'verify and show signatures' '\n> @@ -129,7 +111,7 @@ test_expect_success GPG 'verify and show signatures' '\n>  '\n>  \n>  test_expect_success GPG 'verify-commit exits failure on unknown signature' '\n> -\ttest_must_fail git verify-commit thirteenth-signed 2>actual &&\n> +\tGNUPGHOME=./empty_home test_must_fail git verify-commit initial 2>actual &&\n>  \t! grep \"Good signature from\" actual &&\n>  \t! grep \"BAD signature from\" actual &&\n>  \tgrep -q -F -e \"No public key\" -e \"public key not found\" actual\n"},{"id":"445931","messageId":"220111.86r19exl4z.gmgdl@evledraar.gmail.com","threadId":"57206","inReplyTo":"20220107091432.581225-1-fs@gigacodes.de","subject":"Re: [PATCH] t/gpg: simplify test for unknown key","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-01-11T16:56:50Z","receivedAt":"2022-01-11T17:00:53Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Jan 07 2022, Fabian Stelzer wrote:\n\n> To test for a key that is completely unknown to the keyring we need one\n> to sign the commit with. This was done by generating a new key and not\n> add it into the keyring. To avoid the key generation overhead and\n> problems where GPG did hang in CI during it, switch GNUPGHOME to an\n> empty directory instead, therefore making all used keys unknown for this\n> single `verify-commit` call.\n>\n> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Signed-off-by: Fabian Stelzer <fs@gigacodes.de>\n> ---\n> This was reported by Ævar in <211222.86ilvhpbl0.gmgdl@evledraar.gmail.com>.\n> Just using an empty keyring / gpg homedir should achieve the same effect and \n> keeps the stress of generating a gpg key out of the CI.\n\nThanks, it would be great to have this in and before v2.35.0. I've run\ninto several boxes (on the GCC farm) that hang without this patch.\n\n>  t/t7510-signed-commit.sh | 22 ++--------------------\n>  1 file changed, 2 insertions(+), 20 deletions(-)\n>\n> diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh\n> index 9882b69ae2..2d38580847 100755\n> --- a/t/t7510-signed-commit.sh\n> +++ b/t/t7510-signed-commit.sh\n> @@ -71,25 +71,7 @@ test_expect_success GPG 'create signed commits' '\n>  \tgit tag eleventh-signed $(cat oid) &&\n>  \techo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid &&\n>  \ttest_line_count = 1 oid &&\n> -\tgit tag twelfth-signed-alt $(cat oid) &&\n> -\n> -\tcat >keydetails <<-\\EOF &&\n> -\tKey-Type: RSA\n> -\tKey-Length: 2048\n> -\tSubkey-Type: RSA\n> -\tSubkey-Length: 2048\n> -\tName-Real: Unknown User\n> -\tName-Email: unknown@git.com\n> -\tExpire-Date: 0\n> -\t%no-ask-passphrase\n> -\t%no-protection\n> -\tEOF\n> -\tgpg --batch --gen-key keydetails &&\n> -\techo 13 >file && git commit -a -S\"unknown@git.com\" -m thirteenth &&\n> -\tgit tag thirteenth-signed &&\n> -\tDELETE_FINGERPRINT=$(gpg -K --with-colons --fingerprint --batch unknown@git.com | grep \"^fpr\" | head -n 1 | awk -F \":\" \"{print \\$10;}\") &&\n> -\tgpg --batch --yes --delete-secret-keys $DELETE_FINGERPRINT &&\n> -\tgpg --batch --yes --delete-keys unknown@git.com\n> +\tgit tag twelfth-signed-alt $(cat oid)\n>  '\n>  \n>  test_expect_success GPG 'verify and show signatures' '\n> @@ -129,7 +111,7 @@ test_expect_success GPG 'verify and show signatures' '\n>  '\n>  \n>  test_expect_success GPG 'verify-commit exits failure on unknown signature' '\n> -\ttest_must_fail git verify-commit thirteenth-signed 2>actual &&\n> +\tGNUPGHOME=./empty_home test_must_fail git verify-commit initial 2>actual &&\n\nBefore I noticed this thread (I looked at\nhttps://lore.kernel.org/git/20211230111038.jtoqytdhkilv2732@fs/ first,\nand the In-Reply-To chain wasn't connected) I was about to submit\nexactly this patch for you but with:\n\n\t-       test_must_fail git verify-commit thirteenth-signed 2>actual &&\n\t+       test_must_fail env GNUPGHOME=\"$GNUPGHOME_NOT_USED\" git verify-commit initial 2>actual &&\n\nBoth of those are probably a good thing to do here. I.e.:\n\n 1. Didn't we have portability issues with \"ENV_VAR=VALUE shell_function ...\" ?\n 2. You're pointing to a nonexisting ./empty_home, but shouldn't we use\n    $GNUPGHOME_NOT_USED? The existing \"show unknown signature with custom format\"\n    test in the same file does that.\n"},{"id":"445934","messageId":"20220111172621.qwupg4oyosvpeguu@fs","threadId":"57206","inReplyTo":"220111.86r19exl4z.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH] t/gpg: simplify test for unknown key","fromName":"Fabian Stelzer","fromEmail":"fs@gigacodes.de","sentAt":"2022-01-11T17:26:21Z","receivedAt":"2022-01-11T17:26:31Z","isPatch":true,"sender":{"key":"fs@gigacodes.de","avatar":"https://avatars.githubusercontent.com/u/564858?v=4"},"body":"On 11.01.2022 17:56, Ævar Arnfjörð Bjarmason wrote:\n>\n>On Fri, Jan 07 2022, Fabian Stelzer wrote:\n>\n>> To test for a key that is completely unknown to the keyring we need one\n>> to sign the commit with. This was done by generating a new key and not\n>> add it into the keyring. To avoid the key generation overhead and\n>> problems where GPG did hang in CI during it, switch GNUPGHOME to an\n>> empty directory instead, therefore making all used keys unknown for this\n>> single `verify-commit` call.\n>>\n>> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> Signed-off-by: Fabian Stelzer <fs@gigacodes.de>\n>> ---\n>> This was reported by Ævar in <211222.86ilvhpbl0.gmgdl@evledraar.gmail.com>.\n>> Just using an empty keyring / gpg homedir should achieve the same effect and\n>> keeps the stress of generating a gpg key out of the CI.\n>\n>Thanks, it would be great to have this in and before v2.35.0. I've run\n>into several boxes (on the GCC farm) that hang without this patch.\n>\n>>  t/t7510-signed-commit.sh | 22 ++--------------------\n>>  1 file changed, 2 insertions(+), 20 deletions(-)\n>>\n>> diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh\n>> index 9882b69ae2..2d38580847 100755\n>> --- a/t/t7510-signed-commit.sh\n>> +++ b/t/t7510-signed-commit.sh\n>> @@ -71,25 +71,7 @@ test_expect_success GPG 'create signed commits' '\n>>  \tgit tag eleventh-signed $(cat oid) &&\n>>  \techo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid &&\n>>  \ttest_line_count = 1 oid &&\n>> -\tgit tag twelfth-signed-alt $(cat oid) &&\n>> -\n>> -\tcat >keydetails <<-\\EOF &&\n>> -\tKey-Type: RSA\n>> -\tKey-Length: 2048\n>> -\tSubkey-Type: RSA\n>> -\tSubkey-Length: 2048\n>> -\tName-Real: Unknown User\n>> -\tName-Email: unknown@git.com\n>> -\tExpire-Date: 0\n>> -\t%no-ask-passphrase\n>> -\t%no-protection\n>> -\tEOF\n>> -\tgpg --batch --gen-key keydetails &&\n>> -\techo 13 >file && git commit -a -S\"unknown@git.com\" -m thirteenth &&\n>> -\tgit tag thirteenth-signed &&\n>> -\tDELETE_FINGERPRINT=$(gpg -K --with-colons --fingerprint --batch unknown@git.com | grep \"^fpr\" | head -n 1 | awk -F \":\" \"{print \\$10;}\") &&\n>> -\tgpg --batch --yes --delete-secret-keys $DELETE_FINGERPRINT &&\n>> -\tgpg --batch --yes --delete-keys unknown@git.com\n>> +\tgit tag twelfth-signed-alt $(cat oid)\n>>  '\n>>\n>>  test_expect_success GPG 'verify and show signatures' '\n>> @@ -129,7 +111,7 @@ test_expect_success GPG 'verify and show signatures' '\n>>  '\n>>\n>>  test_expect_success GPG 'verify-commit exits failure on unknown signature' '\n>> -\ttest_must_fail git verify-commit thirteenth-signed 2>actual &&\n>> +\tGNUPGHOME=./empty_home test_must_fail git verify-commit initial 2>actual &&\n>\n>Before I noticed this thread (I looked at\n>https://lore.kernel.org/git/20211230111038.jtoqytdhkilv2732@fs/ first,\n>and the In-Reply-To chain wasn't connected)\n\nYeah, sorry about that. I forgot to add the in-reply-to :/\n\n>I was about to submit\n>exactly this patch for you but with:\n>\n>\t-       test_must_fail git verify-commit thirteenth-signed 2>actual &&\n>\t+       test_must_fail env GNUPGHOME=\"$GNUPGHOME_NOT_USED\" git verify-commit initial 2>actual &&\n>\n>Both of those are probably a good thing to do here. I.e.:\n>\n> 1. Didn't we have portability issues with \"ENV_VAR=VALUE shell_function ...\" ?\n\nI'm not good with portability stuff and trust your judgment on this.\n\n> 2. You're pointing to a nonexisting ./empty_home, but shouldn't we use\n>    $GNUPGHOME_NOT_USED? The existing \"show unknown signature with custom format\"\n>    test in the same file does that.\n\nI was not aware of $GNUPGHOME_NOT_USED but it is used in a similar fashion.  \nHowever it is set to the old value of $GNUPGHOME before we change it in \nlib-gpg.sh which seems wrong to me. Wouldn't it then just pick up the gpg \nhomedir of whatever the test environment has?\nUsing the variable is good, but i would set it to a known empty directory \nor?\n"},{"id":"445958","messageId":"Yd3dQkGxG1hbjThH@nand.local","threadId":"57206","inReplyTo":"20220111172621.qwupg4oyosvpeguu@fs","subject":"Re: [PATCH] t/gpg: simplify test for unknown key","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-01-11T19:40:50Z","receivedAt":"2022-01-11T19:40:52Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Tue, Jan 11, 2022 at 06:26:21PM +0100, Fabian Stelzer wrote:\n> > I was about to submit\n> > exactly this patch for you but with:\n> >\n> > \t-       test_must_fail git verify-commit thirteenth-signed 2>actual &&\n> > \t+       test_must_fail env GNUPGHOME=\"$GNUPGHOME_NOT_USED\" git verify-commit initial 2>actual &&\n> >\n> > Both of those are probably a good thing to do here. I.e.:\n> >\n> > 1. Didn't we have portability issues with \"ENV_VAR=VALUE shell_function ...\" ?\n>\n> I'm not good with portability stuff and trust your judgment on this.\n\nSee [1] and the ensuing discussion for a good summary. Re-reading\nthat thread and comparing it with what we see with `git grep\ntest_must_fail env -- t` confirms that that\n\n    test_must_fail env GNUPGHOME=\"$GNUPGHOME_NOT_USED\" git verify-commit ...\n\nis the right thing to do here.\n\n> > 2. You're pointing to a nonexisting ./empty_home, but shouldn't we use\n> >    $GNUPGHOME_NOT_USED? The existing \"show unknown signature with custom format\"\n> >    test in the same file does that.\n>\n> I was not aware of $GNUPGHOME_NOT_USED but it is used in a similar fashion.\n> However it is set to the old value of $GNUPGHOME before we change it in\n> lib-gpg.sh which seems wrong to me. Wouldn't it then just pick up the gpg\n> homedir of whatever the test environment has?\n> Using the variable is good, but i would set it to a known empty directory\n> or?\n\nYeah, t7510 captures the value of $GNUPGHOME as $GNUPGHOME_NOT_USED\nbefore sourcing t/lib-gpg.sh. So long as nobody else has tampered with\n$GNUPGHOME, they should get `$TRASH_DIRECTORY/gnupg-home-not-used`.\n\nBut I'm less certain that there isn't somebody accidentally ignoring the\n\"not-used\" portion of the test $GNUPGHOME ;).\n\nAnd I don't think that reasoning through it all is that worthwhile, so\nI'm fine with what a much more direct ./empty_home here.\n\nThanks,\nTaylor\n\n[1]: https://lore.kernel.org/git/xmqqbn3l3kmc.fsf@gitster.mtv.corp.google.com/\n"},{"id":"445987","messageId":"20220112121037.6gvmvbjyovzuhb2j@fs","threadId":"57206","inReplyTo":"Yd3dQkGxG1hbjThH@nand.local","subject":"Re: [PATCH] t/gpg: simplify test for unknown key","fromName":"Fabian Stelzer","fromEmail":"fs@gigacodes.de","sentAt":"2022-01-12T12:10:37Z","receivedAt":"2022-01-12T12:10:42Z","isPatch":true,"sender":{"key":"fs@gigacodes.de","avatar":"https://avatars.githubusercontent.com/u/564858?v=4"},"body":"On 11.01.2022 14:40, Taylor Blau wrote:\n>On Tue, Jan 11, 2022 at 06:26:21PM +0100, Fabian Stelzer wrote:\n>> > I was about to submit\n>> > exactly this patch for you but with:\n>> >\n>> > \t-       test_must_fail git verify-commit thirteenth-signed 2>actual &&\n>> > \t+       test_must_fail env GNUPGHOME=\"$GNUPGHOME_NOT_USED\" git verify-commit initial 2>actual &&\n>> >\n>> > Both of those are probably a good thing to do here. I.e.:\n>> >\n>> > 1. Didn't we have portability issues with \"ENV_VAR=VALUE shell_function ...\" ?\n>>\n>> I'm not good with portability stuff and trust your judgment on this.\n>\n>See [1] and the ensuing discussion for a good summary. Re-reading\n>that thread and comparing it with what we see with `git grep\n>test_must_fail env -- t` confirms that that\n>\n>    test_must_fail env GNUPGHOME=\"$GNUPGHOME_NOT_USED\" git verify-commit ...\n>\n>is the right thing to do here.\n\nThanks. Interesting\n\n>\n>> > 2. You're pointing to a nonexisting ./empty_home, but shouldn't we use\n>> >    $GNUPGHOME_NOT_USED? The existing \"show unknown signature with custom format\"\n>> >    test in the same file does that.\n>>\n>> I was not aware of $GNUPGHOME_NOT_USED but it is used in a similar fashion.\n>> However it is set to the old value of $GNUPGHOME before we change it in\n>> lib-gpg.sh which seems wrong to me. Wouldn't it then just pick up the gpg\n>> homedir of whatever the test environment has?\n>> Using the variable is good, but i would set it to a known empty directory\n>> or?\n>\n>Yeah, t7510 captures the value of $GNUPGHOME as $GNUPGHOME_NOT_USED\n>before sourcing t/lib-gpg.sh. So long as nobody else has tampered with\n>$GNUPGHOME, they should get `$TRASH_DIRECTORY/gnupg-home-not-used`.\n>\n>But I'm less certain that there isn't somebody accidentally ignoring the\n>\"not-used\" portion of the test $GNUPGHOME ;).\n>\n>And I don't think that reasoning through it all is that worthwhile, so\n>I'm fine with what a much more direct ./empty_home here.\n>\n\nYeah. I checked the other uses of GNUPGHOME and the NOT_USED seems fine (and \nmore consistent with existing tests). So let's use it.\nEven if some other (non gpg related) test accidentally pollutes this gpghome \nit would surely not do so with the actual signing key used in the test \nsuite.\n\nThanks, I'll send a new patch in a second\n\n>Thanks,\n>Taylor\n>\n>[1]: https://lore.kernel.org/git/xmqqbn3l3kmc.fsf@gitster.mtv.corp.google.com/\n"},{"id":"445988","messageId":"20220112120757.874714-1-fs@gigacodes.de","threadId":"57206","inReplyTo":"20220107091432.581225-1-fs@gigacodes.de","subject":"[PATCH v2] t/gpg: simplify test for unknown key","fromName":"Fabian Stelzer","fromEmail":"fs@gigacodes.de","sentAt":"2022-01-12T12:07:57Z","receivedAt":"2022-01-12T12:10:49Z","isPatch":true,"sender":{"key":"fs@gigacodes.de","avatar":"https://avatars.githubusercontent.com/u/564858?v=4"},"body":"To test for a key that is completely unknown to the keyring we need one\nto sign the commit with. This was done by generating a new key and not\nadd it into the keyring. To avoid the key generation overhead and\nproblems where GPG did hang in CI during it, switch GNUPGHOME to the\nempty $GNUPGHOME_NOT_USED instead, therefore making all used keys unknown \nfor this single `verify-commit` call.\n\nReported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nSigned-off-by: Fabian Stelzer <fs@gigacodes.de>\n---\n t/t7510-signed-commit.sh | 22 ++--------------------\n 1 file changed, 2 insertions(+), 20 deletions(-)\n\ndiff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh\nindex 9882b69ae2..8593b7e3cb 100755\n--- a/t/t7510-signed-commit.sh\n+++ b/t/t7510-signed-commit.sh\n@@ -71,25 +71,7 @@ test_expect_success GPG 'create signed commits' '\n \tgit tag eleventh-signed $(cat oid) &&\n \techo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid &&\n \ttest_line_count = 1 oid &&\n-\tgit tag twelfth-signed-alt $(cat oid) &&\n-\n-\tcat >keydetails <<-\\EOF &&\n-\tKey-Type: RSA\n-\tKey-Length: 2048\n-\tSubkey-Type: RSA\n-\tSubkey-Length: 2048\n-\tName-Real: Unknown User\n-\tName-Email: unknown@git.com\n-\tExpire-Date: 0\n-\t%no-ask-passphrase\n-\t%no-protection\n-\tEOF\n-\tgpg --batch --gen-key keydetails &&\n-\techo 13 >file && git commit -a -S\"unknown@git.com\" -m thirteenth &&\n-\tgit tag thirteenth-signed &&\n-\tDELETE_FINGERPRINT=$(gpg -K --with-colons --fingerprint --batch unknown@git.com | grep \"^fpr\" | head -n 1 | awk -F \":\" \"{print \\$10;}\") &&\n-\tgpg --batch --yes --delete-secret-keys $DELETE_FINGERPRINT &&\n-\tgpg --batch --yes --delete-keys unknown@git.com\n+\tgit tag twelfth-signed-alt $(cat oid)\n '\n \n test_expect_success GPG 'verify and show signatures' '\n@@ -129,7 +111,7 @@ test_expect_success GPG 'verify and show signatures' '\n '\n \n test_expect_success GPG 'verify-commit exits failure on unknown signature' '\n-\ttest_must_fail git verify-commit thirteenth-signed 2>actual &&\n+\ttest_must_fail env GNUPGHOME=\"$GNUPGHOME_NOT_USED\" git verify-commit initial 2>actual &&\n \t! grep \"Good signature from\" actual &&\n \t! grep \"BAD signature from\" actual &&\n \tgrep -q -F -e \"No public key\" -e \"public key not found\" actual\n-- \n2.34.1\n\n"},{"id":"446048","messageId":"Yd8kfgEq+EOMSc2C@nand.local","threadId":"57206","inReplyTo":"20220112120757.874714-1-fs@gigacodes.de","subject":"Re: [PATCH v2] t/gpg: simplify test for unknown key","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-01-12T18:57:02Z","receivedAt":"2022-01-12T18:57:22Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Jan 12, 2022 at 01:07:57PM +0100, Fabian Stelzer wrote:\n> To test for a key that is completely unknown to the keyring we need one\n> to sign the commit with. This was done by generating a new key and not\n> add it into the keyring. To avoid the key generation overhead and\n> problems where GPG did hang in CI during it, switch GNUPGHOME to the\n> empty $GNUPGHOME_NOT_USED instead, therefore making all used keys unknown\n> for this single `verify-commit` call.\n>\n> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Signed-off-by: Fabian Stelzer <fs@gigacodes.de>\n\nReviewed-by: Taylor Blau <me@ttaylorr.com>\n"},{"id":"446057","messageId":"xmqqv8you5b9.fsf@gitster.g","threadId":"57206","inReplyTo":"20220112120757.874714-1-fs@gigacodes.de","subject":"Re: [PATCH v2] t/gpg: simplify test for unknown key","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-12T19:23:06Z","receivedAt":"2022-01-12T19:23:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fabian Stelzer <fs@gigacodes.de> writes:\n\n> To test for a key that is completely unknown to the keyring we need one\n> to sign the commit with. This was done by generating a new key and not\n> add it into the keyring. To avoid the key generation overhead and\n> problems where GPG did hang in CI during it, switch GNUPGHOME to the\n> empty $GNUPGHOME_NOT_USED instead, therefore making all used keys unknown \n> for this single `verify-commit` call.\n>\n> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Signed-off-by: Fabian Stelzer <fs@gigacodes.de>\n> ---\n\nThe original one is already in 'next' so I'll revert the merge and\nqueue this one instead.\n\nWe could turn this into incremental and apply it on the original\none, which may give us a chance to highlight this common mistake\nof using a single-shot environment with shell functions, but let's\nnot bother.\n\nThanks.\n\n\n>  t/t7510-signed-commit.sh | 22 ++--------------------\n>  1 file changed, 2 insertions(+), 20 deletions(-)\n>\n> diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh\n> index 9882b69ae2..8593b7e3cb 100755\n> --- a/t/t7510-signed-commit.sh\n> +++ b/t/t7510-signed-commit.sh\n> @@ -71,25 +71,7 @@ test_expect_success GPG 'create signed commits' '\n>  \tgit tag eleventh-signed $(cat oid) &&\n>  \techo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid &&\n>  \ttest_line_count = 1 oid &&\n> -\tgit tag twelfth-signed-alt $(cat oid) &&\n> -\n> -\tcat >keydetails <<-\\EOF &&\n> -\tKey-Type: RSA\n> -\tKey-Length: 2048\n> -\tSubkey-Type: RSA\n> -\tSubkey-Length: 2048\n> -\tName-Real: Unknown User\n> -\tName-Email: unknown@git.com\n> -\tExpire-Date: 0\n> -\t%no-ask-passphrase\n> -\t%no-protection\n> -\tEOF\n> -\tgpg --batch --gen-key keydetails &&\n> -\techo 13 >file && git commit -a -S\"unknown@git.com\" -m thirteenth &&\n> -\tgit tag thirteenth-signed &&\n> -\tDELETE_FINGERPRINT=$(gpg -K --with-colons --fingerprint --batch unknown@git.com | grep \"^fpr\" | head -n 1 | awk -F \":\" \"{print \\$10;}\") &&\n> -\tgpg --batch --yes --delete-secret-keys $DELETE_FINGERPRINT &&\n> -\tgpg --batch --yes --delete-keys unknown@git.com\n> +\tgit tag twelfth-signed-alt $(cat oid)\n>  '\n>  \n>  test_expect_success GPG 'verify and show signatures' '\n> @@ -129,7 +111,7 @@ test_expect_success GPG 'verify and show signatures' '\n>  '\n>  \n>  test_expect_success GPG 'verify-commit exits failure on unknown signature' '\n> -\ttest_must_fail git verify-commit thirteenth-signed 2>actual &&\n> +\ttest_must_fail env GNUPGHOME=\"$GNUPGHOME_NOT_USED\" git verify-commit initial 2>actual &&\n>  \t! grep \"Good signature from\" actual &&\n>  \t! grep \"BAD signature from\" actual &&\n>  \tgrep -q -F -e \"No public key\" -e \"public key not found\" actual\n"},{"id":"446198","messageId":"YeDzZ1utGGc2ifrC@google.com","threadId":"57206","inReplyTo":"20220107091432.581225-1-fs@gigacodes.de","subject":"Re: [PATCH] t/gpg: simplify test for unknown key","fromName":"Josh Steadmon","fromEmail":"steadmon@google.com","sentAt":"2022-01-14T03:52:07Z","receivedAt":"2022-01-14T03:52:29Z","isPatch":true,"sender":{"key":"steadmon@google.com","avatar":"https://avatars.githubusercontent.com/u/2654920?v=4"},"body":"On 2022.01.07 10:14, Fabian Stelzer wrote:\n> To test for a key that is completely unknown to the keyring we need one\n> to sign the commit with. This was done by generating a new key and not\n> add it into the keyring. To avoid the key generation overhead and\n> problems where GPG did hang in CI during it, switch GNUPGHOME to an\n> empty directory instead, therefore making all used keys unknown for this\n> single `verify-commit` call.\n> \n> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Signed-off-by: Fabian Stelzer <fs@gigacodes.de>\n> ---\n> This was reported by Ævar in <211222.86ilvhpbl0.gmgdl@evledraar.gmail.com>.\n> Just using an empty keyring / gpg homedir should achieve the same effect and \n> keeps the stress of generating a gpg key out of the CI.\n\nLooks good to me.\n\nReviewed-by: Josh Steadmon <steadmon@google.com>\n"}]}