Skip to content

fix(cli): non-elevated daemon management when the broker is serving (Windows)#464

Merged
githubrobbi merged 2 commits into
mainfrom
fix/windows-daemon-mgmt-broker-aware-elevation
Jun 20, 2026
Merged

fix(cli): non-elevated daemon management when the broker is serving (Windows)#464
githubrobbi merged 2 commits into
mainfrom
fix/windows-daemon-mgmt-broker-aware-elevation

Conversation

@githubrobbi

Copy link
Copy Markdown
Collaborator

Symptom

On Windows, a non-elevated uffs --update fails to apply:

Error: Daemon management commands require an elevated (Administrator) shell.
…
Error: daemon did not stop within 20s (PID file lingered)
Error: uffs-update apply failed (exit Some(1)) — the helper rolled back + restored services

Even with the Access Broker installed and serving, you must open an elevated window to update — which defeats the broker's entire purpose (zero-UAC operation).

Root cause

The daemon-management elevation gate was hardcoded on Windows:

#[cfg(not(unix))]
const fn mutating_management_needs_elevation() -> bool { true }   // always

So every uffs --daemon stop/restart demanded elevation. The self-update quiesce drives uffs --daemon stop, the gate refused, the daemon never stopped, and apply rolled back. (Unix already gates intelligently on PID-file ownership; only Windows was blanket-true.)

Fix

On Windows, require elevation only when the broker pipe is NOT serving. With the broker up, the daemon runs non-elevated and a non-elevated caller can stop and restart it (restart adopts broker handles — no UAC), so there's no risk of stranding a daemon that can't be brought back. Without the broker, a restart needs admin to re-read the MFT, so elevation is still required.

The old #[cfg(not(unix))] true splits into #[cfg(windows)] (broker-aware) and #[cfg(not(any(unix, windows)))] (conservative true). Docs updated to match.

Result

The intended zero-UAC flow holds end-to-end: on a broker-equipped install, non-elevated uffs --update just works — no elevated window needed.

Verification

macOS build + x86_64-pc-windows-msvc cross-build + Windows clippy all clean; file stays within the 800-LOC policy.

🤖 Generated with Claude Code

…Windows)

On Windows the daemon-management elevation gate
(`mutating_management_needs_elevation`) was hardcoded to `true`, so EVERY
stop/restart needed an elevated shell — even with the Access Broker installed.
That broke the non-elevated `uffs --update` on Windows: its quiesce drives
`uffs --daemon stop`, the gate refused ("Daemon management commands require an
elevated (Administrator) shell"), the daemon never stopped, and apply rolled
back ("daemon did not stop within 20s"). It defeats the whole point of the
broker (zero-UAC operation) and forced users into an elevated window to update.

Fix: on Windows, require elevation only when the broker pipe is NOT serving.
With the broker up the daemon runs non-elevated and a non-elevated caller can
stop AND restart it (restart adopts broker handles — no UAC), so there's no
risk of stranding a daemon that can't be brought back. Without the broker, a
restart would need admin to re-read the MFT, so elevation is still required.
Mirrors the Unix path, which already gates on PID-file ownership not a blanket
`true`. The old `#[cfg(not(unix))]` `true` splits into `#[cfg(windows)]`
(broker-aware) and `#[cfg(not(any(unix, windows)))]` (conservative `true`).

Verified: macOS build + windows-msvc cross-build + windows clippy all clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@githubrobbi githubrobbi enabled auto-merge (squash) June 20, 2026 00:08
@githubrobbi githubrobbi merged commit 94a79b2 into main Jun 20, 2026
27 checks passed
@githubrobbi githubrobbi deleted the fix/windows-daemon-mgmt-broker-aware-elevation branch June 20, 2026 00:35
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