Skip to content

Refuse inactive status while a reserved-prefix sudo rule is live - #13901

Open
Bartok9 wants to merge 1 commit into
omacom:quattrofrom
Bartok9:bartok9/passwordless-status-reserved-prefix
Open

Bartok9 wants to merge 1 commit into
omacom:quattrofrom
Bartok9:bartok9/passwordless-status-reserved-prefix

Conversation

@Bartok9

@Bartok9 Bartok9 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Test

bash test/shell.d/nopasswd-sudo-expiry-test.sh — new case: a 99-omarchy-nopasswd-jacob rule makes status_locked 1000 return 2 and does not remove the file. That case passed in an Ubuntu container. The later public-status assertion (status must not publish reusable authorization) also fails on unmodified quattro in that container, so it is not this change.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues remain.

Summary

The PR checks the reserved sudo-rule prefix before reporting inactive access.

  • Passwordless-sudo status checks other reserved rules before saying access is inactive.

Both earlier, unnumbered findings are fixed: the expired-grant path now checks the prefix, and the test removes its shared fixtures. No new actionable issues were found. This review used code inspection; no tests were run.

Reviews (3) · Last reviewed commit: "Refuse inactive status while a reserved-..." · Reviewed by Greptile

Comment thread bin/omarchy-sudo-passwordless Resolved
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified, with fixes pushed to your branch. Thanks @Bartok9, the bug is real: on current quattro, an account-named rule from the legacy writer (99-omarchy-nopasswd-<name>) that survives until the migration or the next boot makes __status return 3, so --disable prints "already DISABLED" while that rule still grants passwordless sudo.

What was pushed:

  • Merged quattro into the branch (518b501). Let users choose passwordless sudo duration #14435 rewrote the status paragraph in docs/passwordless-sudo.md, so the PR no longer merged. The resolution keeps both its text and your sentence.
  • The expired-grant path now runs the check too (de69137). An expired UID rule was cleaned up and reported as 3 without looking at the prefix, so the same legacy rule still read as no grant. status_locked now has a single exit that returns 3, and it goes through reserved_prefix_clear. This is the gap Greptile flagged.
  • Another account's grant no longer blocks this one (de69137, bc28eb3). As first written, any other file under the prefix made status 2, including another user's ordinary UID-named grant on a shared machine. That would leave them unable to enable or disable their own grant. Now a file is skipped only if its name is numeric, it is root-safe, it is recognised as a generated rule, and the account it names is not this one. A numeric name alone does not say whom the rule grants (01000, for example).
  • The test cleans up after itself and checks that the grant was active (status 0) before expiring it, so the expiry case cannot pass through the missing-rule path. It also covers another account's rule (status 3) and a numeric-named rule that names this account (status 2).

Checked on a disposable Omarchy worker at bc28eb3:

  • test/shell.d/nopasswd-sudo-expiry-test.sh fails on quattro (legacy rule gives 3) and passes on this head, 28/28.
  • Reverting each part of the fix makes it fail again, at the case that part covers.
  • ./test/cli and the 21 sudo and security shell tests all pass.

Second opinion: Codex Medium reviewed two rounds. The first found the two gaps in the numeric skip and the expiry test that are fixed above. The second found nothing open and agreed the change is proportionate; that agreement is not guaranteed to be independent.

Out of scope and left for the maintainer: when a live UID grant and a legacy rule coexist, status is 0, so --disable removes only the UID grant. enable_locked and expire_locked also do not look at foreign rules under the prefix.

This is now waiting on the maintainer.

@Bartok9

Bartok9 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — the expiry-path check and the contents-based skip for another account’s rule match the bug. Leaving the coexist case (live UID grant plus a legacy rule) for the maintainer is fine; this PR should stay scoped to refusing a false inactive status.

Ready for maintainer review at bc28eb3.

A missing UID-named grant is not confirmed inactive when the legacy writer left another rule under 99-omarchy-nopasswd-*.

Check the reserved prefix on every inactive status, not only a missing rule

An expired UID rule was removed and reported inactive without looking at the rest of the prefix, so a live legacy rule still read as no grant. Another account's UID-named rule is that account's grant, so it no longer turns this account's status into an error on a shared machine. The test removes its fixtures so later cases start from an empty sudoers.d.

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

Skip another account's rule only when its contents name that account

A numeric filename does not say whom the rule grants: a noncanonical 01000, or a UID reassigned while a grant was live, can still name this account. The expiry case now proves the grant was active before expiring it, so it cannot pass on the missing-rule path alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@Bartok9
Bartok9 force-pushed the bartok9/passwordless-status-reserved-prefix branch from bc28eb3 to 54a88cf Compare October 25, 2026 21:26
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 26, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-checked after the squash and rebase, @Bartok9. The fix's diff to bin/omarchy-sudo-passwordless, the doc and the test is the same as at bc28eb3. Only the code around it changed, so verification was re-run at this head.

Checked on disposable Omarchy workers at 54a88cf:

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) each traced every path into status_locked, including the --active indicator path and the listing shortcut in the interactive flow. Neither found a path that reports inactive or offers a grant without going through reserved_prefix_clear. Both found no defects and agreed the change is proportionate. This agreement is not guaranteed to be independent. Both also called it a defensible fail-closed choice that another account's legacy file gives status 2, until boot-time tmpfiles cleanup removes it.

Still for the maintainer, as before: whether a leftover legacy rule should block status until reboot or be migrated or removed, and the coexisting live-grant case noted earlier. This is waiting on the maintainer.

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

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants