Skip to content

Commit 7f44bc5

Browse files
steipetemvanhorn
andcommitted
fix: reject launchd pid sentinel values
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
1 parent 244aabb commit 7f44bc5

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Docs: https://docs.openclaw.ai
7272
- Synology Chat/rate-limit env parsing: honor `SYNOLOGY_RATE_LIMIT=0` as an explicit value while still falling back to the default limit for malformed env values instead of partially parsing them. Landed from contributor PR #39197 by @scoootscooob. Thanks @scoootscooob.
7373
- Voice-call/OpenAI Realtime STT config defaults: honor explicit `vadThreshold: 0` and `silenceDurationMs: 0` instead of silently replacing them with defaults. Landed from contributor PR #39196 by @scoootscooob. Thanks @scoootscooob.
7474
- Voice-call/OpenAI TTS speed config: honor explicit `speed: 0` instead of silently replacing it with the default speed. Landed from contributor PR #39318 by @ql-wade. Thanks @ql-wade.
75+
- launchd/runtime PID parsing: reject `pid <= 0` from `launchctl print` so the daemon state parser no longer treats kernel/non-running sentinel values as real process IDs. Landed from contributor PR #39281 by @mvanhorn. Thanks @mvanhorn.
7576
- Cron/file permission hardening: enforce owner-only (`0600`) cron store/backup/run-log files and harden cron store + run-log directories to `0700`, including pre-existing directories from older installs. (#36078) Thanks @aerelune.
7677
- Gateway/remote WS break-glass hostname support: honor `OPENCLAW_ALLOW_INSECURE_PRIVATE_WS=1` for `ws://` hostname URLs (not only private IP literals) across onboarding validation and runtime gateway connection checks, while still rejecting public IP literals and non-unicast IPv6 endpoints. (#36930) Thanks @manju-rn.
7778
- Routing/binding lookup scalability: pre-index route bindings by channel/account and avoid full binding-list rescans on channel-account cache rollover, preventing multi-second `resolveAgentRoute` stalls in large binding configurations. (#36915) Thanks @songchenghao.

src/daemon/launchd.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@ describe("launchd runtime parsing", () => {
102102
lastExitReason: "exited",
103103
});
104104
});
105+
106+
it("does not set pid when pid = 0", () => {
107+
const output = ["state = running", "pid = 0"].join("\n");
108+
const info = parseLaunchctlPrint(output);
109+
expect(info.pid).toBeUndefined();
110+
expect(info.state).toBe("running");
111+
});
112+
113+
it("sets pid for positive values", () => {
114+
const output = ["state = running", "pid = 1234"].join("\n");
115+
const info = parseLaunchctlPrint(output);
116+
expect(info.pid).toBe(1234);
117+
});
118+
119+
it("does not set pid for negative values", () => {
120+
const output = ["state = waiting", "pid = -1"].join("\n");
121+
const info = parseLaunchctlPrint(output);
122+
expect(info.pid).toBeUndefined();
123+
expect(info.state).toBe("waiting");
124+
});
105125
});
106126

107127
describe("launchctl list detection", () => {

src/daemon/launchd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function parseLaunchctlPrint(output: string): LaunchctlPrintInfo {
128128
const pidValue = entries.pid;
129129
if (pidValue) {
130130
const pid = Number.parseInt(pidValue, 10);
131-
if (Number.isFinite(pid)) {
131+
if (Number.isFinite(pid) && pid > 0) {
132132
info.pid = pid;
133133
}
134134
}

0 commit comments

Comments
 (0)