mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct: earlier Rootless vs AdditionalGroups check
Since the UID/GID/AdditonalGroups fields are now numeric,
we can address the following TODO item in the code (added
by commit d2f49696 back in 2016):
> TODO: We currently can't do
> this check earlier, but if libcontainer.Process.User was typesafe
> this might work.
Move the check to much earlier phase, when we're preparing
to start a process in a container.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -302,6 +302,13 @@ func (c *Container) start(process *Process) (retErr error) {
|
||||
if c.config.Cgroups.Resources.SkipDevices {
|
||||
return errors.New("can't start container with SkipDevices set")
|
||||
}
|
||||
|
||||
if c.config.RootlessEUID && len(process.AdditionalGroups) > 0 {
|
||||
// We cannot set any additional groups in a rootless container
|
||||
// and thus we bail if the user asked us to do so.
|
||||
return errors.New("cannot set any additional groups in a rootless container")
|
||||
}
|
||||
|
||||
if process.Init {
|
||||
if c.initProcessStartTime != 0 {
|
||||
return errors.New("container already has init process")
|
||||
|
||||
Reference in New Issue
Block a user