Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions cmd/ocitools/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,7 @@ func checkLinux(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string)
ipcExists := false
mountExists := false
netExists := false

if len(spec.Linux.UIDMappings) > 5 {
msgs = append(msgs, "Only 5 UID mappings are allowed (linux kernel restriction).")
}
if len(spec.Linux.GIDMappings) > 5 {
msgs = append(msgs, "Only 5 GID mappings are allowed (linux kernel restriction).")
}
userExists := false

for index := 0; index < len(spec.Linux.Namespaces); index++ {
if !namespaceValid(spec.Linux.Namespaces[index]) {
Expand All @@ -336,10 +330,20 @@ func checkLinux(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string)
netExists = true
} else if spec.Linux.Namespaces[index].Type == rspec.MountNamespace {
mountExists = true
} else if spec.Linux.Namespaces[index].Type == rspec.UserNamespace {
userExists = true
}
}
}

if (len(spec.Linux.UIDMappings) > 0 || len(spec.Linux.GIDMappings) > 0) && !userExists {
msgs = append(msgs, "UID/GID mappings requires a new User namespace to be specified as well")
} else if len(spec.Linux.UIDMappings) > 5 {
msgs = append(msgs, "Only 5 UID mappings are allowed (linux kernel restriction).")
} else if len(spec.Linux.GIDMappings) > 5 {
msgs = append(msgs, "Only 5 GID mappings are allowed (linux kernel restriction).")
}

for k := range spec.Linux.Sysctl {
if strings.HasPrefix(k, "net.") && !netExists {
msgs = append(msgs, fmt.Sprintf("Sysctl %v requires a new Network namespace to be specified as well", k))
Expand Down