From 92b9be44c43bf37434bc79629d1aa89a8e2adf01 Mon Sep 17 00:00:00 2001 From: Ma Shimiao Date: Wed, 17 Aug 2016 10:33:15 +0800 Subject: [PATCH] validation: add check for namespace path Signed-off-by: Ma Shimiao Backported to v1.0.0.rc1 from c8b8c73 #192 (cherry-pick applied cleanly). Signed-off-by: W. Trevor King --- cmd/oci-runtime-tool/validate.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/oci-runtime-tool/validate.go b/cmd/oci-runtime-tool/validate.go index 6c37147a5..b99144488 100644 --- a/cmd/oci-runtime-tool/validate.go +++ b/cmd/oci-runtime-tool/validate.go @@ -333,6 +333,13 @@ func checkLinux(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string) } else if spec.Linux.Namespaces[index].Type == rspec.UserNamespace { userExists = true } + } else if hostCheck { + _, err := os.Stat(spec.Linux.Namespaces[index].Path) + if os.IsNotExist(err) { + msgs = append(msgs, fmt.Sprintf("Path of %v not exist", spec.Linux.Namespaces[index].Type)) + } else if err != nil { + msgs = append(msgs, fmt.Sprintf("%v is invalid: %s", spec.Linux.Namespaces[index].Type, err.Error())) + } } }