Skip to content

Commit 4d5210b

Browse files
author
Ma Shimiao
committed
validation: add check for namespace path
Signed-off-by: Ma Shimiao <[email protected]>
1 parent 6aeb752 commit 4d5210b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmd/ocitools/validate.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ func checkLinux(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string)
337337
} else if spec.Linux.Namespaces[index].Type == rspec.MountNamespace {
338338
mountExists = true
339339
}
340+
} else {
341+
if hostCheck {
342+
_, err := os.Stat(spec.Linux.Namespaces[index].Path)
343+
if err != nil {
344+
if os.IsNotExist(err) {
345+
msgs = append(msgs, fmt.Sprintf("Path of %v not exist", spec.Linux.Namespaces[index].Type))
346+
} else {
347+
msgs = append(msgs, fmt.Sprintf("%v is invalid: %s", spec.Linux.Namespaces[index].Type, err.Error()))
348+
}
349+
}
350+
}
340351
}
341352
}
342353

0 commit comments

Comments
 (0)