fix(install): drop the sudo ticket on every exit path - #304
Open
locol23 wants to merge 1 commit into
Open
Conversation
The sudo keep-alive (landed in 847a34b) only revoked the cached ticket on the success path before the final exec; a fatal git-clone exit or Ctrl-C left it alive until the OS timeout. Extract sudo_cleanup(), trap it on EXIT (with INT/TERM converted to exits so the trap fires), keep it in the EXIT slot when the ECC/skills tmpdir traps replace it, and stop the refresh loop with a warning if sudo -n starts failing mid-run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens the sudo keep-alive introduced in #303. Previously the cached sudo ticket was only revoked on the success path (just before the final
exec zsh -l), so a fatal git-clone exit or Ctrl-C mid-run left passwordless sudo open until the OS timeout, and the keep-alive loop could linger up to 60s as an orphan.sudo_cleanup()(kills the keep-alive loop +sudo -k) and trap it onEXITINT/TERMtoexit 130/exit 143— untrapped fatal signals skip theEXITtrap, and trapping the signal directly to a non-exiting handler would make the script survive Ctrl-Csudo_cleanupin theEXITslot when the ECC / mattpocock-skills tmpdir traps replace it (trapreplaces, it does not stack)sudo -n truestarts failing mid-run instead of silently looping foreversudo_cleanupmanually before the finalexec, which bypasses all trapsFindings from a code-review pass on the original keep-alive (1 HIGH: cleanup unreachable on non-success exit paths; 1 MEDIUM: silent refresh-failure loop).
Test plan
bash -n install.shexit 1, cleanup runs, exit code is preserved, no orphan loop survives./install.shrun: one password prompt at start; afterwardssudo -n trueprompts again (ticket revoked) andpgrep -f 'sudo -n true'is empty🤖 Generated with Claude Code