@@ -560,8 +560,8 @@ func (v *Validator) CheckLinux() (errs error) {
560560
561561 for index := 0 ; index < len (v .spec .Linux .Namespaces ); index ++ {
562562 ns := v .spec .Linux .Namespaces [index ]
563- if ! v .namespaceValid (ns ) {
564- errs = multierror .Append (errs , fmt . Errorf ( "namespace %v is invalid" , ns ) )
563+ if err := v .namespaceValid (ns ); err != nil {
564+ errs = multierror .Append (errs , err )
565565 }
566566
567567 tmpItem := nsTypeList [ns .Type ]
@@ -701,13 +701,15 @@ func (v *Validator) CheckLinux() (errs error) {
701701
702702 for _ , maskedPath := range v .spec .Linux .MaskedPaths {
703703 if ! strings .HasPrefix (maskedPath , "/" ) {
704- errs = multierror .Append (errs , fmt .Errorf ("maskedPath %v is not an absolute path" , maskedPath ))
704+ errs = multierror .Append (errs ,
705+ specerror .NewError (specerror .MaskedPathsAbs , fmt .Errorf ("maskedPath %v is not an absolute path" , maskedPath ), rspec .Version ))
705706 }
706707 }
707708
708709 for _ , readonlyPath := range v .spec .Linux .ReadonlyPaths {
709710 if ! strings .HasPrefix (readonlyPath , "/" ) {
710- errs = multierror .Append (errs , fmt .Errorf ("readonlyPath %v is not an absolute path" , readonlyPath ))
711+ errs = multierror .Append (errs ,
712+ specerror .NewError (specerror .ReadonlyPathsAbs , fmt .Errorf ("readonlyPath %v is not an absolute path" , readonlyPath ), rspec .Version ))
711713 }
712714 }
713715
@@ -885,7 +887,7 @@ func (v *Validator) rlimitValid(rlimit rspec.POSIXRlimit) (errs error) {
885887 return
886888}
887889
888- func (v * Validator ) namespaceValid (ns rspec.LinuxNamespace ) bool {
890+ func (v * Validator ) namespaceValid (ns rspec.LinuxNamespace ) error {
889891 switch ns .Type {
890892 case rspec .PIDNamespace :
891893 case rspec .NetworkNamespace :
@@ -895,14 +897,14 @@ func (v *Validator) namespaceValid(ns rspec.LinuxNamespace) bool {
895897 case rspec .UserNamespace :
896898 case rspec .CgroupNamespace :
897899 default :
898- return false
900+ return specerror . NewError ( specerror . NamespacesType , fmt . Errorf ( "namespace type %s may not be valid" , ns . Type ), rspec . Version )
899901 }
900902
901903 if ns .Path != "" && ! osFilepath .IsAbs (v .platform , ns .Path ) {
902- return false
904+ return specerror . NewError ( specerror . NamespacesPathAbs , fmt . Errorf ( "path %v of namespace %v is not absolute path" , ns . Path , ns ), rspec . Version )
903905 }
904906
905- return true
907+ return nil
906908}
907909
908910func deviceValid (d rspec.LinuxDevice ) bool {
0 commit comments