unshare: support for systemd-nsresourced, --map-foreign option - #4560
Draft
Skyb0rg007 wants to merge 1 commit into
Draft
unshare: support for systemd-nsresourced, --map-foreign option#4560Skyb0rg007 wants to merge 1 commit into
--map-foreign option#4560Skyb0rg007 wants to merge 1 commit into
Conversation
Adds the `--map-foreign` option, which uses systemd-nsresourced to setup the uid and gid maps, additionally asking the service to map the foreign UID range. The `--map-current-user` and `--map-root-user` options are also compatible.
Skyb0rg007
marked this pull request as draft
August 13, 2026 23:14
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.
Adds the
--map-foreignoption, which usessystemd-nsresourced.service(8)to setup the uid and gid maps, specifically for asking the service to map the foreign UID range. The--map-current-userand--map-root-useroptions are also compatible:--map-current-useris the default, and--map-root-usertranslates into"target": 0.systemd-nsresourcedhas other options, but the primary use case that I envisionunshareto be used for is to manage files owned by theforeign-0-foreign-65534UIDs and GIDs.Specifically, running
unshare --map-foreign --map-root-user -- rm -rf ./dirto delete local files that were created usingsystemd-nspawn(1)orsystemd-mountfsd.service(8)'sio.systemd.MountFileSystem.MakeDirectoryVarlink method.The important thing to note is that the foreign UID range is a systemd concept, so
newuidmapis not usually able to map those uids into the user namespace.This is a draft PR to garner feedback, as this is a new idea.