Commit 954cb2a
Don't leak gpg-agent when signing with gpg
mkosi signs SHA256SUMS by running gpg, which autostarts a gpg-agent if none is
running. As mkosi's sandbox has no PID namespace, that agent daemonizes and is
leaked when the sandbox goes away. Unprivileged this is worse, as the leaked
agents hold systemd-nsresourced dynamic UID ranges and eventually exhaust the
pool (builds then fail with io.systemd.NamespaceResource.NoDynamicRange), but
the process is leaked either way.
Shut the agent down after signing, but only if we started it: an agent the
user already had running for their GNUPGHOME (e.g. their own ~/.gnupg) is left
untouched. gpg-connect-agent exits 0 even with no agent, so detect a running
agent by its GETINFO output rather than the exit code.
The gpg signing integration test also starts its own agent via
gpg --quick-gen-key; kill that too (its GNUPGHOME is a throwaway directory).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent db3e38e commit 954cb2a
2 files changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2565 | 2565 | | |
2566 | 2566 | | |
2567 | 2567 | | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
2568 | 2583 | | |
2569 | 2584 | | |
2570 | 2585 | | |
2571 | 2586 | | |
2572 | 2587 | | |
2573 | 2588 | | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
2574 | 2597 | | |
2575 | 2598 | | |
2576 | 2599 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| |||
0 commit comments