user: allow setting multiple groups without user namespaces
authorPatrick Steinhardt <ps@pks.im>
Thu, 20 Jun 2019 09:45:27 +0000 (11:45 +0200)
committerPatrick Steinhardt <ps@pks.im>
Thu, 20 Jun 2019 10:12:16 +0000 (12:12 +0200)
commit91848d22bfe534e3bd11360d3cef26a3103ff0f9
treea18694a602794911466e90154bdefc6066fc05e1
parent83a28cd0d3ebc54a4e34832e6e017d3e465a1fc3
user: allow setting multiple groups without user namespaces

When not using a user namespace, then we'll completely ignore
whether multiple groups have been specified by the user and only set
up the process's GID. With user namespaces, we in fact cannot set up
supplementary groups as we have set up "/proc/self/setgroups" to
deny any call to setgroups(2). But we can do better than that when
not using user namespaces, as we're free to use that syscall.

As nsjail(1) documents that "--group" can be specified multiple
times without mentioning that this won't work with
"--disable_clone_newuser", change the code to make that
constellation work.
user.cc