mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
integration: fix mis-use of libcontainer.Factory
For some reason, libcontainer/integration has a whole bunch of incorrect usages of libcontainer.Factory -- causing test failures with a set of security patches that will be published soon. Fixing ths is fairly trivial (switch to creating a new libcontainer.Factory once in each process, rather than creating one in TestMain globally). Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
@@ -77,6 +77,7 @@ func newTestRoot() (string, error) {
|
||||
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||
return "", err
|
||||
}
|
||||
testRoots = append(testRoots, dir)
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
@@ -127,9 +128,20 @@ func newContainer(config *configs.Config) (libcontainer.Container, error) {
|
||||
}
|
||||
|
||||
func newContainerWithName(name string, config *configs.Config) (libcontainer.Container, error) {
|
||||
f := factory
|
||||
root, err := newTestRoot()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f, err := libcontainer.New(root, libcontainer.Cgroupfs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if config.Cgroups != nil && config.Cgroups.Parent == "system.slice" {
|
||||
f = systemdFactory
|
||||
f, err = libcontainer.New(root, libcontainer.SystemdCgroups)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return f.Create(name, config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user