mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
factory: use e{u,g}id as the owner of /run/runc/$id
It appears as though these semantics were not fully thought out when
implementing them for rootless containers. It is not necessary (and
could be potentially dangerous) to set the owner of /run/ctr/$id to be
the root inside the container (if user namespaces are being used).
Instead, just use the e{g,u}id of runc to determine the owner.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
@@ -162,14 +162,6 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
|
|||||||
if err := l.Validator.Validate(config); err != nil {
|
if err := l.Validator.Validate(config); err != nil {
|
||||||
return nil, newGenericError(err, ConfigInvalid)
|
return nil, newGenericError(err, ConfigInvalid)
|
||||||
}
|
}
|
||||||
uid, err := config.HostRootUID()
|
|
||||||
if err != nil {
|
|
||||||
return nil, newGenericError(err, SystemError)
|
|
||||||
}
|
|
||||||
gid, err := config.HostRootGID()
|
|
||||||
if err != nil {
|
|
||||||
return nil, newGenericError(err, SystemError)
|
|
||||||
}
|
|
||||||
containerRoot := filepath.Join(l.Root, id)
|
containerRoot := filepath.Join(l.Root, id)
|
||||||
if _, err := os.Stat(containerRoot); err == nil {
|
if _, err := os.Stat(containerRoot); err == nil {
|
||||||
return nil, newGenericError(fmt.Errorf("container with id exists: %v", id), IdInUse)
|
return nil, newGenericError(fmt.Errorf("container with id exists: %v", id), IdInUse)
|
||||||
@@ -179,7 +171,7 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
|
|||||||
if err := os.MkdirAll(containerRoot, 0711); err != nil {
|
if err := os.MkdirAll(containerRoot, 0711); err != nil {
|
||||||
return nil, newGenericError(err, SystemError)
|
return nil, newGenericError(err, SystemError)
|
||||||
}
|
}
|
||||||
if err := os.Chown(containerRoot, uid, gid); err != nil {
|
if err := os.Chown(containerRoot, unix.Geteuid(), unix.Getegid()); err != nil {
|
||||||
return nil, newGenericError(err, SystemError)
|
return nil, newGenericError(err, SystemError)
|
||||||
}
|
}
|
||||||
if config.Rootless {
|
if config.Rootless {
|
||||||
|
|||||||
Reference in New Issue
Block a user