Repository navigation
Fix disabled detection, add provenance and per-action privileges - #3
Merged
Merged
Conversation
launchctl print-disabled prints `=> disabled` since macOS 13, not `=> true`, so the disabled set was always empty: no service ever showed as disabled and the enable/disable toggle could only ever plan `disable`. Parse both wordings. Privileges were decided per service, conflating launchd scope with file ownership. An agent in /Library/LaunchAgents is root-owned but runs in the caller's gui domain, so every action on it was blocked for nothing. Elevation is now computed per axis at discovery time and per action at plan time; what genuinely needs root is prefixed with `sudo`, shown in full at the prompt, and run with the TUI suspended so the password reaches the real terminal. Also adds provenance classification (homebrew, user-plist, mise, nix, vendor-app, system, runtime-only) from signals already in memory, closing the gap where every plist-less job was lumped into one bucket. Other fixes found along the way: - no panic hook, so any panic left the shell in raw mode on the alt screen - tail_file seeked to an arbitrary byte offset then read_to_string, failing on any log whose 32KiB boundary cut a codepoint - actions ran on the UI thread, freezing the TUI for the length of a slow `brew services` - a panicking refresh worker disabled background refresh for the whole session - `brew services list --json` (0.9s of a 1.1s pass) polled every 3s; it now has its own TTL, bypassed after an action - width specifiers were ignored in `list` output, misaligning two columns
A plist that fails lint stayed in ~/Library/LaunchAgents: it surfaced as a broken service on the next refresh, and the "already exists" guard then blocked the user from retrying with the same label. Also locks the invariant between CreateField::editable and current_value_mut, whose unreachable!() arm depends on the two lists agreeing.
The row carried label, confidence, change hint and evidence at once: 129 characters worst case, truncated below 120 columns. The change hint is generic per provenance kind, so it moves to the status line when the origin row is selected, which is the mechanism the other detail rows already use. Evidence, which is what actually varies per service, stays in the row. Worst case is now 63 characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1
Closes #2
disablednever workedlaunchctl print-disabledprints=> disabledsince macOS 13, not=> true. The disabled set was therefore always empty, with a chain of consequences: no service ever showed asdisabled, and sinceapply_disabledfell through toenabled = Some(true)for everything, the toggle could only ever plandisable— a disabled service could not be re-enabled from the UI at all.Verified on macOS 26.4.1: 0 lines match
=> true, 16 match=> disabledacrossgui/user/system. Both wordings are now accepted; 10 disabled services surface on the test machine where there were structurally zero.Privileges are per action, not per service (#1)
The issue reported that admin services are blocked. The diagnosis was only half right:
safety_for_scopetagged bothGlobalAgentandSystemDaemonasAdminRequired, but launchd scope and file ownership are independent axes. An agent in/Library/LaunchAgentsis root-owned on disk yet runs in the caller'sgui/<uid>domain —launchctl kickstart gui/501/<label>needs no privileges whatsoever. Launchdeck was blocking itself for nothing.ElevationNeeds { runtime, plist_write, plist_remove }is now computed at discovery from the real uid/mode of the plist and its directory, and resolved per action at plan time. Concretely, on/Library/LaunchAgents/us.zoom.updater.plist: start/stop need nothing, delete needs root.What genuinely needs root is prefixed with
sudo --, shown in full at the confirmation prompt, then run with the TUI suspended sosudoprompts on the real terminal. The command stays an argument list — never a shell string — and the password never passes through the process.osascriptandSMJobBlesswere rejected: the first breaks over SSH and reintroduces a shell-quoting surface, the second needs a signed bundle.Verified end to end against
system/org.wireshark.ChmodBPF: prompt, execution, terminal restored.Provenance (#2)
Origin { kind, confidence, evidence }classified from signals already in memory — no extra subprocess. Ordering is the design: a nix-darwin daemon sits in/Library/LaunchDaemonslike any vendor helper, so the/nix/storecommand path has to win over the directory it lives in.Kinds:
homebrew,user-plist,mise,nix,vendor-app,system,runtime-only,unknown. Rendered as anoriginrow in the detail modal with its evidence, anORIGINcolumn inlaunchdeck list, and indexed by search. Selecting the row puts the change hint in the status line.On the test machine: 8 homebrew (matching exactly the 8 brew formulas), 21 user-plist, 9 vendor-app, 5 runtime-only, 1045 system, 0 unknown.
This also fixes a real gap: every plist-less job used to be lumped into
ProtectedVendorregardless of what it actually was.Other defects found along the way
terminal.drawleft the shell in raw mode on the alternate screen.tail_fileseeked to an arbitrary byte offset thenread_to_string. Any log whose 32 KiB boundary cut a codepoint — or any non-UTF-8 log — made the log view fail outright. Now reads bytes, decodes lossily, and drops the half-line the seek created.brew servicesfroze the whole TUI. Unprivileged actions moved to a worker; elevated ones stay inline becausesudoneeds the terminal.refresh_in_progresswas never reset. Now bounded by a timeout.brew services list --jsonpolled every 3 s — 0.9 s of a 1.1 s inventory pass, permanently, for state that only changes when someone runs brew. Own TTL, bypassed after an action.Displayimpls that write straight to the formatter, misaligning two columns oflaunchdeck list.plutil -lintstayed on disk. It reappeared as a broken service on the next refresh, and the "already exists" guard then blocked recreating it with the same label — a stuck state around a file the user never knew was written.Packaging
--version(it did not exist), and acargo publishjob guarded byCARGO_REGISTRY_TOKENthat verifies the tag matchesCargo.toml. crates.io had drifted to 0.1.2 while the repo was at 0.1.3, because publishing was manual.Tests
47 passing, up from 31. Covers both
print-disabledwordings, the four elevation rules, the four provenance ordering rules, brew cache hit/expiry, and a headless render of all three views at 1×1, 8×3, 20×5 and 40×10 — which is how the detail modal growing from 17 to 19 rows was checked for panics.Known limits
is_writabledoes not resolve supplementary groups (no libc). The bias is deliberate and one-directional: it may ask for elevation that was not strictly needed, never skip elevation that was.SafetyLevel::AdminRequiredno longer governs anything and survives as a location label only./bin/sh -lccalls inactions.rsare untouched.