shell: fall back to sh when SHELL is /usr/bin/false or nologin#69308
shell: fall back to sh when SHELL is /usr/bin/false or nologin#69308steipete merged 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a real production issue where processes running under a service account with Confidence Score: 5/5Safe to merge — the fix is minimal, well-scoped, and all existing plus new tests pass. The logic change is correct: placeholder basenames are filtered before any shell invocation, the fallback path reuses the existing resolveShellFromPath helper, and the fish-shell path is untouched. The only finding is a P2 suggestion to add a test for the detectRuntimeShell code path, which does not block merge. No files require special attention.
|
e15950b to
39dde04
Compare
39dde04 to
a221f51
Compare
a221f51 to
10197ce
Compare
10197ce to
aadb99a
Compare
aadb99a to
0dc6f04
Compare
0dc6f04 to
a3defb0
Compare
* 'main' of https://github.com/openclaw/openclaw: (653 commits) docs(changelog): deduplicate openclaw#67800 entries in Unreleased (openclaw#69670) fix(agents): honor explicit long Anthropic cache TTL on custom hosts (openclaw#67800) fix: fix Telegram media file delivery (openclaw#69641) fix(media): preserve outbound attachment filenames fix(media): parse lowercase media directives fix(bluebubbles): add opt-in coalesceSameSenderDms for split-send DMs (openclaw#69258) fix: centralize provider thinking profiles docs: prepare 2026.4.20 changelog fix: stage ACP and Codex runtime deps fix(gateway): drop stale service env on reinstall test: add bundled channel dependency Docker smoke test: relax detached task recovery timing assertion fix: ignore placeholder shells in runtime detection (openclaw#69308) shell: fall back to sh when SHELL is /usr/bin/false or nologin fix(browser): clarify DevToolsActivePort attach failures fix: sanitize mcp transport warning fields fix: launch Windows startup gateway directly fix(openai-codex): normalize legacy copilot transport fix: narrow MCP stdio env safety filter (openclaw#69540) fix(mcp): block dangerous stdio env overrides ...
Summary
getShellConfig()soexecno longer exits with code 1 whenprocess.env.SHELLis a non-interactive placeholder such as/usr/bin/false,/bin/false,/usr/sbin/nologin, or/sbin/nologin.detectRuntimeShell()so runtime classification does not leak the placeholder name.sh(thenbash) fromPATH; fall back to bareshonly when nothing is onPATH.Problem — fixes #69077
On macOS 15, OpenClaw Gateway deployed as a custom LaunchDaemon under a dedicated service user whose login shell is
/usr/bin/falsehas everyexecreturnexitCode=1after 3-10ms, with the target script never actually running. The workaround was to setSHELL=/bin/shexplicitly in the LaunchDaemonEnvironmentVariablesplist.Root cause:
src/agents/shell-utils.ts#getShellConfigreadsprocess.env.SHELLdirectly and, when non-empty, uses it verbatim with-c. Spawning/usr/bin/false -c '<script>'exits 1 immediately becausefalseis not a shell.Fix
falseornologinas non-interactive placeholders and ignore them.SHELLis unset or a placeholder, resolveshfromPATH(thenbash), and fall back to bare"sh"only if nothing is found — matches the previous "unset" branch.detectRuntimeShell()so/usr/bin/falsedoes not bubble up as a runtime shell name.Not changed
SHELL=/usr/bin/fishpath is untouched (still prefersbashthensh).OPENCLAW_SHELLoverride indetectRuntimeShell()is unchanged and still wins; users who deliberately configure a non-standard binary can keep using it.resolveShellFromPathhelper is unchanged.Testing
pnpm test src/agents/shell-utils.test.ts— 14/14 green (3 new cases: SHELL=/usr/bin/false with sh on PATH; SHELL=/sbin/nologin with sh on PATH; placeholder + empty PATH).pnpm test src/agents/shell-utils.test.ts src/agents/bash-tools.exec.path.test.ts— 40/40 green.pnpm lint src/agents/shell-utils.ts src/agents/shell-utils.test.ts— 0 warnings / 0 errors.pnpm tsgo:coreandpnpm tsgo:core:test— clean.pnpm format— applied.Notes
AI-assisted: Claude Code (Opus 4.7), human reviewed and tested. Scope stays within
src/agents/shell-utils.{ts,test.ts}; no behavior change for users whoseSHELLis a real shell.