fix(exec): prevent shell startup files from overriding daemon env#40200
fix(exec): prevent shell startup files from overriding daemon env#40200NewdlDewdl wants to merge 3 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes issue #40179 by preventing shell startup files from overriding daemon-inherited environment variables during exec command execution. It adds a new helper Key changes:
Observation:
Confidence Score: 4/5
Last reviewed commit: acb1b7b |
|
Addressed the fish fallback gap noted in feedback. Changes pushed to
Validation run locally on this branch:
|
|
Investigated the failing macOS job. This branch is 6,973 commits behind Current blocker:
Recommended next step: rebase this branch onto current |
b831c7b to
ed4e1d9
Compare
afe0dc8 to
7fcb367
Compare
7fcb367 to
8d1841b
Compare
|
Contributor cycle update:\n\n- Rebased onto current and resolved the merge conflict in .\n- Verified PR scope is still limited to:\n - \n - \n- Verified fish startup suppression is present () alongside existing zsh/bash suppression paths.\n\nCurrent head: \nChecks have restarted on the rebased head. |
|
Correction (previous comment had shell-escaping issues): Contributor cycle update:
Current head: |
There was a problem hiding this comment.
💡 Codex Review
openclaw/src/agents/shell-utils.ts
Line 72 in 8d1841b
getShellConfig still calls isNonInteractiveShell, but this commit removed that helper from the module. On non-Windows exec paths this becomes a ReferenceError when shell config is resolved (and the same missing symbol is referenced again in detectRuntimeShell), so command execution can fail before launching any child process unless a separate typecheck gate blocks the build.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex automated review: keeping this open. Keep #40200 open. Current main has related PATH/login-shell handling for host exec, and #40179 was closed after a Codex review, but main still does not implement this PR's requested command-shell startup suppression for zsh, bash, or fish. The PR remains a plausible focused fix for exec commands whose invoked shell startup files override the sanitized daemon environment. Best possible solution: Keep the PR open for maintainer review. The best path is to rebase it onto current main, preserve the existing sh/bash PATH fallback and non-interactive shell placeholder handling, add/keep regression tests for zsh -f, bash --noprofile --norc, and fish --no-config, then run the changed exec/agents lanes. If maintainers decide startup files should remain allowed, that should be an explicit product/security decision with docs or a narrower follow-up, not an automated close. What I checked:
Remaining risk / open question:
Codex Review notes: model gpt-5.5, reasoning high; reviewed against 724e92505adf. |
|
Re-verified this against current main before acting. What I checked:
I did not force-push the rebased branch because that would rewrite the PR while the unrelated current-main test failures are still present. Once baseline is green again, this still looks like a focused fix worth rebasing and pushing cleanly. |
Carries forward the focused shell startup suppression fix from #40200 by NewdlDewdl. - launch bash, zsh, and fish exec shells with startup files suppressed - preserve fish/bash/sh PATH fallback, non-interactive shell fallback, and Windows PowerShell behavior - add regression coverage for the affected shell arg paths Fixes #40179. Carries forward #40200. Thanks @NewdlDewdl.
|
Thanks @NewdlDewdl. The focused startup-file suppression fix from this PR has landed via the replacement PR #73969 in ea9f172, with the contributor credit preserved in the changelog. |
Carries forward the focused shell startup suppression fix from openclaw#40200 by NewdlDewdl. - launch bash, zsh, and fish exec shells with startup files suppressed - preserve fish/bash/sh PATH fallback, non-interactive shell fallback, and Windows PowerShell behavior - add regression coverage for the affected shell arg paths Fixes openclaw#40179. Carries forward openclaw#40200. Thanks @NewdlDewdl.
Carries forward the focused shell startup suppression fix from openclaw#40200 by NewdlDewdl. - launch bash, zsh, and fish exec shells with startup files suppressed - preserve fish/bash/sh PATH fallback, non-interactive shell fallback, and Windows PowerShell behavior - add regression coverage for the affected shell arg paths Fixes openclaw#40179. Carries forward openclaw#40200. Thanks @NewdlDewdl.
Summary
-f -cso.zshenvdoes not override inherited daemon environment variables--noprofile --norc -cfor the same deterministic env behaviorWhy
Issue #40179 reports exec commands seeing stale values despite launchd showing updated service env. Startup files can override inherited env values, causing this mismatch.
Testing
bash skills/openclaw-autonomous-contributor/scripts/quality_gate.sh /tmp/openclaw-issue-40179-1772997941AI disclosure
This PR was prepared with AI assistance.
Fixes #40179