Repository navigation
fix(daemon): prevent duplicate systemd gateway ownership - #116162
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 9:42 PM ET / July 30, 2026, 01:42 UTC. ClawSweeper reviewWhat this changesThe PR blocks user-scope systemd gateway installation and lifecycle actions when a same-named system-scope unit owns—or cannot be reliably checked for—the canonical gateway service name, while adding rollback and regression coverage. Merge readinessKeep this PR open for explicit maintainer review. It addresses the linked dual-supervisor failure, but it deliberately chooses fail-closed installation over the linked issue's proposed automatic opposite-scope retirement; the author is a MEMBER and the PR carries the protected Priority: P1 Review scores
Verification
How this fits togetherOpenClaw's daemon CLI publishes and controls a user-level systemd gateway service. This change inserts a system-scope ownership decision before user-unit publication or activation so two supervisors cannot manage the same canonical gateway name and compete for the gateway process. flowchart LR
A[Daemon CLI request] --> B[User systemd service lifecycle]
B --> C[Resolve canonical gateway unit name]
C --> D[Check system systemd manager]
D -->|Same name or unverifiable| E[Actionable ownership error]
D -->|No owner found| F[Publish user unit and environment]
F --> G[Enable or restart user gateway]
E --> H[No user files changed]
Decision needed
Why: Both approaches prevent the dual-supervisor failure, but they differ materially in operator control, upgrade behavior, and whether OpenClaw automatically changes a system-managed service. Before merge
Agent review detailsSecurityNone. PR surfaceSource +331, Tests +488, Docs +1. Total +820 across 6 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt one explicit cross-scope ownership policy for canonical gateway units—prefer the proposed fail-closed rule if maintainers want to preserve system units untouched—and ensure the resulting recovery path remains actionable for existing Linux operators. Do we have a high-confidence way to reproduce the issue? No high-confidence independent reproduction was run in this read-only review. The linked issue and the added test paths make the dual-owner condition source-reproducible, and the PR body reports a live Linux reproduction with a transient Is this the best way to solve the issue? Unclear. The branch is a coherent way to prevent duplicate ownership, but its fail-closed policy differs from the linked issue's automatic-retirement proposal and needs an explicit maintainer choice before it can be called the best fix. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 21db50efc72e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer decision: adopt the fail-closed ownership rule in this PR. A same-named system-scope unit is operator-owned; user-scope install/start/restart must stop with recovery guidance, and This matches the existing launchd ownership policy and keeps cross-scope retirement out of unattended install/update paths. The live |
Fixes #116129
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where Linux operators could install the same OpenClaw gateway unit in both system and user systemd scopes, leaving two supervisors competing over one gateway and causing restart loops or unreliable message delivery.
Why This Change Was Made
Gateway install, stage, start, and restart now fail closed when the system manager owns the exact canonical unit name. The check uses the running system manager's unit search path, is repeated around publication and activation to close races, and cannot be bypassed with
--force.OpenClaw does not mutate system-scope units automatically. Differently named and profile-specific units remain independent, while user-unit and environment-file publication is atomic and rolls back exact prior contents and permissions if ownership changes mid-install.
User Impact
Linux operators get an actionable error before OpenClaw creates or activates a conflicting user gateway. Existing system units remain untouched, custom differently named services continue to work, and failed publication does not leave partial user-scope files behind.
Evidence
src/daemon/systemd-system.test.ts,src/daemon/systemd.test.ts, andsrc/cli/daemon-cli/install.integration.test.ts./run/systemd/system, confirmed install failed withSYSTEM_SYSTEMD_OWNERSHIP, confirmed a differently named unit passed, and verified no user unit or gateway environment file was published./etc,/run,/usr/local, generator/package guidance, uncheckable ownership, root/non-root recovery, profile names, publication and activation races, symlink refusal, rollback, and zero-valued permission preservation.Agent Transcript
Redacted Codex session transcript