Repository navigation
Invalidate the sudo timestamp when the quattro upgrader exits - #15295
nekomario28 wants to merge 2 commits into
Conversation
[Medium impact] The PR appears safe to merge, with no new actionable issues found. SummaryThe Quattro upgrader now clears cached sudo authorization during cleanup.
Reviews (3) · Last reviewed commit: "Let the keepalive finish its refresh bef..." · Reviewed by Greptile |
c341892 to
e11371d
Compare
The upgrade authenticates sudo once and keeps the timestamp fresh with a background keepalive. cleanup_on_exit stops the keepalive, but the refreshed timestamp stays valid for the sudo timeout, so the upgrade's authorization outlives the script and whatever runs right afterwards inherits it. Invalidate the timestamp in cleanup_on_exit, as omarchy update does on every exit, and assert it in the upgrade shell test.
e11371d to
075effc
Compare
|
Addressed in 075effc: the behavioural case now skips the logged |
Cleanup killed the keepalive loop and then ran sudo -k, but killing the loop's shell leaves a `sudo -n true` already in flight running as an orphan, and that refresh can land after the revoke and re-validate the timestamp. On a worker with real sudo and the 60s sleep shortened, authorization survived the upgrader's exit in 26 of 200 runs. The keepalive now traps TERM the way omarchy update's does: bash holds the trap until the foreground refresh finishes, and the sleep runs under wait so it is interrupted at once. Cleanup waits for the loop before revoking, so sudo -k is the last word. The same race harness then leaked in 0 of 200 runs. The test now runs the script's own keepalive against a sudo stub whose refresh marks its start and then holds until sudo -k is logged, or for a second if cleanup is waiting on it. The fixture exits only once a refresh is in flight, the check waits for that refresh to log, and sudo -k must be the last call. Without the wait, or with the old loop, the refresh logs after the revoke and the test fails. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @nekomario28. The problem is real, and the fix holds once one more race is closed. I pushed that fix as 6906a3a. Reproduced. On a worker built from the Omarchy ISO, I ran the upgrader's own trap, keepalive and What I changed. Cleanup killed the keepalive loop and then ran Tests. Second opinion. Codex Medium reviewed it in four rounds. It agreed the problem was real and proportionately fixed. It raised the keepalive race, which I had asked it to check, so treat that as agreement rather than an independent find; I then confirmed the race with real sudo. In later rounds it pointed out twice that the test's timing could let a regression slip through, and both are fixed. Its last round, on this head, found nothing. Its independence from this review is not guaranteed. Both of Greptile's earlier comments are addressed at this head. It is waiting on the maintainer. |
|
Thanks @nekomario28. I took another look because this no longer merges with What changed on The test. The conflict is in What still holds. The mechanism is sound. With the keepalive's TERM trap and the Second opinion. Codex Medium and muse-wonder (via pi, thinking high) both reviewed it against current This is waiting on the maintainer. My recommendation is to close it as superseded by #17000, unless they want revocation back for the upgrader as a deliberate exception. |
omarchy-upgrade-to-quattroauthenticates sudo once and keeps the timestamp fresh with a background keepalive for the whole run.cleanup_on_exitstops that keepalive, but the refreshed timestamp stays valid for the sudo timeout, so the upgrade's authorization outlives the script and whatever runs right afterwards inherits it.omarchy updateinvalidates the timestamp on every exit (end_update_authorization); the upgrader should do the same.This invalidates the timestamp in
cleanup_on_exit, guarded to the non-root path that starts the keepalive, and asserts it intest/shell.d/upgrade-to-quattro-test.sh.Test:
bash test/shell.d/upgrade-to-quattro-test.shpasses (31 checks); with thesudo -kline reverted, the new assertion fails.