Skip to content

feat(closed-lid): install, detect and remove the pmset sudo rule - #58

Merged
scttbnsn merged 1 commit into
dev/m2from
feat/closed-lid-sudo-rule
Nov 2, 2026
Merged

scttbnsn merged 1 commit into
dev/m2from
feat/closed-lid-sudo-rule

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Second step of moving closed-lid mode off the root helper.

ClosedLidPermission manages /private/etc/sudoers.d/dilated, which allows only pmset -a disablesleep 0 and 1 for admin users. Install runs one fixed script through the admin prompt. It writes the rule to a temp file, checks it with visudo -cf, installs it as root:wheel 0444 and moves it into place, then runs visudo -c and deletes the file if that fails. Remove deletes the file and runs visudo -c again. Detection reports notInstalled, needsRepair, blocked, ready or notAdmin. Cancelling the prompt is its own outcome.

The in-app transport now backs off from 1s to a 30s cap while sudo refuses the command, instead of starting a failing sudo every second. It still fails closed and keeps retrying. That was a follow-up from the #57 review.

Nothing calls this yet. Settings and the CLI come in a later step. Tests use injected seams and never touch real sudo, osascript or /etc. visudo -cf runs on the rule written to a temp file.

…ck off permission retries

ClosedLidPermission owns the fixed /private/etc/sudoers.d/dilated rule, detects notInstalled, needsRepair, blocked, ready and notAdmin, and installs or removes it through an injected admin-prompt runner. The local transport tick loop now backs off from 1s to 30s while sudo refuses, still failed and still retrying.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 666b05df-bc1c-442f-be18-7709ba59206e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.11111% with 42 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Sources/DilatedCore/ClosedLidPermission.swift 48.10% 41 Missing ⚠️
.../DilatedUI/ClosedLid/LocalClosedLidTransport.swift 95.45% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttbnsn
scttbnsn merged commit 3e68c62 into dev/m2 Nov 2, 2026
2 of 4 checks passed
@scttbnsn
scttbnsn deleted the feat/closed-lid-sudo-rule branch November 2, 2026 16:36
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.

1 participant