Skip to content

Let sudo -v validate against the passwordless sudo grant - #16111

Closed
statick88 wants to merge 3 commits into
omacom:quattrofrom
statick88:fix/passwordless-sudo-verifypw
Closed

statick88 wants to merge 3 commits into
omacom:quattrofrom
statick88:fix/passwordless-sudo-verifypw

Conversation

@statick88

@statick88 statick88 commented Oct 20, 2026 •

Copy link
Copy Markdown

Lets sudo -v validate against the passwordless sudo grant.

Under sudo's default verifypw=all, sudo -v asks for a password unless
every entry the user has in sudoers carries NOPASSWD. The installer's
own admin grant (/etc/sudoers.d/04_<user>) is password-requiring, and
package drop-ins such as 50-asdcontrol add more, so a user who enabled
passwordless sudo could not validate their credentials without a password.
omarchy-update already works around this by authorizing with sudo true
instead of sudo -v.

Measured on a machine with the grant enabled:

$ sudo -n -v
sudo: a password is required
$ sudo -n true            # the grant itself works

Removing only 50-asdcontrol leaves the failure, removing only
04_<user> leaves it too, and removing both makes sudo -v succeed. The
grant cannot be the only passwordless entry, so the fix belongs to the
command that publishes the grant.

omarchy-sudo-passwordless now publishes a sudoers default above the rule
it already wrote:

Defaults:audituser verifypw = any
audituser ALL=(ALL) NOPASSWD: ALL

The default is scoped to the account that asked for the grant. An
unqualified Defaults line would change the rule for every account on the
host and displace a verifypw setting an administrator had configured; a
file whose default names another account is not read as this command's
grant. A grant published before the default existed keeps working, and a
migration rewrites it in place with the default it is missing.

The grant file is removed when the grant is revoked or expires, so the
default goes with it and leaves the policy it changed exactly as it was.

Relates to omacom/omarchy-pkgs#970, where the drop-in that was blamed is shipped.

Tested with test/shell.d/passwordless-sudo-verifypw-test.sh, which pins the
published policy, the account the default is scoped to, the readback of a
grant published before the default existed, and the upgrade path. The
existing passwordless sudo suites still pass unchanged.

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.
@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previously reported migration failure is fixed.

Summary

The PR adds account-scoped verifypw = any to passwordless sudo grants and upgrades existing generated grants without changing their rules or deadlines.

  • Passwordless sudo grants let sudo -v validate against their rule.

Reviews (2) · Last reviewed commit: "Reach the grant upgrade through the comm..." · Reviewed by Greptile

Comment thread bin/omarchy-sudo-passwordless Resolved
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.
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for this, @statick88. The diagnosis holds. omabot could not push to statick88/omarchy-mac (the push was refused with a 403), so the pull request continues on a branch in this repository with your three commits unchanged and two fixes on top.

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:

  • With the grant as quattro writes it, sudo -n true succeeds and sudo -n -v answers "a password is required". After this branch's migration rewrites it, and for a timed grant published by __enable, sudo -n -v succeeds. After sudo -v under the grant and then revoking it, password-requiring sudo is refused again, so no cached credential outlives the grant.
  • passwordless-sudo-verifypw-test.sh, nopasswd-sudo-expiry-test.sh, passwordless-sudo-indicator-test.sh, passwordless-grant-lifecycle-test.sh and ./test/cli pass. The full ./test/shell has seven failures (ascii, background reload and clone, About animation, i18n, lock budget, runtime smoke) that fail identically on the base commit, plus one flaky FD-leak check that passes on both when run alone.

Fixed on top:

  • classify_generated_rule returned 2 (unreadable) for a readable file whose default names a different account than its rule, so cleanup_all_locked left that rule live instead of quarantining it. It now returns 1, like any other foreign policy under the prefix, with a test.
  • The migration ran sudo for every account. An administrator without a grant was asked for a password to authorize nothing, and an account without sudo could never finish it, which leaves its later migrations pending. It now runs the upgrade only when --active says the account holds a grant. The migration test now asserts that the rewrite happens, and a new test asserts that an account without sudo finishes without it.

Both findings came from the second opinion, Codex Medium, and were reproduced on the worker before they were fixed. Its second round on the fixes found nothing further to change; independence is not guaranteed, since it can read this session. This is related to, not a replacement for, #15729.

Continued in #16223.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants