Debian Codegraph @

man/systemd-nsresourced.service.xml

raw
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="systemd-nsresourced.service" conditional='ENABLE_NSRESOURCED'>
7
8 <refentryinfo>
9 <title>systemd-nsresourced.service</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>systemd-nsresourced.service</refentrytitle>
15 <manvolnum>8</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>systemd-nsresourced.service</refname>
20 <refname>systemd-nsresourced</refname>
21 <refpurpose>User Namespace Resource Delegation Service</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <para><filename>systemd-nsresourced.service</filename></para>
26 <para><filename>/usr/lib/systemd/systemd-nsresourced</filename></para>
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
32 <para><command>systemd-nsresourced</command> is a system service that permits transient delegation of a
33 UID/GID range to a user namespace (see <citerefentry
34 project='man-pages'><refentrytitle>user_namespaces</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
35 allocated by a client, via a Varlink IPC API.</para>
36
37 <para>Unprivileged clients may allocate a user namespace, and then request a UID/GID range to be assigned
38 to it via this service. The user namespace may then be used to run containers and other sandboxes, and/or
39 apply it to an id-mapped mount.</para>
40
41 <para>Allocations of UIDs/GIDs this way are transient: when a user namespace goes away, its UID/GID range
42 is returned to the pool of available ranges. In order to ensure that clients cannot gain persistency in
43 their transient UID/GID range a BPF-LSM based policy is enforced that ensures that user namespaces set up
44 this way can only write to file systems they allocate themselves or that are explicitly allowlisted via
45 <command>systemd-nsresourced</command>.</para>
46
47 <para><command>systemd-nsresourced</command> automatically ensures that any registered UID ranges show up
48 in the system's NSS database via the <ulink url="https://systemd.io/USER_GROUP_API">User/Group Record
49 Lookup API via Varlink</ulink>.</para>
50
51 <para>Currently, only UID/GID ranges consisting of either exactly 1 or exactly 65536 UIDs/GIDs can be
52 registered with this service. Moreover, UIDs and GIDs are always allocated together, and
53 symmetrically.</para>
54
55 <para>The allocation API supports <emphasis>delegated ranges</emphasis>: additional UID/GID ranges that
56 are mapped 1:1 into the user namespace rather than being translated to a target UID/GID. These delegated
57 ranges enable nested user namespace scenarios where a container needs to create child user namespaces
58 with their own transient UID ranges. Normally, the kernel restricts which UIDs can be mapped into a user
59 namespace to those that are also mapped in the parent. Delegated ranges solve this by pre-allocating
60 additional ranges that are visible inside the user namespace and can be used by nested
61 <function>AllocateUserRange()</function> calls. Up to 16 delegated ranges can be requested per user
62 namespace, each of size 65536. The ranges are allocated from the container UID ranges as per
63 <ulink url="https://systemd.io/UIDS-GIDS">Users, Groups, UIDs and GIDs on systemd Systems</ulink>.</para>
64
65 <para>The allocation API also supports <emphasis>identity mappings</emphasis>: instead of allocating a
66 transient UID/GID range, the user namespace can be configured to map the caller's UID/GID to root (UID
67 0) inside the namespace, or to itself. Identity mappings can be combined with delegated ranges to enter
68 a privileged user namespace from which the container can be set up after which the container can run in
69 one of the delegated ranges. Identity mapped users are not subject to BPF-LSM write restrictions unlike
70 the transient ranges.</para>
71
72 <para>Additionally, the allocation API supports mapping the <emphasis>foreign UID range</emphasis> into
73 the user namespace. When this option is enabled, the foreign UID range is mapped 1:1 into the user
74 namespace, allowing processes inside to access and manipulate files owned by the foreign UID range.</para>
75
76 <para>The service provides API calls to allowlist mounts (referenced via their mount file descriptors as
77 per Linux <function>fsmount()</function> API), to pass ownership of a cgroup subtree to the user
78 namespace and to delegate a virtual Ethernet device pair to the user namespace. When used in combination
79 this is sufficient to implement fully unprivileged container environments, as implemented by
80 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>, fully
81 unprivileged <varname>RootImage=</varname> (see
82 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>) or
83 fully unprivileged disk image tools such as
84 <citerefentry><refentrytitle>systemd-dissect</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
85
86 <para>This service provides one <ulink url="https://varlink.org/">Varlink</ulink> service:
87 <constant>io.systemd.NamespaceResource</constant> allows registering user namespaces, and assign mounts,
88 cgroups and network interfaces to it.</para>
89 </refsect1>
90
91 <refsect1>
92 <title>See Also</title>
93 <para><simplelist type="inline">
94 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
95 <member><citerefentry><refentrytitle>systemd-mountfsd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
96 <member><citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
97 <member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
98 <member><citerefentry><refentrytitle>systemd-dissect</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
99 <member><citerefentry project='man-pages'><refentrytitle>user_namespaces</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
100 </simplelist></para>
101 </refsect1>
102 </refentry>