{"thread":{"id":"46430","subject":"[PATCH] t: lib-gpg: flush gpg agent on startup","startedAt":"2017-07-20T16:58:28Z","lastAt":"2017-07-20T20:25:50Z","messageCount":4,"participants":["santiago@nyu.edu","Santiago Torres","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"324811","messageId":"20170720165814.30037-1-santiago@nyu.edu","threadId":"46430","inReplyTo":null,"subject":"[PATCH] t: lib-gpg: flush gpg agent on startup","fromName":"","fromEmail":"santiago@nyu.edu","sentAt":"2017-07-20T16:58:14Z","receivedAt":"2017-07-20T16:58:28Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"From: Santiago Torres <santiago@nyu.edu>\n\nWhen running gpg-relevant tests, a gpg-daemon is spawned for each\nGNUPGHOME used. This daemon may stay running after the test and cache\nfile descriptors for the trash directories, even after the trash\ndirectory is removed. This leads to ENOENT errors when attempting to\ncreate files if tests are run multiple times.\n\nAdd a cleanup script to force flushing the gpg-agent for that GNUPGHOME\n(if any) before setting up the GPG relevant-environment.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Santiago Torres <santiago@nyu.edu>\n---\n t/lib-gpg.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/t/lib-gpg.sh b/t/lib-gpg.sh\nindex ec2aa8f68..7a6c7ee6f 100755\n--- a/t/lib-gpg.sh\n+++ b/t/lib-gpg.sh\n@@ -31,6 +31,7 @@ then\n \t\tchmod 0700 ./gpghome &&\n \t\tGNUPGHOME=\"$(pwd)/gpghome\" &&\n \t\texport GNUPGHOME &&\n+\t\tgpgconf --kill gpg-agent 2>&1 >/dev/null\n \t\tgpg --homedir \"${GNUPGHOME}\" 2>/dev/null --import \\\n \t\t\t\"$TEST_DIRECTORY\"/lib-gpg/keyring.gpg &&\n \t\tgpg --homedir \"${GNUPGHOME}\" 2>/dev/null --import-ownertrust \\\n-- \n2.13.3\n\n"},{"id":"324813","messageId":"20170720170113.fvquowatpv4ms6if@LykOS.localdomain","threadId":"46430","inReplyTo":"20170720165814.30037-1-santiago@nyu.edu","subject":"Re: [PATCH] t: lib-gpg: flush gpg agent on startup","fromName":"Santiago Torres","fromEmail":"santiago@nyu.edu","sentAt":"2017-07-20T17:01:14Z","receivedAt":"2017-07-20T17:01:26Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"This is the patch that stemmed from [1].\n\nI tried to keep it simple and not noisy, alhtough it breaks the &&\nchain, it needs to be run right before the --import command. I also\ndecided to drop the switch chain in case that regression was to be\nintroduced in the future in other versions (hopefully gpgconf goes\nnowhere by then).\n\nI was able to test this on debian oldstable/stable and arch.\n\nCheers!\n-Santiago.\n\n[1] https://public-inbox.org/git/xmqqvampmnmv.fsf@gitster.mtv.corp.google.com/\n\nOn Thu, Jul 20, 2017 at 12:58:14PM -0400, santiago@nyu.edu wrote:\n> From: Santiago Torres <santiago@nyu.edu>\n> \n> When running gpg-relevant tests, a gpg-daemon is spawned for each\n> GNUPGHOME used. This daemon may stay running after the test and cache\n> file descriptors for the trash directories, even after the trash\n> directory is removed. This leads to ENOENT errors when attempting to\n> create files if tests are run multiple times.\n> \n> Add a cleanup script to force flushing the gpg-agent for that GNUPGHOME\n> (if any) before setting up the GPG relevant-environment.\n> \n> Helped-by: Junio C Hamano <gitster@pobox.com>\n> Signed-off-by: Santiago Torres <santiago@nyu.edu>\n> ---\n>  t/lib-gpg.sh | 1 +\n>  1 file changed, 1 insertion(+)\n> \n> diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh\n> index ec2aa8f68..7a6c7ee6f 100755\n> --- a/t/lib-gpg.sh\n> +++ b/t/lib-gpg.sh\n> @@ -31,6 +31,7 @@ then\n>  \t\tchmod 0700 ./gpghome &&\n>  \t\tGNUPGHOME=\"$(pwd)/gpghome\" &&\n>  \t\texport GNUPGHOME &&\n> +\t\tgpgconf --kill gpg-agent 2>&1 >/dev/null\n>  \t\tgpg --homedir \"${GNUPGHOME}\" 2>/dev/null --import \\\n>  \t\t\t\"$TEST_DIRECTORY\"/lib-gpg/keyring.gpg &&\n>  \t\tgpg --homedir \"${GNUPGHOME}\" 2>/dev/null --import-ownertrust \\\n> -- \n> 2.13.3\n> \n"},{"id":"324830","messageId":"xmqq379qlvzi.fsf@gitster.mtv.corp.google.com","threadId":"46430","inReplyTo":"20170720170113.fvquowatpv4ms6if@LykOS.localdomain","subject":"Re: [PATCH] t: lib-gpg: flush gpg agent on startup","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-07-20T20:00:17Z","receivedAt":"2017-07-20T20:00:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santiago Torres <santiago@nyu.edu> writes:\n\n> This is the patch that stemmed from [1].\n>\n> I tried to keep it simple and not noisy, alhtough it breaks the &&\n> chain, it needs to be run right before the --import command. I also\n> decided to drop the switch chain in case that regression was to be\n> introduced in the future in other versions (hopefully gpgconf goes\n> nowhere by then).\n\nI'm inclined to do\n\n\t...\n\texport GNUPGHOME &&\n\t( gpgconf --kill gpg-agent 2>&1 >/dev/null || : ) &&\n\tgpg --homedir ... --import ...\n\nImagine \"chmod 0777 ./gpghome\" failed and what happens. We skip the\npart that exports GNUPGHOME and attempts to kill gpg-agent as if\nnothing bad happened, and then we try to \"--import\".  At that point\nwe do not know what value GNUPGHOME has---are we clobbering the real\nkeychain the user who runs the test has?\n\nWith that \"run it but ignore the outcome even if we failed to.\", we\ndo not have to worry about any of that ;-)\n\n>\n> I was able to test this on debian oldstable/stable and arch.\n>\n> Cheers!\n> -Santiago.\n>\n> [1] https://public-inbox.org/git/xmqqvampmnmv.fsf@gitster.mtv.corp.google.com/\n>\n> On Thu, Jul 20, 2017 at 12:58:14PM -0400, santiago@nyu.edu wrote:\n>> From: Santiago Torres <santiago@nyu.edu>\n>> \n>> When running gpg-relevant tests, a gpg-daemon is spawned for each\n>> GNUPGHOME used. This daemon may stay running after the test and cache\n>> file descriptors for the trash directories, even after the trash\n>> directory is removed. This leads to ENOENT errors when attempting to\n>> create files if tests are run multiple times.\n>> \n>> Add a cleanup script to force flushing the gpg-agent for that GNUPGHOME\n>> (if any) before setting up the GPG relevant-environment.\n>> \n>> Helped-by: Junio C Hamano <gitster@pobox.com>\n>> Signed-off-by: Santiago Torres <santiago@nyu.edu>\n>> ---\n>>  t/lib-gpg.sh | 1 +\n>>  1 file changed, 1 insertion(+)\n>> \n>> diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh\n>> index ec2aa8f68..7a6c7ee6f 100755\n>> --- a/t/lib-gpg.sh\n>> +++ b/t/lib-gpg.sh\n>> @@ -31,6 +31,7 @@ then\n>>  \t\tchmod 0700 ./gpghome &&\n>>  \t\tGNUPGHOME=\"$(pwd)/gpghome\" &&\n>>  \t\texport GNUPGHOME &&\n>> +\t\tgpgconf --kill gpg-agent 2>&1 >/dev/null\n>>  \t\tgpg --homedir \"${GNUPGHOME}\" 2>/dev/null --import \\\n>>  \t\t\t\"$TEST_DIRECTORY\"/lib-gpg/keyring.gpg &&\n>>  \t\tgpg --homedir \"${GNUPGHOME}\" 2>/dev/null --import-ownertrust \\\n>> -- \n>> 2.13.3\n>> \n"},{"id":"324832","messageId":"20170720202543.qw7wbrz5nhvvqt47@LykOS.localdomain","threadId":"46430","inReplyTo":"xmqq379qlvzi.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] t: lib-gpg: flush gpg agent on startup","fromName":"Santiago Torres","fromEmail":"santiago@nyu.edu","sentAt":"2017-07-20T20:25:44Z","receivedAt":"2017-07-20T20:25:50Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"> With that \"run it but ignore the outcome even if we failed to.\", we\n> do not have to worry about any of that ;-)\n\nOh right! thanks for the suggestion! Let me re-roll...\n\nThanks,\n-Santiago.\n\n"}]}