Skip to content

fix(update): share one sudo authorization across first-party phases - #13268

Closed
ekollof wants to merge 2 commits into
omacom:quattrofrom
ekollof:fix/scoped-update-sudo-caching
Closed

ekollof wants to merge 2 commits into
omacom:quattrofrom
ekollof:fix/scoped-update-sudo-caching

Conversation

@ekollof

@ekollof ekollof commented Sep 25, 2026 •

Copy link
Copy Markdown

Every sudo call in omarchy update prompts for a password, because the no-update wrapper is installed globally at startup (35b318e) on top of per-phase revokes: no timestamp can ever be recorded, so nothing can be reused.

Caching sudo covers prune, snapshot, keyring, pacman, orphan removal, and service restarts. Migrations, AUR builds, hooks, and mise authenticate with --no-update, so a prompt there does not publish a reusable timestamp.

  • bin/omarchy-update: check-only for --no-update support at startup instead of a global wrapper install. The sleep inhibitor is told the update owns the timestamp, so it does not sudo -k. Migrations run between two revokes, with the no-update wrapper first on PATH. AUR, hooks, and mise stay cold behind the wrapper.
  • bin/omarchy-update-stay-awake: a direct run still revokes on entry and exit. From the update it only authenticates the inhibitor with sudo -N.
  • test/shell.d/update-hook-security-test.sh: caching sudo before the migration boundary, sudo -N only for the migration itself, caching sudo again for orphan removal, and no -N before yay outside that boundary.
  • test/shell.d/update-lock-test.sh: an update-owned inhibitor leaves a pre-seeded timestamp in place. A direct run still starts cold.
  • docs/update-process.md: describe the two cached spans and the cold migration boundary.

Verified: update-hook-security, update-user-path, update-sequence, update-lock, and update-stay-awake-security.

@shawnyeager

Copy link
Copy Markdown
Contributor

Filed the failure this pull request describes: #13319. Reproduced on omarchy-dev 4.0.0.r2304.g7b336b1-1. The 07:28 update log asks four times before snapshot cleanup (paccache, snapper list-configs, snapper create, snapper cleanup) and never finishes. The diagnosis here matches that: the global no-update wrapper plus the opening sudo -k means a successful prompt writes no timestamp.

The patch does not hold up against the r2304 scripts.

omarchy-update-stay-awake start runs inside the span this treats as one authorization. It sudo -ks on entry, execs /usr/bin/sudo -N -b, and sudo -ks again on exit. Those clears are account-wide, so the ticket from prune and snapshot dies there, the inhibitor prompt is not cached, and keyring or pacman prompts again. This diff does not change that script.

omarchy-migrate stays on caching sudo. Migrations 1789095456, 1789310715, 1789764927, and 1790017600 run mise or install a hook, and a migration sudo refreshes the timestamp for anything that migration started. That is the reuse #9469 closed. The doc edit in this pull request still says historical migrations mix user-controlled code with later privileged repairs.

test/shell.d/update-hook-security-test.sh stubs the steps and only asserts that sudo -N is absent before yay, so it stays green with both of those in place.

Caching sudo belongs on prune, snapshot, keyring, pacman, orphan removal, and service restart. The sudo -k and the no-update wrapper belong at omarchy-migrate, and stay-awake has to stop revoking a timestamp it did not create.

@shawnyeager

Copy link
Copy Markdown
Contributor

The fix for the repeated update prompts is #13321, tracked in #13319.

That pull request keeps the cached sudo only through the fixed helpers before migrations, then revokes and installs the no-update wrapper at omarchy-migrate. It also stops omarchy-update-stay-awake start from clearing a timestamp it did not create. This pull request still does both of those.

The sleep inhibitor revoked on entry and exit, which cleared the timestamp
prune and snapshot had just created. Direct runs still revoke; omarchy-update
marks the timestamp as its own so the inhibitor only authenticates with -N.

Migrations can run mise or install hooks, so they now start from a cold
cache behind the no-update wrapper and revoke again before orphan removal.
@ekollof

ekollof commented Sep 26, 2026

Copy link
Copy Markdown
Author

Pushed 79b937a7 after the comment above, which was against the previous head.

Stay-awake no longer clears the update's timestamp. omarchy-update sets OMARCHY_UPDATE_OWNS_SUDO before omarchy-update-stay-awake start, and in that mode the helper only authenticates the inhibitor with sudo -N. A direct run still revokes on entry and exit. Prune, snapshot, keyring, and pacman therefore keep the timestamp that start used to drop.

Migrations are the cold boundary. The timestamp is revoked, omarchy-migrate runs with the no-update wrapper first on PATH, and the timestamp is revoked again before orphan removal. A migration sudo authorizes that command and cannot publish a credential. Orphan removal and service restarts then use caching sudo again, which is the split from the earlier review (caching sudo on those two phases, wrapper and sudo -k at omarchy-migrate).

#13321 keeps the wrapper on for the rest of the run, including orphan removal and service restarts. This branch does not: those two phases are after the second revoke and use a normal sudo. Happy to move the boundary to match #13321 if that is the one maintainers want.

update-hook-security-test.sh now calls sudo from the migration and orphan stubs and checks that -N appears only inside the migration span. update-lock-test.sh checks that an update-owned stop leaves a pre-seeded timestamp in place.

@dhh

dhh commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for digging into this. Closing in favor of #13323, which makes omarchy update ask for the sudo password once and reuse it for every phase except AUR updates. AUR now runs last, with no saved password, through the no-update wrapper.

@dhh dhh closed this Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants