daemon: load systemd EnvironmentFile and drop-ins so gateway status probe uses same env as gateway#18498
Open
saurav470 wants to merge 2 commits intoopenclaw:mainfrom
Open
Conversation
…robe uses same env as gateway Co-authored-by: Cursor <cursoragent@cursor.com>
|
This pull request has been automatically marked as stale due to inactivity. |
|
Does this has been fixed? |
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.
Summary
fix #18475
EnvironmentFile=(e.g./etc/openclaw/secrets/*.env) for the openclaw-gateway service,openclaw gateway statusreports a false unauthorized: device token mismatch (rotate/reissue device token) even though the gateway runs normally, the dashboard loads, andopenclaw status/openclaw doctorwork.readSystemdServiceExecStart()now loads EnvironmentFile= contents and parses drop-in dirs (*.service.d/*.conf) so the returnedenvironmentmatches what the gateway process actually sees. The daemon status probe already merges this service env; it now gets the same token/config as the gateway.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
openclaw gateway statuscould report "unauthorized: device token mismatch" when the gateway was started withEnvironmentFile=or drop-in overrides that setOPENCLAW_GATEWAY_TOKENorOPENCLAW_CONFIG_PATH, even though the gateway and dashboard were healthy.Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
~/.config/systemd/user/openclaw-gateway.service.d/secrets.confwithEnvironmentFile=/etc/openclaw/secrets/agent1.env(and optionally more).Steps
/etc/openclaw/secrets/agent1.env(or placeholder) and~/.config/systemd/user/openclaw-gateway.service.d/secrets.confwith[Service]andEnvironmentFile=....systemctl --user daemon-reloadandopenclaw gateway restart.openclaw gateway status.Expected
Actual (before fix)
Evidence
src/daemon/systemd.test.tsfor EnvironmentFile=, drop-in merge, optional-/path, and[Service]-only parsing.Human Verification (required)
Compatibility / Migration
Failure Recovery (if this breaks)
readSystemdServiceExecStartcould returnnullor incomplete env; status would then fall back to CLI env (previous behavior).Risks and Mitigations
-/path; tests cover basic and override cases. Complex expansion is not implemented (systemd does it at run time; we only need same vars for probe).Greptile Summary
Fixes
openclaw gateway statusreporting a false "unauthorized: device token mismatch" when the gateway's systemd unit uses EnvironmentFile directives or drop-in overrides. The status probe now loads the same env files and drop-in configs that systemd passes to the gateway process, so credentials match.parseSystemdServiceSectionto parse only the Service sectionstatus.gather.ts; no functional changeResilience concern: If a non-optional EnvironmentFile path is missing or a drop-in file is unreadable, the entire parse aborts and returns null, silently falling back to CLI env. This could mask config issues.
Confidence Score: 3/5
Last reviewed commit: 66d5c23