fix(sandbox): add --map-auto flag for unshare commands#3013
Open
Einspanner123 wants to merge 2 commits intoultraworkers:mainfrom
Open
fix(sandbox): add --map-auto flag for unshare commands#3013Einspanner123 wants to merge 2 commits intoultraworkers:mainfrom
Einspanner123 wants to merge 2 commits intoultraworkers:mainfrom
Conversation
a6dd933 to
f8c586d
Compare
On systems where `unshare --map-root-user` alone fails because uid_map direct writes are blocked by the kernel (observed on util-linux 2.39.3 with non-root users), adding `--map-auto` lets unshare use the newuidmap SUID helper with /etc/subuid delegations to set up the mapping. This affects both the user-namespace detection probe and the actual sandbox launch arguments. When --map-root-user already works natively, the additional --map-auto flag is a safe no-op. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
f8c586d to
36d5da9
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
Fixes sandbox namespace detection and activation on systems where
unshare --map-root-useralone fails because the kernel blocks directuid_mapwrites by non-root users (observed on util-linux 2.39.3).Root Cause
unshare --map-root-usertries to write directly to/proc/self/uid_map, which the kernel rejects withEPERMfor unprivileged users on some configurations. The--map-autoflag tellsunshareto use thenewuidmapSUID helper with/etc/subuiddelegations instead, which is the recommended approach for unprivileged user namespaces.On systems where
--map-root-useralready works natively, the additional--map-autoflag is a safe no-op.Changes
Two one-line additions in
rust/crates/runtime/src/sandbox.rs:--map-root-user→--map-root-user --map-auto--map-autoto theunshareargument listVerification
cargo build --releasesucceedscargo test --package runtime -- sandbox— all 7 tests passclaw doctorshows sandbox as supported and active on a system where it previously failedBefore / After
🤖 Generated with Claude Code