Skip to content

fix: resolve openclaw.json permissions conflict and scope Dockerfile …#570

Closed
franknvda1 wants to merge 1 commit into
NVIDIA:mainfrom
franknvda1:fix/frankr-openclaw_permissions
Closed

fix: resolve openclaw.json permissions conflict and scope Dockerfile …#570
franknvda1 wants to merge 1 commit into
NVIDIA:mainfrom
franknvda1:fix/frankr-openclaw_permissions

Conversation

@franknvda1

@franknvda1 franknvda1 commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

…lockdown

  • Bake both 'nvidia' and 'inference' providers into openclaw.json at image build time; remove runtime Python config-patching from buildSandboxConfigSyncScript (writes to locked root:root 444 file)
  • Use openclaw models set for runtime model selection (writes to writable agent config in .openclaw-data/)
  • Add identity/, devices/, canvas/, cron/ to .openclaw-data symlinks so the gateway can write device-auth.json at runtime
  • Remove dead openclaw doctor --fix and openclaw plugins install calls from nemoclaw-start.sh (already ran at build time, fail with EPERM at runtime)

Caused-by: 2d3f84e (fix: lock gateway config via Landlock filesystem policy) Fixes #514

Summary

Related Issue

Changes

Type of Change

  • Code change for a new feature, bug fix, or refactor.
  • Code change with doc updates.
  • Doc only. Prose changes without code sample modifications.
  • Doc only. Includes code sample changes.

Testing

  • make check passes.
  • npm test passes.
  • make docs builds without warnings. (for doc-only changes)

Checklist

General

Code Changes

  • make format applied (TypeScript and Python).
  • Tests added or updated for new or changed behavior.
  • No secrets, API keys, or credentials committed.
  • Doc pages updated for any user-facing behavior changes (new commands, changed defaults, new features, bug fixes that contradict existing docs).

Doc Changes

  • Follows the style guide. Try running the update-docs agent skill to draft changes while complying with the style guide. For example, prompt your agent with "/update-docs catch up the docs for the new changes I made in this PR."
  • New pages include SPDX license header and frontmatter, if creating a new page.
  • Cross-references and links verified.

Summary by CodeRabbit

  • New Features

    • Added support for multiple model providers in configuration.
  • Improvements

    • Simplified runtime initialization by moving configuration steps to build time, reducing startup overhead.
    • Model selection now handled via command-line interface for better consistency.
  • Tests

    • Updated test cases to reflect new configuration workflow.

…lockdown

- Bake both 'nvidia' and 'inference' providers into openclaw.json at
  image build time; remove runtime Python config-patching from
  buildSandboxConfigSyncScript (writes to locked root:root 444 file)
- Use `openclaw models set` for runtime model selection (writes to
  writable agent config in .openclaw-data/)
- Add identity/, devices/, canvas/, cron/ to .openclaw-data symlinks
  so the gateway can write device-auth.json at runtime
- Remove dead `openclaw doctor --fix` and `openclaw plugins install`
  calls from nemoclaw-start.sh (already ran at build time, fail with
  EPERM at runtime)

Caused-by: 2d3f84e (fix: lock gateway config via Landlock filesystem policy)
Fixes NVIDIA#514
@coderabbitai

coderabbitai Bot commented Mar 21, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR makes OpenClaw configuration immutable by moving runtime state to separate writable directories with symlinks, pre-baking agent configuration at Docker build time, and removing all runtime modifications to openclaw.json. This prevents agents from self-modifying security-critical configuration files.

Changes

Cohort / File(s) Summary
Docker Build Configuration
Dockerfile
Provisions writable state directories (identity, devices, canvas, cron) under /sandbox/.openclaw-data/ with symlinks into the immutable /sandbox/.openclaw/ tree. Adds update-check.json to data directory. Expands models.providers configuration to include an inference provider alongside the existing nvidia provider, with the primary agent model configured to use inference/{model} format.
Runtime Onboarding
bin/lib/onboard.js
Removes embedded Python logic that modified openclaw.json at runtime (agent defaults, provider injection). Simplifies generated sandbox-config sync script to only write NemoClaw selection config and invoke openclaw models set for model activation, with provider/model configuration now pre-baked at image build time.
Container Startup
scripts/nemoclaw-start.sh
Removes openclaw doctor --fix and openclaw plugins install invocations with explanatory comments indicating these operations now occur during Docker build and cannot run at runtime due to EPERM restrictions on the locked /sandbox/.openclaw directory.
Test Expectations
test/onboard.test.js
Updates test assertions to verify the script writes to ~/.nemoclaw/config.json with model selection and credentials, invokes openclaw models set 'inference/<model>' CLI, and does not reference openclaw.json (treating it as immutable). Removes assertions for prior JSON manipulation implementation details.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 Hop, hop—no more config tweaks for thee!
Build-time bakes what agents dare not see
Symlinks shield the data, read-only stays the key
Security takes root, immutably free 🔐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: resolving openclaw.json permissions conflicts and scoping Dockerfile lockdown, which aligns with the core objective of preventing unauthorized modifications.
Linked Issues check ✅ Passed The PR implements the proposed fix for #514 by making openclaw.json read-only at build time, removing runtime modification attempts, and adjusting filesystem layout to isolate writable state from locked directories.
Out of Scope Changes check ✅ Passed All changes directly support the stated objective of preventing runtime modifications to openclaw.json. The Dockerfile changes pre-bake configuration, onboard.js removes JSON modification, and nemoclaw-start.sh removes problematic runtime operations.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread Dockerfile
}, \
'inference': { \
'baseUrl': 'https://inference.local/v1', \
'apiKey': 'unused', # pragma: allowlist secret \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing this out because onboarding is broken for me (see #580), but the # pragma: allowlist secret comment here (and also above on line 108) seemed to break this for me. It resulted in:

SyntaxError: '{' was never closed

ericksoa added a commit that referenced this pull request Mar 21, 2026
The # pragma: allowlist secret comments inside the multi-line python3 -c
string cause Python to treat everything after # as a comment, swallowing
the \ line continuation and closing braces. This results in:
  SyntaxError: '{' was never closed

Reported by DanTup in PR #570.
@kjw3

kjw3 commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Thanks for the work on this. The core fix direction from #570 has now landed through #588, which carried the same approach forward and closed the remaining gap.

I’m going to close this one as superseded so the history stays clean, but the contribution here was useful and directly informed the merged fix.

Let it rip 🤙

@kjw3 kjw3 closed this Mar 21, 2026
kjw3 pushed a commit that referenced this pull request Mar 21, 2026
…me (#588)

* fix: resolve openclaw.json permissions conflict and scope Dockerfile lockdown

- Bake both 'nvidia' and 'inference' providers into openclaw.json at
  image build time; remove runtime Python config-patching from
  buildSandboxConfigSyncScript (writes to locked root:root 444 file)
- Use `openclaw models set` for runtime model selection (writes to
  writable agent config in .openclaw-data/)
- Add identity/, devices/, canvas/, cron/ to .openclaw-data symlinks
  so the gateway can write device-auth.json at runtime
- Remove dead `openclaw doctor --fix` and `openclaw plugins install`
  calls from nemoclaw-start.sh (already ran at build time, fail with
  EPERM at runtime)

Caused-by: 2d3f84e (fix: lock gateway config via Landlock filesystem policy)
Fixes #514

* fix: remove pragma comments that break inline Python in Dockerfile

The # pragma: allowlist secret comments inside the multi-line python3 -c
string cause Python to treat everything after # as a comment, swallowing
the \ line continuation and closing braces. This results in:
  SyntaxError: '{' was never closed

Reported by DanTup in PR #570.

* fix: remove openclaw models set from sync script — config stays on host

openclaw models set writes to openclaw.json, which is correctly locked
(root:root 444 + Landlock read-only). Model routing is handled by the
host-side gateway via openshell inference set (Step 5), not from inside
the sandbox. The sync script should only write NemoClaw's own selection
config to ~/.nemoclaw/config.json.

Remove openclaw models set call, dead pythonLiteralJson helper, and
unused getOpenClawPrimaryModel/DEFAULT_OLLAMA_MODEL imports.

---------

Co-authored-by: Frank Ruiz <frankr@nvidia.com>
@0x1stvan

Copy link
Copy Markdown

Thanks for the work on this. The core fix direction from #570 has now landed through #588, which carried the same approach forward and closed the remaining gap.

I’m going to close this one as superseded so the history stays clean, but the contribution here was useful and directly informed the merged fix.

Let it rip 🤙

Isn't this just brake the openclaw configuration inside the sandbox? I get permission denied trying to set the configs for example: openclaw config set allowedOrigins, returns EACCES: permission denied, copyfile '/sandbox/.openclaw/openclaw.json

Ryuketsukami pushed a commit to Ryuketsukami/NemoClaw that referenced this pull request Mar 24, 2026
…me (NVIDIA#588)

* fix: resolve openclaw.json permissions conflict and scope Dockerfile lockdown

- Bake both 'nvidia' and 'inference' providers into openclaw.json at
  image build time; remove runtime Python config-patching from
  buildSandboxConfigSyncScript (writes to locked root:root 444 file)
- Use `openclaw models set` for runtime model selection (writes to
  writable agent config in .openclaw-data/)
- Add identity/, devices/, canvas/, cron/ to .openclaw-data symlinks
  so the gateway can write device-auth.json at runtime
- Remove dead `openclaw doctor --fix` and `openclaw plugins install`
  calls from nemoclaw-start.sh (already ran at build time, fail with
  EPERM at runtime)

Caused-by: 2d3f84e (fix: lock gateway config via Landlock filesystem policy)
Fixes NVIDIA#514

* fix: remove pragma comments that break inline Python in Dockerfile

The # pragma: allowlist secret comments inside the multi-line python3 -c
string cause Python to treat everything after # as a comment, swallowing
the \ line continuation and closing braces. This results in:
  SyntaxError: '{' was never closed

Reported by DanTup in PR NVIDIA#570.

* fix: remove openclaw models set from sync script — config stays on host

openclaw models set writes to openclaw.json, which is correctly locked
(root:root 444 + Landlock read-only). Model routing is handled by the
host-side gateway via openshell inference set (Step 5), not from inside
the sandbox. The sync script should only write NemoClaw's own selection
config to ~/.nemoclaw/config.json.

Remove openclaw models set call, dead pythonLiteralJson helper, and
unused getOpenClawPrimaryModel/DEFAULT_OLLAMA_MODEL imports.

---------

Co-authored-by: Frank Ruiz <frankr@nvidia.com>
jessesanford pushed a commit to jessesanford/NemoClaw that referenced this pull request Mar 24, 2026
…me (NVIDIA#588)

* fix: resolve openclaw.json permissions conflict and scope Dockerfile lockdown

- Bake both 'nvidia' and 'inference' providers into openclaw.json at
  image build time; remove runtime Python config-patching from
  buildSandboxConfigSyncScript (writes to locked root:root 444 file)
- Use `openclaw models set` for runtime model selection (writes to
  writable agent config in .openclaw-data/)
- Add identity/, devices/, canvas/, cron/ to .openclaw-data symlinks
  so the gateway can write device-auth.json at runtime
- Remove dead `openclaw doctor --fix` and `openclaw plugins install`
  calls from nemoclaw-start.sh (already ran at build time, fail with
  EPERM at runtime)

Caused-by: 2d3f84e (fix: lock gateway config via Landlock filesystem policy)
Fixes NVIDIA#514

* fix: remove pragma comments that break inline Python in Dockerfile

The # pragma: allowlist secret comments inside the multi-line python3 -c
string cause Python to treat everything after # as a comment, swallowing
the \ line continuation and closing braces. This results in:
  SyntaxError: '{' was never closed

Reported by DanTup in PR NVIDIA#570.

* fix: remove openclaw models set from sync script — config stays on host

openclaw models set writes to openclaw.json, which is correctly locked
(root:root 444 + Landlock read-only). Model routing is handled by the
host-side gateway via openshell inference set (Step 5), not from inside
the sandbox. The sync script should only write NemoClaw's own selection
config to ~/.nemoclaw/config.json.

Remove openclaw models set call, dead pythonLiteralJson helper, and
unused getOpenClawPrimaryModel/DEFAULT_OLLAMA_MODEL imports.

---------

Co-authored-by: Frank Ruiz <frankr@nvidia.com>
@wscurran wscurran added the bug-fix PR fixes a bug or regression label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent can self-modify openclaw.json to bypass auth and CORS controls

5 participants