Skip to content

Commit c8b8c73

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

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
@@ -337,6 +337,13 @@ 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 if hostCheck {
341+
_, err := os.Stat(spec.Linux.Namespaces[index].Path)
342+
if os.IsNotExist(err) {
343+
msgs = append(msgs, fmt.Sprintf("Path of %v not exist", spec.Linux.Namespaces[index].Type))
344+
} else if err != nil {
345+
msgs = append(msgs, fmt.Sprintf("%v is invalid: %s", spec.Linux.Namespaces[index].Type, err.Error()))
346+
}
340347
}
341348
}
342349

0 commit comments

Comments
 (0)