90525c
From 0ef48896d9f23b9fd547a532a4e6e6b8f8b12901 Mon Sep 17 00:00:00 2001
90525c
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
90525c
Date: Wed, 23 Nov 2022 16:09:56 +0100
90525c
Subject: [PATCH 2/2] pam: add a call to pam_namespace
90525c
90525c
A call to pam_namespace is required so that children of user@.service end up in
90525c
a namespace as expected. pam_namespace gets called as part of the stack that
90525c
creates a session (login, sshd, gdm, etc.) and those processes end up in a
90525c
namespace, but it also needs to be called from our stack which is parallel and
90525c
descends from pid1 itself.
90525c
90525c
The call to pam_namespace is similar to the call to pam_keyinit that was added
90525c
in ab79099d1684457d040ee7c28b2012e8c1ea9a4f. The pam stack for user@.service
90525c
creates a new session which is disconnected from the parent environment. Both
90525c
calls are not suitable for inclusion in the shared part of the stack (e.g.
90525c
@system-auth on Fedora/RHEL systems), because for example su/sudo/runuser
90525c
should not include them.
90525c
90525c
Fixes #17043 (Allow to execute user service into dedicated namespace
90525c
              if pam_namespace enabled)
90525c
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1861836
90525c
(Polyinstantiation is ignored/bypassed in GNOME sessions)
90525c
---
90525c
 src/login/systemd-user.in | 1 +
90525c
 1 file changed, 1 insertion(+)
90525c
90525c
diff --git a/src/login/systemd-user.in b/src/login/systemd-user.in
90525c
index d5597d28cb..06f7e36458 100644
90525c
--- a/src/login/systemd-user.in
90525c
+++ b/src/login/systemd-user.in
90525c
@@ -15,6 +15,7 @@ session  required pam_selinux.so nottys open
90525c
 {% endif %}
90525c
 session  required pam_loginuid.so
90525c
 session  optional pam_keyinit.so force revoke
90525c
+session  required pam_namespace.so
90525c
 {% if ENABLE_HOMED %}
90525c
 -session  optional pam_systemd_home.so
90525c
 {% endif %}
90525c
-- 
90525c
2.38.1
90525c