Enforce real timeouts on gpg subprocess calls #62
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
mfer/gpg.go:52-53runs every gpg invocation as:exec.CommandContextis the right call, butcontext.Background()neverexpires, so no deadline is actually enforced. All five gpg call sites
route through
runGPGand inherit this:gpgSign,gpgExportPublicKey,gpgGetKeyFingerprint,gpgExtractPubKeyFingerprint,gpgVerify.This is a real hang risk, not a theoretical one:
gpgblocks indefinitelywaiting on a passphrase prompt, a stalled
gpg-agent, or entropy. In anon-interactive context — CI, a cron job, a server embedding this library —
that is an unbounded hang with no way out.
It is also the most likely cause of the intermittent test-suite timeout
described in the
script/testissue: the gpg tests generate real RSA-2048keys, and a slow keygen has nothing to bound it.
Definition of done
to why that value was chosen.
context.Contextin scope propagate itinstead of manufacturing a fresh background context, so cancellation from
above works.
invocation timed out and which operation it was — not a bare
context deadline exceeded.the timeout error rather than hanging. Use a stub or a deliberately
slow fake binary; do not add a multi-second sleep to the suite.
make checkpasses.TODO.mdupdated in the same commit.Implementation requirements
go testtimeout. The productioncode path is what is unbounded.
gpg.CommandContextsends
os.Interrupt/Killto the direct child only; ifgpghas spawnedor delegated to a
gpg-agent, the child may not die. If a process groupkill is needed, do it properly and explain in a comment.
//nolinton one of these exec sites referring to a"non-cancellable signing exec". If signing genuinely cannot be cancelled,
that claim needs to be justified in a comment or withdrawn — it should not
survive as an unexplained suppression.
robustness fix, not a redesign. Replacing gpg with pure-Go crypto is a
separate, owner-gated decision and is out of scope here.
(closes #62).