Stop GPG agent before removing signature-verification home (#1273) · actions/setup-java@a78ec39 · GitHub
Skip to content

Commit a78ec39

Browse files
Copilotbrunoborges
andauthored
Stop GPG agent before removing signature-verification home (#1273)
* Initial plan * Stop GPG agent before verification home cleanup Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 97c5a5e commit a78ec39

6 files changed

Lines changed: 53 additions & 16 deletions

File tree

‎__tests__/gpg.test.ts‎

Lines changed: 22 additions & 5 deletions

‎dist/cleanup/index.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35832,13 +35832,16 @@ async function removeGpgHome(gpgHome) {
3583235832
if (!external_fs_.existsSync(resolvedGpgHome)) {
3583335833
return;
3583435834
}
35835+
await stopGpgAgent(resolvedGpgHome);
35836+
await lib_io/* rmRF */.Yz(resolvedGpgHome);
35837+
}
35838+
async function stopGpgAgent(gpgHome) {
3583535839
try {
35836-
await lib_exec/* exec */.m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
35840+
await lib_exec/* exec */.m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
3583735841
}
3583835842
catch {
3583935843
// gpgconf may be unavailable, but directory removal must still be attempted.
3584035844
}
35841-
await lib_io/* rmRF */.Yz(resolvedGpgHome);
3584235845
}
3584335846
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
3584435847
const signaturePath = await tc.downloadTool(signatureUrl);
@@ -35884,6 +35887,7 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
3588435887
], options);
3588535888
}
3588635889
finally {
35890+
await stopGpgAgent(gpgHome);
3588735891
await io.rmRF(signaturePath);
3588835892
await io.rmRF(gpgHome);
3588935893
}

‎dist/setup/220.index.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,16 @@ async function removeGpgHome(gpgHome) {
263263
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
264264
return;
265265
}
266+
await stopGpgAgent(resolvedGpgHome);
267+
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
268+
}
269+
async function stopGpgAgent(gpgHome) {
266270
try {
267-
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
271+
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
268272
}
269273
catch {
270274
// gpgconf may be unavailable, but directory removal must still be attempted.
271275
}
272-
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
273276
}
274277
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
275278
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
@@ -315,6 +318,7 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
315318
], options);
316319
}
317320
finally {
321+
await stopGpgAgent(gpgHome);
318322
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
319323
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
320324
}

‎dist/setup/463.index.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,16 @@ async function removeGpgHome(gpgHome) {
375375
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
376376
return;
377377
}
378+
await stopGpgAgent(resolvedGpgHome);
379+
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
380+
}
381+
async function stopGpgAgent(gpgHome) {
378382
try {
379-
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
383+
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
380384
}
381385
catch {
382386
// gpgconf may be unavailable, but directory removal must still be attempted.
383387
}
384-
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
385388
}
386389
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
387390
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
@@ -427,6 +430,7 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
427430
], options);
428431
}
429432
finally {
433+
await stopGpgAgent(gpgHome);
430434
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
431435
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
432436
}

‎dist/setup/81.index.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,16 @@ async function removeGpgHome(gpgHome) {
350350
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
351351
return;
352352
}
353+
await stopGpgAgent(resolvedGpgHome);
354+
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
355+
}
356+
async function stopGpgAgent(gpgHome) {
353357
try {
354-
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
358+
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
355359
}
356360
catch {
357361
// gpgconf may be unavailable, but directory removal must still be attempted.
358362
}
359-
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
360363
}
361364
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
362365
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
@@ -402,6 +405,7 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
402405
], options);
403406
}
404407
finally {
408+
await stopGpgAgent(gpgHome);
405409
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
406410
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
407411
}

‎src/gpg.ts‎

Lines changed: 7 additions & 3 deletions

0 commit comments

Comments
 (0)