diff --git a/__tests__/gpg.test.ts b/__tests__/gpg.test.ts index cf72803e..d8f14494 100644 --- a/__tests__/gpg.test.ts +++ b/__tests__/gpg.test.ts @@ -76,13 +76,26 @@ describe('gpg tests', () => { expect(exec.exec).toHaveBeenNthCalledWith( 1, 'gpg', - ['--batch', '--import', expect.stringContaining('public-key.asc')], + [ + '--homedir', + expect.any(String), + '--batch', + '--import', + expect.stringContaining('public-key.asc') + ], expect.objectContaining({silent: true}) ); expect(exec.exec).toHaveBeenNthCalledWith( 2, 'gpg', - ['--batch', '--verify', '/tmp/jdk.tar.gz.sig', '/tmp/jdk.tar.gz'], + [ + '--homedir', + expect.any(String), + '--batch', + '--verify', + '/tmp/jdk.tar.gz.sig', + '/tmp/jdk.tar.gz' + ], expect.objectContaining({silent: true}) ); }); diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 18ac0774..c32109fd 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -52374,13 +52374,12 @@ function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) { } throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`); } - const env = Object.assign(Object.assign({}, process.env), { GNUPGHOME: gpgHome }); try { const publicKeyFile = path.join(gpgHome, 'public-key.asc'); fs.writeFileSync(publicKeyFile, publicKeyContent, { encoding: 'utf-8' }); - const options = { silent: true, env }; - yield exec.exec('gpg', ['--batch', '--import', publicKeyFile], options); - yield exec.exec('gpg', ['--batch', '--verify', signaturePath, archivePath], options); + const options = { silent: true }; + yield exec.exec('gpg', ['--homedir', gpgHome, '--batch', '--import', publicKeyFile], options); + yield exec.exec('gpg', ['--homedir', gpgHome, '--batch', '--verify', signaturePath, archivePath], options); } finally { yield io.rmRF(signaturePath); diff --git a/dist/setup/index.js b/dist/setup/index.js index 4c999d79..f8d12d87 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -81154,13 +81154,12 @@ function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) { } throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`); } - const env = Object.assign(Object.assign({}, process.env), { GNUPGHOME: gpgHome }); try { const publicKeyFile = path.join(gpgHome, 'public-key.asc'); fs.writeFileSync(publicKeyFile, publicKeyContent, { encoding: 'utf-8' }); - const options = { silent: true, env }; - yield exec.exec('gpg', ['--batch', '--import', publicKeyFile], options); - yield exec.exec('gpg', ['--batch', '--verify', signaturePath, archivePath], options); + const options = { silent: true }; + yield exec.exec('gpg', ['--homedir', gpgHome, '--batch', '--import', publicKeyFile], options); + yield exec.exec('gpg', ['--homedir', gpgHome, '--batch', '--verify', signaturePath, archivePath], options); } finally { yield io.rmRF(signaturePath); diff --git a/src/gpg.ts b/src/gpg.ts index 650476a1..1086fdce 100644 --- a/src/gpg.ts +++ b/src/gpg.ts @@ -78,16 +78,18 @@ export async function verifyPackageSignature( }` ); } - const env = {...process.env, GNUPGHOME: gpgHome}; - try { const publicKeyFile = path.join(gpgHome, 'public-key.asc'); fs.writeFileSync(publicKeyFile, publicKeyContent, {encoding: 'utf-8'}); - const options: ExecOptions = {silent: true, env}; - await exec.exec('gpg', ['--batch', '--import', publicKeyFile], options); + const options: ExecOptions = {silent: true}; await exec.exec( 'gpg', - ['--batch', '--verify', signaturePath, archivePath], + ['--homedir', gpgHome, '--batch', '--import', publicKeyFile], + options + ); + await exec.exec( + 'gpg', + ['--homedir', gpgHome, '--batch', '--verify', signaturePath, archivePath], options ); } finally {