Skip to content
This repository was archived by the owner on Apr 21, 2021. It is now read-only.

Commit 0247f07

Browse files
committed
[WIP][RFC] validation: LinuxUIDMapping: fix tests
Don't validate uid mappings and gid mappings separately: containers with only user mappings or with only group mappings are not usable. Additionnally, don't rely on the runtime to create the directories to be mounted. runc mounts them in the easy cases but it does not work with user namespaces. Marking as WIP/RFC because this is in discussion in opencontainers/runtime-spec#955 Signed-off-by: Alban Crequy <[email protected]>
1 parent fdbc3d6 commit 0247f07

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

validation/linux_gid_mappings.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

validation/linux_uid_mappings.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
11
package main
22

33
import (
4+
"os"
5+
"path/filepath"
6+
47
"github.com/opencontainers/runtime-tools/validation/util"
58
)
69

10+
func mkdir(path, subdir string) error {
11+
pathName := filepath.Join(path, subdir)
12+
err := os.MkdirAll(pathName, 0700)
13+
if err != nil {
14+
return err
15+
}
16+
err = os.Chown(pathName, 1000, 1000)
17+
if err != nil {
18+
return err
19+
}
20+
21+
return nil
22+
}
23+
724
func main() {
825
g := util.GetDefaultGenerator()
926
g.AddOrReplaceLinuxNamespace("user", "")
10-
g.AddLinuxUIDMapping(uint32(1000), uint32(0), uint32(3200))
11-
err := util.RuntimeInsideValidate(g, nil)
27+
g.AddLinuxUIDMapping(uint32(1000), uint32(0), uint32(2000))
28+
g.AddLinuxGIDMapping(uint32(1000), uint32(0), uint32(3000))
29+
err := util.RuntimeInsideValidate(g, func(path string) error {
30+
_ = mkdir(path, "proc")
31+
_ = mkdir(path, "dev")
32+
_ = mkdir(path, "sys")
33+
34+
return nil
35+
})
1236
if err != nil {
1337
util.Fatal(err)
1438
}

0 commit comments

Comments
 (0)