]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Also check if we can mount /proc if pid namespace is delegated
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 17 Mar 2025 15:17:25 +0000 (16:17 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 19 Mar 2025 09:00:45 +0000 (10:00 +0100)
If the pid namespace is delegated, it doesn't matter if we have CAP_SYS_ADMIN,
we'll still fail to mount /proc if part of it is masked on the host so also
check if we can mount /proc if the pid namespace is delegated.

src/core/exec-invoke.c

index 9b21e385a89f4a8e95b1902448b862fd39d38423..e69c65feca5e3aa19aa00f59e19c77d2ecb3bb2c 100644 (file)
@@ -4391,7 +4391,7 @@ static int setup_delegated_namespaces(
                  * We need to check prior to entering the user namespace because if we're running unprivileged or in a
                  * system without CAP_SYS_ADMIN, then we can have CAP_SYS_ADMIN in the current user namespace but not
                  * once we unshare a mount namespace. */
-                if (!have_cap_sys_admin) {
+                if (!have_cap_sys_admin || delegate) {
                         r = can_mount_proc(context, params);
                         if (r < 0) {
                                 *reterr_exit_status = EXIT_NAMESPACE;