Skip to content

Commit

Permalink
validation: add hostname validation
Browse files Browse the repository at this point in the history
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
  • Loading branch information
Ma Shimiao committed May 20, 2016
1 parent 037ba51 commit 9fe6309
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -152,7 +152,7 @@ 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) {
if len(spec.UIDMappings) > 5 {
logrus.Fatalf("Only 5 UID mappings are allowed (linux kernel restriction).")
}
Expand All @@ -163,6 +163,8 @@ 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 && hostname != "" {
logrus.Fatalf("New UTS namespace should to be created.")
}
}

Expand Down

0 comments on commit 9fe6309

Please sign in to comment.