mirror of
https://github.com/opencontainers/runc.git
synced 2025-09-26 19:41:35 +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")
|
||||
|
@@ -438,14 +438,6 @@ func syncParentSeccomp(pipe *syncSocket, seccompFd int) error {
|
||||
|
||||
// setupUser changes the groups, gid, and uid for the user inside the container.
|
||||
func setupUser(config *initConfig) error {
|
||||
if config.RootlessEUID && len(config.AdditionalGroups) > 0 {
|
||||
// We cannot set any additional groups in a rootless container and thus
|
||||
// we bail if the user asked us to do so. TODO: We currently can't do
|
||||
// this check earlier, but if libcontainer.Process.User was typesafe
|
||||
// this might work.
|
||||
return errors.New("cannot set any additional groups in a rootless container")
|
||||
}
|
||||
|
||||
// Before we change to the container's user make sure that the processes
|
||||
// STDIO is correctly owned by the user that we are switching to.
|
||||
if err := fixStdioPermissions(config.UID); err != nil {
|
||||
|
Reference in New Issue
Block a user