github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/builder/dockerfile/copy_windows.go (about)

     1  package dockerfile
     2  
     3  import (
     4  	"errors"
     5  	"path/filepath"
     6  	"strings"
     7  
     8  	"github.com/docker/docker/pkg/idtools"
     9  )
    10  
    11  var pathBlacklist = map[string]bool{
    12  	"c:\\":        true,
    13  	"c:\\windows": true,
    14  }
    15  
    16  func fixPermissions(source, destination string, rootIDs idtools.IDPair, overrideSkip bool) error {
    17  	// chown is not supported on Windows
    18  	return nil
    19  }
    20  
    21  func validateCopySourcePath(imageSource *imageMount, origPath, platform string) error {
    22  	// validate windows paths from other images + LCOW
    23  	if imageSource == nil || platform != "windows" {
    24  		return nil
    25  	}
    26  
    27  	origPath = filepath.FromSlash(origPath)
    28  	p := strings.ToLower(filepath.Clean(origPath))
    29  	if !filepath.IsAbs(p) {
    30  		if filepath.VolumeName(p) != "" {
    31  			if p[len(p)-2:] == ":." { // case where clean returns weird c:. paths
    32  				p = p[:len(p)-1]
    33  			}
    34  			p += "\\"
    35  		} else {
    36  			p = filepath.Join("c:\\", p)
    37  		}
    38  	}
    39  	if _, blacklisted := pathBlacklist[p]; blacklisted {
    40  		return errors.New("copy from c:\\ or c:\\windows is not allowed on windows")
    41  	}
    42  	return nil
    43  }