Skip to content

Commit 7a436fd

Browse files
committed
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. Additionally, 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. The tests about uid/gid mappings now pass with runc: ``` $ sudo validation/linux_uid_mappings.t TAP version 13 not ok 1 - root filesystem --- { "error": "rootfs must not be readonly\nRefer to: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#root" } ... ok 2 - hostname ok 3 - process ok 4 - mounts ok 5 - user ok 6 - rlimits ok 7 - capabilities ok 8 - default symlinks ok 9 - default file system ok 10 - default devices ok 11 - linux devices ok 12 - linux process ok 13 - masked paths ok 14 - oom score adj ok 1 # SKIP syscall action SCMP_ACT_ALLOW ok 2 # SKIP syscall action SCMP_ACT_ALLOW ok 3 # SKIP syscall action SCMP_ACT_ALLOW ok 4 # SKIP syscall action SCMP_ACT_ALLOW ok 5 # SKIP syscall action SCMP_ACT_ALLOW ok 6 # SKIP syscall action SCMP_ACT_ALLOW ok 15 - seccomp ok 16 - read only paths ok 17 - rootfs propagation ok 18 - sysctls ok 19 - uid mappings ok 20 - gid mappings 1..20 ``` Signed-off-by: Alban Crequy <[email protected]>
1 parent be1c11f commit 7a436fd

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

validation/linux_gid_mappings.go

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

validation/linux_uid_mappings.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import (
77
func main() {
88
g := util.GetDefaultGenerator()
99
g.AddOrReplaceLinuxNamespace("user", "")
10-
g.AddLinuxUIDMapping(uint32(1000), uint32(0), uint32(3200))
10+
g.AddLinuxUIDMapping(uint32(1000), uint32(0), uint32(2000))
11+
g.AddLinuxGIDMapping(uint32(1000), uint32(0), uint32(3000))
1112
err := util.RuntimeInsideValidate(g, nil)
1213
if err != nil {
1314
util.Fatal(err)

0 commit comments

Comments
 (0)