core: add 'DefaultRestrictSUIDSGID' config option (#38126)

closes #37602, see there for extra motivation and considered
alternatives.

On typical systems, only few services need to create SUID/SGID files.
This often is limited to the user explicitly setting suid/sgid, the
`systemd-tmpfiles*` services, and the package manager. Allowing a
default to globally restrict creation of suid/sgid files makes it easier
to apply this restriction precisely.

## testing done
- built on aarch64-linux and x86_64-linux
- ran a VM test on x86_64-linux, checking for:
    - VM system boots successfully
    - defaults apply (both `yes`, `no`, and undefined)
    - systemd tmpfiles can set suid/sgid on journal log path
- Other services explicitly defining `RestrictSUIDSGID=no` can create
suid files
This commit is contained in:
Yu Watanabe
2025-07-10 13:30:07 +09:00
committed by GitHub
13 changed files with 38 additions and 2 deletions
+5 -1
View File
@@ -2690,7 +2690,11 @@ RestrictNamespaces=~cgroup net</programlisting>
programs that actually require them. Note that this restricts marking of any type of file system
object with these bits, including both regular files and directories (where the SGID is a different
meaning than for files, see documentation). This option is implied if <varname>DynamicUser=</varname>
is enabled. Defaults to off.</para>
is enabled.</para>
<para>In other cases, this setting defaults to the value set with <varname>DefaultRestrictSUIDSGID=</varname> in
<citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, which
defaults to off.</para>
<xi:include href="version-info.xml" xpointer="v242"/></listitem>
</varlistentry>