diff --git a/validate.go b/validate.go index df46e3e1c..c63aed31c 100644 --- a/validate.go +++ b/validate.go @@ -87,7 +87,7 @@ func bundleValidate(spec rspec.Spec, rootfs string) { checkPlatform(spec.Platform) checkProcess(spec.Process, rootfs) checkMounts(spec.Mounts, rootfs) - checkLinux(spec.Linux, rootfs) + checkLinux(spec.Linux, spec.Hostname, rootfs) } func checkSemVer(version string) { @@ -166,7 +166,9 @@ func checkProcess(process rspec.Process, rootfs string) { } //Linux only -func checkLinux(spec rspec.Linux, rootfs string) { +func checkLinux(spec rspec.Linux, hostname string, rootfs string) { + utsExists := false + if len(spec.UIDMappings) > 5 { logrus.Fatalf("Only 5 UID mappings are allowed (linux kernel restriction).") } @@ -177,9 +179,15 @@ func checkLinux(spec rspec.Linux, rootfs string) { for index := 0; index < len(spec.Namespaces); index++ { if !namespaceValid(spec.Namespaces[index]) { logrus.Fatalf("namespace %v is invalid.", spec.Namespaces[index]) + } else if spec.Namespaces[index].Type == rspec.UTSNamespace { + utsExists = true } } + if !utsExists && hostname != "" { + logrus.Fatalf("New UTS namespace should to be created.") + } + for index := 0; index < len(spec.Devices); index++ { if !deviceValid(spec.Devices[index]) { logrus.Fatalf("device %v is invalid.", spec.Devices[index])