Skip to content

Commit 8043e83

Browse files
author
Dongsu Park
committed
validation: enable UID/GID mappings for userns, add comments
Enable UID/GID mappings for user namespaces, to be able to test user namespaces with most container runtimes. According to discussions in opencontainers/runtime-spec#961, it's clear that we can safely enable UID/GID mappings. Also add some comments about cgroup namespaces, which is not supported by runc yet. Signed-off-by: Dongsu Park <[email protected]>
1 parent 1ceca9e commit 8043e83

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

validation/linux_ns_path.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ func checkNamespacePath(unsharePid int, ns string) error {
111111
// existing userns. Anyway in reality, we should set up uid/gid
112112
// mappings, to make userns work in most runtimes.
113113
// See https://github.com/opencontainers/runtime-spec/issues/961
114-
// if ns == "user" {
115-
// g.AddLinuxUIDMapping(uint32(1000), uint32(0), uint32(1000))
116-
// g.AddLinuxGIDMapping(uint32(1000), uint32(0), uint32(1000))
117-
// }
114+
if ns == "user" {
115+
g.AddLinuxUIDMapping(uint32(1000), uint32(0), uint32(1000))
116+
g.AddLinuxGIDMapping(uint32(1000), uint32(0), uint32(1000))
117+
}
118118

119119
return util.RuntimeOutsideValidate(g, func(config *rspec.Spec, state *rspec.State) error {
120120
containerNsPath := fmt.Sprintf("/proc/%d/ns/%s", state.Pid, ns)
@@ -160,6 +160,9 @@ func main() {
160160
t := tap.New()
161161
t.Header(0)
162162

163+
// NOTE: cgroup namespaces test will fail when testing with runc, because
164+
// a PR for runc to support cgroup namespaces,
165+
// https://github.com/opencontainers/runc/pull/1184, has not been merged.
163166
cases := []struct {
164167
name string
165168
unshareOpt string

0 commit comments

Comments
 (0)