fix(daemon): recognize shell-wrapped gateway commands in service audit#81755
fix(daemon): recognize shell-wrapped gateway commands in service audit#81755Bartok9 wants to merge 1 commit into
Conversation
When a LaunchAgent ProgramArguments is wrapped in a POSIX shell invocation (`/bin/zsh -lc "... gateway --port ..."`), the service audit incorrectly reported 'Service command does not include the gateway subcommand' because `hasGatewaySubcommand` only checked for a bare 'gateway' token in the array, not inside shell inline-command strings. The fix extends `hasGatewaySubcommand` to also recognise the pattern: ["<shell>", "-c|-lc|-...", "<inline-cmd-containing-gateway>"] where <shell> is any common POSIX shell basename (sh, bash, zsh, dash, fish). A word-boundary regex test on the inline command string confirms that 'gateway' is present as a subcommand, not as part of an unrelated path segment. Fixes openclaw#81751.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as duplicate/superseded: the same shell-wrapped LaunchAgent audit bug is now covered by the canonical open PR at #81778, which updates the same service-audit surface, includes real macOS proof, and avoids this PR's broad substring bug. Canonical path: Use #81778 as the canonical fix path, then close the linked issue after that PR lands. So I’m closing this here and keeping the remaining discussion on the canonical linked item. Review detailsBest possible solution: Use #81778 as the canonical fix path, then close the linked issue after that PR lands. Do we have a high-confidence way to reproduce the issue? Yes. Current main passes LaunchAgent Is this the best way to solve the issue? No for this PR as the merge path. The canonical open PR is the better solution because it covers the same bug with real behavior proof, port parsing, and a near-match negative regression without broad word-boundary matching. Security review: Security review cleared: The diff only changes local TypeScript service-audit parsing and tests, with no dependency, workflow, secret, install, or supply-chain surface change. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f74436dc81bc. |
Problem
When a LaunchAgent's
ProgramArgumentsuses a shell wrapper like:gateway statusreports:...even though the gateway is reachable and running correctly.
Root Cause
hasGatewaySubcommand()checked if any element inprogramArgumentsexactly equals"gateway". When the gateway binary is invoked inside a shell inline command (the third array element),"gateway"is embedded in a larger string — never a standalone token.Fix
Extended
hasGatewaySubcommandwith a secondary check: whenprogramArguments[0]is a recognized POSIX shell (sh,bash,zsh,dash,fish), scan subsequent arguments for a-c/-lc/etc. flag, then test the following inline command string for/\bgateway\b/.Tests Added
Three new cases in
service-audit.test.ts:/bin/zsh -lcwrapper with gateway in the inline command → no false positive/bin/sh -cwrapper with gateway in the inline command → no false positive/bin/sh -cwrapper without gateway → correctly flagsgateway-command-missingFixes #81751