fix(docker): self-dropping netclaw CLI launcher so root exec works (0.23.0-beta.3)#1322
Merged
Merged
Conversation
….23.0-beta.3) The daemon runs as the non-root netclaw user, but docker exec / kubectl exec default to the image's root user, and 'netclaw init' is invoked that way. A root-context CLI run extracted the .NET single-file bundle into a per-$HOME dir the runtime locks root:root (and wrote config root-owned), after which the non-root daemon could no longer run its own CLI (Failed to create directory ... Error code: 13 / EACCES, exit 160). /usr/local/bin/netclaw is now a self-dropping launcher that re-execs as the netclaw user when invoked as root; when already netclaw it execs directly (composes with runAsUser / -u netclaw). netclawd stays a plain symlink (only ever launched by the already-dropped entrypoint). Adds ADR-004 and a standalone-docker regression test (scripts/docker/test-nonroot-cli.sh) wired into validate_docker_image. Bumps to 0.23.0-beta.3.
f39dcfd to
7ff3efb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the non-root container model usable for the operator CLI, and locks it in with a standalone-
dockerregression test. Bumps to 0.23.0-beta.3.Problem
The daemon runs as the unprivileged
netclawuser (good — it executes model-chosen shell commands). Butdocker exec/kubectl execdefault to the image'sUSER root, andnetclaw init— the documented first-run setup — is invoked exactly that way.A root-context
netclawinvocation breaks the agent two ways:$HOME/.net/netclaw/<hash>/, which the runtime locks to the invoking user at mode700. Extracted by root, the non-root daemon can no longer extract its own CLI:EACCES, exit 160).netclaw initwrites identity/config/secrets underNETCLAW_HOMEas root; the non-root daemon can't read them.Seen in production: operators inspecting/setting model assignments via
kubectl execleft the agents unable to run their own CLI.Fix
/usr/local/bin/netclawbecomes a self-dropping launcher (docker/netclaw-cli-launcher.sh): if invoked as root it re-execs asnetclawviagosu; if alreadynetclawit execs directly (so it composes withrunAsUser: 1654/docker exec -u netclaw).netclawdstays a plain symlink — it's only ever launched by the already-dropped entrypoint, so it never hits the root path.Rationale and alternatives (why not
USER netclaw,runAsUser,DOTNET_BUNDLE_EXTRACT_BASE_DIR, or docs-only) are in ADR-004.Regression test
scripts/docker/test-nonroot-cli.sh(wired intovalidate_docker_image.yml) reproduces the original break with standalonedockerand asserts:docker exec -- netclaw --versionexits 0, prints a version (no EACCES signature), and emits the launcher's drop breadcrumb;/home/netclaw/.netor/home/netclaw/.netclawis owned by uid 0 after root-context CLI runs (the guard — without the launcher the extraction dir isroot:rootand this fails);docker exec -u netclaw) execs directly with no second drop;Changes
docker/netclaw-cli-launcher.sh(new) +docker/Dockerfile(CLI → launcher;netclawdsymlink unchanged)scripts/docker/test-nonroot-cli.sh(new) +validate_docker_image.yml(run it; path trigger; cleanup)docs/adr/ADR-004-non-root-cli-self-drop.md(new)Directory.Build.props+RELEASE_NOTES.md→0.23.0-beta.3Release
Tag
0.23.0-beta.3after merge to firepublish_release_binaries.yml.