]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
start: Respect lxc.init.groups also in new user namespace 4626/head
authorFilip Schauer <f.schauer@proxmox.com>
Mon, 15 Dec 2025 15:03:43 +0000 (16:03 +0100)
committerFiliprogrammer <44641787+Filiprogrammer@users.noreply.github.com>
Mon, 15 Dec 2025 19:27:50 +0000 (20:27 +0100)
Fix supplementary groups defined in 'lxc.init.groups' being ignored when
the container uses a new user namespace.

In other words: Fix lxc.init.groups for unprivileged containers.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
src/lxc/start.c

index 4927faf9528ea353d0b37a8e2039697744b05372..b5ca683dbdbc3738e640be6932b049dc52c17a74 100644 (file)
@@ -1603,17 +1603,19 @@ static int do_start(void *data)
                if (lxc_proc_cap_is_set(CAP_SETGID, CAP_EFFECTIVE))
                #endif
                {
-                       if (handler->conf->init_groups.size > 0) {
-                               if (!lxc_setgroups(handler->conf->init_groups.list,
-                                                  handler->conf->init_groups.size))
-                                       goto out_warn_father;
-                       } else {
+                       if (handler->conf->init_groups.size == 0) {
                                if (!lxc_drop_groups())
                                        goto out_warn_father;
                        }
                }
        }
 
+       if (handler->conf->init_groups.size > 0) {
+               if (!lxc_setgroups(handler->conf->init_groups.list,
+                                  handler->conf->init_groups.size))
+                       goto out_warn_father;
+       }
+
        if (!lxc_switch_uid_gid(new_uid, new_gid))
                goto out_warn_father;