]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: Only apply unprivileged userns logic to user managers
authorChris Down <chris@chrisdown.name>
Wed, 5 Nov 2025 10:41:17 +0000 (18:41 +0800)
committerChris Down <chris@chrisdown.name>
Wed, 5 Nov 2025 13:12:52 +0000 (21:12 +0800)
commit666cd35be493e2d796c5424eed9a3deeddc9b0fe
treee903cf7771cd121af787cf67d816e292aac38c99
parent3a2c46dfbe318a44375acbc155c8e3ed87cc31d0
core: Only apply unprivileged userns logic to user managers

Commit 38748596f078 ("core: Make DelegateNamespaces= work for user
managers with CAP_SYS_ADMIN") refactored the logic for when an
unprivileged process should create a new user namespace for sandboxing.

This refactor inadvertently removed a check (`params->runtime_scope !=
RUNTIME_SCOPE_USER`) that differentiated between system services and user
services.

This causes a regression in rootless containers where systemd runs
unprivileged. When starting a system service (like `dbus-broker`) that
uses sandboxing features (eg. with `PrivateTmp=yes`), systemd now
incorrectly creates a new, minimal `PRIVATE_USERS_SELF` namespace.

This new namespace only maps UID/GID 0. When dbus-broker attempts to
drop privileges to the `dbus` user (GID 81), the `setresgid(81, 81, 81)`
call fails because GID 81 is not mapped.

Restore the check to ensure that the special unprivileged sandboxing
logic is only applied to user services, as was the original intent.
System services in a rootless context will now correctly run in the
container's main user namespace, where all necessary UIDs/GIDs are
mapped.

Fixes: https://github.com/systemd/systemd/issues/39563
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2391343
src/core/exec-invoke.c