Skip to content

Commit 8bec9e3

Browse files
Ma Shimiaowking
authored andcommitted
validation: add check for namespace path
Signed-off-by: Ma Shimiao <[email protected]> Backported to v1.0.0.rc1 from c8b8c73 #192 (cherry-pick applied cleanly). Signed-off-by: W. Trevor King <[email protected]>
1 parent 9b4706c commit 8bec9e3

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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)