Skip to content

unshare: support for systemd-nsresourced, --map-foreign option - #4560

Draft
Skyb0rg007 wants to merge 1 commit into
util-linux:masterfrom
Skyb0rg007:unshare-nsresourced
Draft

unshare: support for systemd-nsresourced, --map-foreign option#4560
Skyb0rg007 wants to merge 1 commit into
util-linux:masterfrom
Skyb0rg007:unshare-nsresourced

Conversation

@Skyb0rg007

Copy link
Copy Markdown
Contributor

Adds the --map-foreign option, which uses systemd-nsresourced.service(8) to setup the uid and gid maps, specifically for asking the service to map the foreign UID range. The --map-current-user and --map-root-user options are also compatible: --map-current-user is the default, and --map-root-user translates into "target": 0.

systemd-nsresourced has other options, but the primary use case that I envision unshare to be used for is to manage files owned by the foreign-0-foreign-65534 UIDs and GIDs.
Specifically, running unshare --map-foreign --map-root-user -- rm -rf ./dir to delete local files that were created using systemd-nspawn(1) or systemd-mountfsd.service(8)'s io.systemd.MountFileSystem.MakeDirectory Varlink method.

The important thing to note is that the foreign UID range is a systemd concept, so newuidmap is 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.

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
Skyb0rg007 marked this pull request as draft August 13, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant