@@ -564,8 +564,8 @@ func (v *Validator) CheckLinux() (errs error) {
564564
565565 for index := 0 ; index < len (v .spec .Linux .Namespaces ); index ++ {
566566 ns := v .spec .Linux .Namespaces [index ]
567- if ! v .namespaceValid (ns ) {
568- errs = multierror .Append (errs , fmt . Errorf ( "namespace %v is invalid" , ns ) )
567+ if err := v .namespaceValid (ns ); err != nil {
568+ errs = multierror .Append (errs , err )
569569 }
570570
571571 tmpItem := nsTypeList [ns .Type ]
@@ -705,13 +705,15 @@ func (v *Validator) CheckLinux() (errs error) {
705705
706706 for _ , maskedPath := range v .spec .Linux .MaskedPaths {
707707 if ! strings .HasPrefix (maskedPath , "/" ) {
708- errs = multierror .Append (errs , fmt .Errorf ("maskedPath %v is not an absolute path" , maskedPath ))
708+ errs = multierror .Append (errs ,
709+ specerror .NewError (specerror .MaskedPathsAbs , fmt .Errorf ("maskedPath %v is not an absolute path" , maskedPath ), rspec .Version ))
709710 }
710711 }
711712
712713 for _ , readonlyPath := range v .spec .Linux .ReadonlyPaths {
713714 if ! strings .HasPrefix (readonlyPath , "/" ) {
714- errs = multierror .Append (errs , fmt .Errorf ("readonlyPath %v is not an absolute path" , readonlyPath ))
715+ errs = multierror .Append (errs ,
716+ specerror .NewError (specerror .ReadonlyPathsAbs , fmt .Errorf ("readonlyPath %v is not an absolute path" , readonlyPath ), rspec .Version ))
715717 }
716718 }
717719
@@ -889,7 +891,7 @@ func (v *Validator) rlimitValid(rlimit rspec.POSIXRlimit) (errs error) {
889891 return
890892}
891893
892- func (v * Validator ) namespaceValid (ns rspec.LinuxNamespace ) bool {
894+ func (v * Validator ) namespaceValid (ns rspec.LinuxNamespace ) error {
893895 switch ns .Type {
894896 case rspec .PIDNamespace :
895897 case rspec .NetworkNamespace :
@@ -899,14 +901,14 @@ func (v *Validator) namespaceValid(ns rspec.LinuxNamespace) bool {
899901 case rspec .UserNamespace :
900902 case rspec .CgroupNamespace :
901903 default :
902- return false
904+ return specerror . NewError ( specerror . NSTypeValueError , fmt . Errorf ( "namespace type %s may not be valid" , ns . Type ), rspec . Version )
903905 }
904906
905907 if ns .Path != "" && ! osFilepath .IsAbs (v .platform , ns .Path ) {
906- return false
908+ return specerror . NewError ( specerror . NSPathAbs , fmt . Errorf ( "path %v of namespace %v is not absolute path" , ns . Path , ns ), rspec . Version )
907909 }
908910
909- return true
911+ return nil
910912}
911913
912914func deviceValid (d rspec.LinuxDevice ) bool {
0 commit comments