Repository navigation
fix(update): use a private workspace when the system temp directory is unsafe - #187737
Conversation
Warn with the rejected writable ancestor and use private state/tmp scratch when the selected system temp hierarchy is unsafe. Preserve shared coordination addresses, Android admission, and artifact retention/cleanup. Fixes #187657. Thanks @Yachiyo1680 for the report.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25ffdac10d
ℹ️ 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".
| const stateDir = resolveStateDir(); | ||
| try { | ||
| const fallbackRoot = resolveRoot({ | ||
| ...rootOptions, | ||
| preferredDir: undefined, | ||
| tmpdir: () => path.join(stateDir, "tmp"), |
There was a problem hiding this comment.
Preserve the caller-selected namespace for Doctor IPC
When /tmp/openclaw has an unsafe ancestor, this fallback discards the caller's tmpdir override and selects scratch from the current process's state directory. In src/infra/update-candidate-canary.ts, doctorResultOptions explicitly selects copiedStateDir for the Doctor result, while the child receives that copied directory as OPENCLAW_STATE_DIR. The parent now creates the result path under live-state scratch, but the child's resolveSafeUpdatePostInstallDoctorResultPath in src/infra/update-doctor-result.ts expects copied-state scratch and throws Unsafe post-install doctor result path. Consequently, candidate Doctor cannot publish its result and normal update rehearsal fails in the unsafe-temp environment this change is meant to support. Preserve a shared IPC namespace across the parent and child when applying the fallback.
AGENTS.md reference: AGENTS.md:L52-L52
Useful? React with 👍 / 👎.
| (options.warn ?? console.warn)( | ||
| `[openclaw] ${String(rejected)} Using private state temp dir: ${fallbackRoot}`, | ||
| ); |
There was a problem hiding this comment.
Emit the fallback warning without reentering logger initialization
With console capture enabled, default file logging, and an unsafe system-temp ancestor, this unconditional console.warn reenters the logger that is resolving this same directory. enableConsoleCapture in src/logging/console.ts forwards warnings through getLogger(), whose uncached settings resolve resolveDefaultRollingLogFile() and call this selector again. Since every selection emits another warning before settings can be cached, initialization recurses until stack exhaustion; the console wrapper catches the error, but unwinding then emits many duplicate warnings and performs repeated filesystem work. Use a non-captured warning sink or otherwise prevent warning emission from recursively initializing the logger.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesSelect private state-directory scratch when system temporary storage has unsafe ancestor permissions, while preserving coordination locations. Example: Linux has /tmp mode 0775 without sticky protection and a safe /home/alex/.openclaw state directory.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Needs changes before merge - 2 items remain This PR addresses a real update failure, but the fallback introduces a Doctor result-path mismatch and recursive logger initialization that should be repaired before merge. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe shared temporary-root selector supplies update staging, Doctor IPC, logging, and plugin consumers; fs-safe admits private directories, while service locks and handoff databases need stable coordination addresses. flowchart TD
A[Update and runtime callers] --> B[Temporary root selector]
B --> C[System temporary root]
C --> D[Ancestor permission check]
D --> E[Private state scratch fallback]
B --> F[Stable coordination locations]
E --> G[Workspace and Doctor consumers]
Technical reviewBest possible solution: Keep the shared selector and fs-safe admission, preserve the caller's Doctor namespace during fallback, and emit warnings through a sink that cannot initialize logging. Do we have a high-confidence way to reproduce the issue? The permission mismatch and both introduced regressions are traceable through current source; supplied real-filesystem tests support the original mismatch, but this read-only review executed no target code. Is this the best way to solve the issue? A private fallback is appropriate and uses existing owners, but its namespace and warning behavior must satisfy existing consumers before the fix is complete. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 01080c52372e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +68, Tests +78, Docs +12. Total +158 across 9 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 29, 2026, 11:15 AM ET / 15:15 UTC. |
…s unsafe (openclaw#187737) Update admission refused outright when an ancestor of the system temp directory was group/world-writable without sticky protection. The shared temp-root selector now falls back to a checked owner-private workspace under the OpenClaw state directory, warns with the rejected directory, and keeps artifact retention, cleanup and shared coordination paths; it refuses only when no safe root exists, naming the directory to fix. Fixes openclaw#187657. Thanks @Yachiyo1680 for the report.
What Problem This Solves
Updates can refuse before package mutation when the selected temp root has a group- or world-writable ancestor without sticky protection.
Fixes #187657. Thanks @Yachiyo1680 for the report.
User Impact
OpenClaw warns with the rejected ancestor and continues using private scratch under the selected state directory's
tmpdirectory. If both locations are unsafe, the refusal identifies the directory and giveschmod +torchmod go-wguidance. Shared permissions are never changed.Node 26.8.1 is admitted with security-upgrade guidance per #186589; 26.12.1 is the recommended security patch level, rather than the current runtime admission floor. This change does not alter Node admission.
Why This Change Was Made
On POSIX, the shared selector prefers
/tmp/openclaw, with a per-useros.tmpdir()/TMPDIRfallback. It checked the private leaf while workspace admission also checked ancestors. Filter unsafe ancestors at selection and reuse the same fs-safe private-root resolver for the state fallback. This covers update artifacts, candidate admission, install workspaces, and Doctor snapshot staging through their existing callers. Coordination databases and service locks explicitly keep their existing shared locations across profiles and updater versions; Android ancestor group admission remains with fs-safe. Artifact retention after uncertain child cleanup and identity-checked removal stay with their existing owner.The canonical state resolver is reused. Home-path context initializes lazily so importing the selector remains browser-safe. Fallback selection stays stable when state does not yet exist, and disposable scratch remains under
state/tmp.Evidence
82777f305ef8: the unsafe system root was selected, and the unsafe-state case did not refuse. With the fix, a real0775non-sticky ancestor selects private state scratch; fs-safe admits a workspace there and removes it after use. Both unsafe roots produce directory-specific repair guidance.git diff --check, and Madge (0 cycles) passed. Both ratchets passed: 404 grandfathered suppressions; 6,267,403 test lines against a 6,325,142 ceiling. No baseline changes.82777f305ef8, through P2: scoped-clean. The SQLite inventory portion of fullcheck:changedwas omitted under the campaign's local gate budget; PR CI supplies broad proof.All fixtures and live npm work used isolated, realpath-resolved per-user temp roots. The reporter's exact rejected directory is unknown; the synthetic permission layout reproduces the policy mismatch without claiming the original deployment layout.
The inherited failures are
Doctor maintenance retains pending recovery without another activation after an operator edit(expected revoked authority/recovery-pending, received the fixture activation error), and the legacy LaunchAgent migration cases(20, throttle=10)and(600, throttle=1)(expected timeout/throttle repair, plist retained the old values). No assertions, retries, or timeouts were changed to hide them.Pre-existing slow proof was retained: the original-service integration file spent 234.7 seconds across 48 cases, with a 13.38-second maximum case; its fixtures exercise real state/lease owners with simulated native transports. The skill-library worker E2E case took 38.052 seconds through real worker authoring/lifecycle behavior. The initial broad command took 1,899.82 seconds including runtime preparation and all 23 shards.
Production: +80/-12 lines (net +68). Tests: +84/-6 lines (net +78). The added production work selects scratch roots and preserves existing coordination addresses; no schema, dependency, CLI, or config changes.
The focused Bun command was
OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs src/infra/tmp-openclaw-dir.test.ts src/infra/update-managed-service-handoff-lease-path.test.ts src/infra/tmp-openclaw-dir.browser-import.test.ts src/infra/home-dir.test.ts src/cli/update-cli/update-command-artifact.test.ts --maxWorkers=1(65 passed). Node used the same repository runner withOPENCLAW_VITEST_RUNTIME=nodefor the 143-file direct/home-path selection, 91-file coordination/ownership selection, and 47-file SDK/barrel selection.