Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/cli/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,10 @@ export function resolveGpgSocketInfo(containerHome: string): GpgSocketInfo | nul
// Socket path is known but agent isn't running yet — start it once.
if (!agentStartAttempted) {
agentStartAttempted = true
spawnSync('gpg-agent', ['--daemon'], {
// Use gpgconf --launch rather than gpg-agent --daemon: on macOS the
// agent is managed by launchd and gpgconf is the correct way to
// ensure it is running without spawning a conflicting second instance.
spawnSync('gpgconf', ['--launch', 'gpg-agent'], {
encoding: 'utf-8',
timeout: 5_000,
stdio: ['ignore', 'ignore', 'ignore'],
Expand All @@ -913,7 +916,10 @@ export function resolveGpgSocketInfo(containerHome: string): GpgSocketInfo | nul
hostSocket,
containerSocket: `${containerHome}/.gnupg/S.gpg-agent`,
source: dir,
fingerprint: `${dir}:${hostSocket}`,
// Include the socket inode in the fingerprint so that if the host
// gpg-agent restarts (new socket inode, same path), the config hash
// changes and the sandbox is transparently restarted with the fresh socket.
fingerprint: `${dir}:${hostSocket}:${fs.statSync(hostSocket).ino}`,
}
} catch {
continue
Expand Down
Loading