copy_windows.go 932 B

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