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:
Aleksa Sarai
2019-01-19 21:54:46 +11:00
parent c1e454b2a1
commit 565325fc36
3 changed files with 36 additions and 97 deletions
+14 -2
View File
@@ -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)
}