Skip to content

fix(gpg): set no-autostart so agent forwarding survives gpg calls - #789

Closed
skevetter wants to merge 2 commits into
mainfrom
fix/gpg-forward-no-autostart
Closed

fix(gpg): set no-autostart so agent forwarding survives gpg calls#789
skevetter wants to merge 2 commits into
mainfrom
fix/gpg-forward-no-autostart

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Summary

GPG agent forwarding into the container never worked reliably: gpg -K was empty and signing failed with No secret key, even though the host agent held the keys and the socket was forwarded.

Root cause

configureGPGAgent points the container's gpg at the forwarded host socket via a symlink (~/.gnupg/S.gpg-agent → /tmp/S.gpg-agent → …/S.gpg-agent.extra), but SetupGpgConf only wrote use-agent to gpg.conf — never no-autostart. Whenever gpg ran while the forwarded socket was momentarily unavailable, gpg autostarted a local gpg-agent, which replaced the symlink with an empty local socket. From that point every gpg call hit the empty local agent, permanently breaking forwarding for the session.

Fix

Write no-autostart (GnuPG's recommended setting for agent forwarding) so gpg only ever uses the forwarded agent and never spawns a local one. Directives are written idempotently, and appended safely when the existing gpg.conf has no trailing newline.

Validation

Reproduced the fixed state in a live container (forwarded socket + no-autostart):

  • gpg -K now lists the secret keys.
  • A commit is GPG-signed and verifies: Good signature from "Samuel K <skevetter@pm.me>".

Unit tests cover directive presence, idempotency, existing-directive preservation, and the newline-less-file edge case.

GPG agent forwarding into the container points gpg at the forwarded host
socket via a symlink (~/.gnupg/S.gpg-agent). Setup wrote only "use-agent"
to gpg.conf, never "no-autostart". Whenever gpg ran while the forwarded
socket was momentarily unavailable, it autostarted a local gpg-agent,
which replaced the symlink with an empty local socket and permanently
broke forwarding for the session — gpg -K showed nothing and signing
failed with "No secret key".

Write no-autostart (the GnuPG-recommended setting for agent forwarding)
so gpg only ever uses the forwarded agent. Verified end to end: with the
forwarded socket and no-autostart, gpg -K lists the secret keys and a
commit is GPG-signed and verifies.
@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit cbb5de2
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a67e62152cb3a0008ed764f

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 683e512d-9a3e-44ad-ae02-737f2429d4db

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit cbb5de2
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a67e6219280280008da9567

@skevetter

Copy link
Copy Markdown
Contributor Author

Superseded by #790, which consolidates all GPG agent-forwarding fixes (no-autostart + supervised self-healing forward).

@skevetter skevetter closed this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant