Repository navigation
Let sudo -v validate against the passwordless sudo grant - #16223
omarchybot wants to merge 9 commits into
Conversation
Under sudo's default verifypw=all, one password-requiring entry anywhere in the policy is enough to make `sudo -v` prompt, so a user who enabled passwordless sudo could not validate credentials without a password. The installer's own admin grant is password-requiring, and package drop-ins add more, so the grant cannot be the only entry that carries NOPASSWD. The published grant now carries the sudoers default that makes validation read the grant instead of every other entry, and a grant published before that default existed is rewritten in place.
The default was unqualified, so publishing a grant for one account changed the credential validation of every account on the host, and displaced a verifypw setting an administrator had configured. The default now names the account the grant belongs to, and a file whose default names another account is not read as this command's grant.
The action was only reachable from inside the script, so the migration's call fell through to the user-facing arguments, valid_duration rejected it and the helper exited 1. That would have stopped omarchy-migrate on every machine that reached the migration and left every later migration pending. The action is dispatched now, and the test drives it through the executable and through the migration itself.
classify_generated_rule read a sudoers default naming someone other than the rule's account as an unreadable file (2) rather than foreign policy (1), so cleanup_all_locked stopped quarantining it and left the rule live. The file was read fine; it is simply not this command's grant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
Migrations run once per account, and this one ran sudo for every account to rewrite grants most of them do not have. An administrator with no grant was asked for a password to authorize nothing, and an account without sudo rights could never finish it, which leaves every later migration pending for that account. An account with an active grant runs sudo without a password, so checking --active first means the migration never prompts; each account's own grant is rewritten when that account's migrations run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
[Medium impact] The PR appears safe to merge; the remaining test coverage concern is non-blocking. Findings
SummaryLets generated passwordless grants support
No new actionable issues were found. Reviews (3) · Last reviewed commit: "Keep the grant-format migration pending ..." · Reviewed by Greptile |
| ( | ||
| source "$library" | ||
| enable_locked 1000 15 | ||
| head -1 "$(rule_file 1000)" | grep -qx 'Defaults:audituser verifypw = any' | ||
| tail -1 "$(rule_file 1000)" | grep -qxE 'audituser ALL=\(ALL\) NOTAFTER=[0-9]{14}Z NOPASSWD: ALL' | ||
| ) | ||
| pass "the published grant carries the sudoers default above its rule" |
There was a problem hiding this comment.
Credential validation remains untested
The new tests check the generated text but never run sudo -v. The shared fixture replaces sudo, and the existing native-policy check only tests command execution. A change that writes the expected text but still prompts could pass these checks.
Add a disposable integration test with both password-requiring policy and the generated grant. Check that sudo -n -v succeeds during the grant, leaves no usable credentials after revocation or expiry, and does not change another account's behavior.
Status, enable and disable always run the installed /usr/bin copy, but under a dev link the migration runs the checkout's helper, which can be newer than the package. Rewriting a grant there left it in a form the installed copy rejects as unreadable, so the user could not revoke a permanent grant until the package caught up. The upgrade now leaves grants alone unless the installed copy knows the upgrade action, and therefore reads both forms. The fixture points INSTALLED_SELF at a private copy so a test can stand in an older one. docs/passwordless-sudo.md now describes the default the grant carries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
Reviewed at 89816c1 against What was checked, on a disposable Omarchy worker running sudo 1.9.17p2, with a test account that has a password-requiring rule beside the grant:
Fixed on top, in 89816c1: status, enable and disable always run the installed The second opinion came from Codex Medium and muse-spark-1.3 (thinking high). Codex found the dev-link problem, and both found the missing docs sentence. Both also raised these, which were weighed and left unchanged:
Their second round on 89816c1 found nothing further. Independence is not guaranteed, since they can read this session. |
quattro no longer tests migrations (#16302): they run once and are frozen once they ship. The fixture branch these two tests drove the migration through went with that change, so they now fail on the merged tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…read it When the installed omarchy-sudo-passwordless predates the two-line grant, the upgrade skipped and returned success, so the migration was marked done and a permanent grant on a dev-linked machine kept the old form for good. It now fails, leaving the migration pending until the package catches up, as the migrations guide asks of one that cannot finish. The tests move into the existing lifecycle suite and keep only what fails without this change: the published default, the upgrade through the dispatch the migration uses, and the refusal under an older installed copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: muse-wonder High <noreply@meta.com>
|
The maintainer asked at the desk whether this is still needed now that Why it is still needed: #17000 adds What was checked, on a disposable Omarchy worker at the head merged with
Pushed:
The second opinion came from Codex Medium and muse-wonder (thinking high). Both concluded on their own reading that the fix is still needed after #17000, and both found the deferral bug and the test-rule problems fixed above. Their second round, on f030b57, found nothing further. Independence is not guaranteed, since they can read this session. Still open for the maintainer: |
Lets
sudo -vvalidate against the passwordless sudo grant.Under sudo's default
verifypw=all,sudo -vasks for a password unless every sudoers entry the user has carriesNOPASSWD. The installer's own admin rule (/etc/sudoers.d/04_<user>) requires a password, so a user who enabled passwordless sudo is still prompted by everysudo -v:omarchy-sudo-keepalive,omarchy-upgrade-to-quattro, and anything an agent runs. On a stock install with the grant enabled,sudo -n truesucceeds andsudo -n -vanswers "a password is required".omarchy-sudo-passwordlessnow publishes a sudoers default above the rule it already wrote:The default is scoped to the account that asked for the grant, so it changes nothing for any other account on the host, and it is removed with the grant file when the grant is revoked or expires. A successful
sudo -vunder the grant writes no timestamp, so validation never leaves cached credentials behind after a timed grant ends.The readers accept both the new two-line form and a grant published before the default existed. A file whose default names a different account than its rule is not this command's grant: status and expiry refuse it, and cleanup quarantines it as foreign policy under the generated prefix, as it does any other.
Grants published before the default existed are rewritten in place by a migration, keeping their rule and deadline. Migrations run once per account, so the migration only asks sudo to rewrite grants when the account running it holds an active grant, whose sudo needs no password; an account without a grant, or without sudo at all, finishes it without being asked to authorize anything, and each account's grant is rewritten when that account's migrations run.
This complements #15729, which fixes the
sudo -vin the quiet-boot migration for every passwordless setup, including hand-writtenNOPASSWDrules this change does not reach. That migration runs before this one, so it still needs #15729.Reviewed by Claude Opus 5.5 and Codex Medium.
Supersedes #16111 by @statick88, whose commits this carries unchanged, with the fixes above on top.