Skip to content

Ask for the sudo password once per omarchy update - #13323

Merged
dhh merged 2 commits into
quattrofrom
fix/update-single-sudo-prompt
Sep 26, 2026
Merged

dhh merged 2 commits into
quattrofrom
fix/update-single-sudo-prompt

Conversation

@dhh

@dhh dhh commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #13319. Supersedes #13268 and #13321.

omarchy update asked for the sudo password on nearly every privileged command. The no-update wrapper covered the whole run on top of per-phase sudo -k revokes, and omarchy-update-stay-awake revoked on its own entry and exit. So no timestamp ever survived, and one update could prompt four times before the snapshot even finished.

What changes

  • One prompt. Right after confirmation, the update revokes any existing timestamp and runs sudo /usr/bin/true once, so the prompt always belongs to this update. It runs a command rather than sudo -v because under the default verifypw=all, -v prompts even with passwordless sudo enabled. A background keepalive runs sudo -n /usr/bin/true every minute until the update is done, so long downloads and builds never outlast the timestamp.
  • Shared by everything except AUR. Prune, snapshot, stay-awake, keyring, system packages, migrations, orphan removal, service restarts, the post-update hook, and mise all use that single authorization. Stay-awake sees OMARCHY_UPDATE_SUDO_SESSION=1 and leaves the timestamp to the update. Without a terminal, it reuses the authorization with non-interactive sudo instead of asking again through polkit. Run standalone, it still revokes on entry and exit.
  • AUR runs cold, last. PKGBUILDs are third-party code, so AUR updates move to after hooks and mise. The keepalive stops, the timestamp is revoked, and yay and any bare sudo a PKGBUILD runs use the no-update wrapper. An AUR install can still prompt, but it never caches. The timestamp is revoked again after AUR and on every exit.
  • Behaviour change: the post-update hook now runs before AUR updates instead of after. Otherwise the hook and mise would have needed a second prompt after the AUR revoke.

Trade-off

This deliberately relaxes the #9469 boundary for migrations, the post-update hook, and mise: they can reuse the update's authorization while it is live. AUR keeps the cold, command-scoped boundary. The authorization is created fresh by the update, and it lives inside the script(1) pty session. It is revoked before AUR and on every exit.

Standalone commands that keep their own cold boundary, such as omarchy-refresh-pacman and omarchy-remove-dev-env ocaml, still revoke if a user's post-update hook calls them. That is left as-is.

Channel switching still authorizes its own steps command by command. The update it hands off to then asks once for its own phases.

Review

Reviewed with Codex. Fixed from that review: the no-terminal polkit fallback inside an update, and a mock that let a cold sudo -n succeed. Also fixed: the passwordless-sudo prompt from sudo -v. Out of scope: -y still entering the orphan confirmation, which is an existing bug on quattro.

Tests

  • update-hook-security: asserts one sudo -v before any work, plain sudo with no revokes through mise, and a revoke before AUR. After it, only -N sudo or revokes, and a cold exit.
  • update-sequence: new order, with AUR after hooks and mise.
  • update-user-path / channel-sudo-boundary: the post-update hook and mise see the shared authorization; the pre-refresh hook stays cold.
  • update-stay-awake-security: new checks that the helper leaves an update's authorization alone, still revokes standalone, and reuses sudo instead of polkit without a terminal.
  • Fixture: the mock sudo refuses a cold -n call, as the real one does.
  • Fixture: bare sudo in bin/ now resolves to the mock, so no test can reach the host's sudo.
  • Full ./test/shell shows the same 4 files failing as on a clean quattro (kernel-headers migration, kernel migration, passwordless-grant lifecycle, unowned system paths). The keepalive was also exercised on its own: it refreshed, stopped cleanly, and left no orphaned sleep.

🤖 Generated with Claude Code

dhh and others added 2 commits September 26, 2026 15:05
Every sudo call in omarchy update prompted, because the no-update wrapper
covered the whole run on top of per-phase revokes, and stay-awake revoked
the timestamp on its own entry and exit. A single update could ask four
times before the snapshot finished (#13319).

Authorize once, right after confirmation, starting from a revoked
timestamp so the prompt always belongs to this update. A background
keepalive refreshes it until the update is done. Prune, snapshot,
stay-awake, keyring, system packages, migrations, orphan removal, service
restarts, the post-update hook, and mise all share that authorization.

AUR builds run third-party PKGBUILD code, so they move to the end and run
cold: the keepalive stops, the timestamp is revoked, and yay and any bare
sudo use the no-update wrapper. The timestamp is revoked again after AUR
and on every exit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ition

Authorize by running a command instead of sudo -v. Under the default
verifypw=all, -v prompts even when passwordless sudo is enabled, which
would have added a prompt those users never had.

Inside an update without a terminal, stay-awake now reuses the update's
authorization with a non-interactive sudo instead of asking again through
polkit. It falls back to polkit only if that authorization is gone.

The test sudo refuses a cold non-interactive call, as the real one does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh dhh added the ready Good to merge label Sep 26, 2026
@dhh
dhh merged commit e1614f2 into quattro Sep 26, 2026
@dhh
dhh deleted the fix/update-single-sudo-prompt branch September 26, 2026 13:31
@emirb emirb added this to the 4.5 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Good to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy update asks for the sudo password on every privileged command

2 participants