merge branch 'pr-1114'

LGTMs: @hqhq @cyphar
Closes: #1114
This commit is contained in:
Aleksa Sarai 2016-10-16 22:27:15 +11:00
commit 7be6edaa60
No known key found for this signature in database
GPG Key ID: 9E18AA267DDB8DB4
1 changed files with 13 additions and 0 deletions

13
spec.go
View File

@ -240,6 +240,9 @@ func loadSpec(cPath string) (spec *specs.Spec, err error) {
if err = json.NewDecoder(cf).Decode(&spec); err != nil {
return nil, err
}
if err = validatePlatform(&spec.Platform); err != nil {
return nil, err
}
return spec, validateProcessSpec(&spec.Process)
}
@ -254,3 +257,13 @@ func createLibContainerRlimit(rlimit specs.Rlimit) (configs.Rlimit, error) {
Soft: uint64(rlimit.Soft),
}, nil
}
func validatePlatform(platform *specs.Platform) error {
if platform.OS != runtime.GOOS {
return fmt.Errorf("target os %s mismatch with current os %s", platform.OS, runtime.GOOS)
}
if platform.Arch != runtime.GOARCH {
return fmt.Errorf("target arch %s mismatch with current arch %s", platform.Arch, runtime.GOARCH)
}
return nil
}