]> git.ipfire.org Git - thirdparty/systemd.git/commit
nsresourced: Add support for delegated ranges
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 23 Jan 2026 11:31:47 +0000 (12:31 +0100)
committerDaan De Meyer <daan@amutable.com>
Tue, 24 Feb 2026 17:29:37 +0000 (18:29 +0100)
commit025439faaa8c053fab9fd01fb5f45fb819408bc5
tree24398883a9788425d792d29737ac765794864d74
parent6c2d4375852eb726d7f538ad938c27a22bf905fd
nsresourced: Add support for delegated ranges

We want to support the scenario where we bind mount the nsresourced
varlink socket into a container to allow nested containers where the
outer container runs in its own transient range from nsresourced but
can still allocate transient ranges for its own nested containers.

To support this use case let's add support for delegation. Delegated
ranges are allocated when allocating the primary range and are propagated
1:1 to the user namespace. We track delegated ranges in ".delegate" files
in the userns registry so that they can't be used for other range allocations.

We make one exception for delegated ranges though, if we get a request from
a user namespace that is a child of the user namespace that owns the delegated
ranges, we allow allocating from the delegated range. The parent userns already
has full ownership over the child userns, so it doesn't matter that the parent
userns and the child userns share the same range. This allows making use of
delegated ranges without having to run another copy of nsresourced inside the
parent userns to hand out from the delegated range.

To support recursive delegations, we keep track of the previous owners of the
delegated range and restore ownership to the last previous owner when the current
owner is freed.
man/systemd-nsresourced.service.xml
src/basic/uid-range.c
src/basic/uid-range.h
src/nsresourced/nsresourcework.c
src/nsresourced/userns-registry.c
src/nsresourced/userns-registry.h
src/shared/varlink-io.systemd.NamespaceResource.c
src/test/test-uid-range.c
test/units/TEST-50-DISSECT.mountfsd.sh