diff --git a/validate.go b/validate.go index f5a795958..28d2ed20a 100644 --- a/validate.go +++ b/validate.go @@ -83,7 +83,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) { @@ -152,7 +152,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) { + utsExist := false + if len(spec.UIDMappings) > 5 { logrus.Fatalf("Only 5 UID mappings are allowed (linux kernel restriction).") } @@ -163,9 +165,15 @@ func checkLinux(spec rspec.Linux, rootfs string) { for index := 0; index < len(spec.Namespaces); index++ { if !namespaceValid(spec.Namespaces[index]) { logrus.Fatalf("Namespace %s is invalid.", spec.Namespaces[index]) + } else if spec.Namespaces[index].Type == rspec.UTSNamespace { + utsExist = true } } + if !utsExist && 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 %s is invalid.", spec.Devices[index].Path)