Skip to content

Commit 4472a78

Browse files
author
Mrunal Patel
authored
Merge pull request #192 from Mashimiao/add-namespace-path-check
validation: add check for namespace path
2 parents 089d971 + c8b8c73 commit 4472a78

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmd/ocitools/validate.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ func checkLinux(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string)
333333
} else if spec.Linux.Namespaces[index].Type == rspec.UserNamespace {
334334
userExists = true
335335
}
336+
} else if hostCheck {
337+
_, err := os.Stat(spec.Linux.Namespaces[index].Path)
338+
if os.IsNotExist(err) {
339+
msgs = append(msgs, fmt.Sprintf("Path of %v not exist", spec.Linux.Namespaces[index].Type))
340+
} else if err != nil {
341+
msgs = append(msgs, fmt.Sprintf("%v is invalid: %s", spec.Linux.Namespaces[index].Type, err.Error()))
342+
}
336343
}
337344
}
338345

0 commit comments

Comments
 (0)