Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions specerror/config-linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
const (
// DefaultFilesystems represents "The following filesystems SHOULD be made available in each container's filesystem:"
DefaultFilesystems Code = 0xc001 + iota

// NSTypeValueError represents "The following namespace types are supported:"
NSTypeValueError
// NSPathAbs represents "This value MUST be an absolute path in the runtime mount namespace."
NSPathAbs
// NSProcInPath represents "The runtime MUST place the container process in the namespace associated with that `path`."
Expand Down Expand Up @@ -105,6 +108,7 @@ var (

func init() {
register(DefaultFilesystems, rfc2119.Should, defaultFilesystemsRef)
register(NSTypeValueError, rfc2119.Should, namespacesRef)
register(NSPathAbs, rfc2119.Must, namespacesRef)
register(NSProcInPath, rfc2119.Must, namespacesRef)
register(NSPathMatchTypeError, rfc2119.Must, namespacesRef)
Expand Down
12 changes: 6 additions & 6 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ func (v *Validator) CheckLinux() (errs error) {

for index := 0; index < len(v.spec.Linux.Namespaces); index++ {
ns := v.spec.Linux.Namespaces[index]
if !v.namespaceValid(ns) {
errs = multierror.Append(errs, fmt.Errorf("namespace %v is invalid", ns))
if err := v.namespaceValid(ns); err != nil {
errs = multierror.Append(errs, err)
}

tmpItem := nsTypeList[ns.Type]
Expand Down Expand Up @@ -936,7 +936,7 @@ func (v *Validator) rlimitValid(rlimit rspec.POSIXRlimit) (errs error) {
return
}

func (v *Validator) namespaceValid(ns rspec.LinuxNamespace) bool {
func (v *Validator) namespaceValid(ns rspec.LinuxNamespace) error {
switch ns.Type {
case rspec.PIDNamespace:
case rspec.NetworkNamespace:
Expand All @@ -946,14 +946,14 @@ func (v *Validator) namespaceValid(ns rspec.LinuxNamespace) bool {
case rspec.UserNamespace:
case rspec.CgroupNamespace:
default:
return false
return specerror.NewError(specerror.NSTypeValueError, fmt.Errorf("namespace type %s may not be valid", ns.Type), rspec.Version)
}

if ns.Path != "" && !osFilepath.IsAbs(v.platform, ns.Path) {
return false
return specerror.NewError(specerror.NSPathAbs, fmt.Errorf("path %v of namespace %v is not absolute path", ns.Path, ns), rspec.Version)
}

return true
return nil
}

func deviceValid(d rspec.LinuxDevice) bool {
Expand Down