Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #40970 from AkihiroSuda/archive-40939-1903
Browse files Browse the repository at this point in the history
[19.03 backport] pkg/archive: escape ":" symbol in overlay lowerdir
Upstream-commit: 811a247d06e8f37cbccd2c2d9546815b912a1948
Component: engine
  • Loading branch information
tiborvass authored May 14, 2020
2 parents 765a1b5 + a36b2dc commit 23743ee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/engine/pkg/archive/archive_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ func mknodChar0Overlay(cleansedOriginalPath string) error {
if err := ioutil.WriteFile(lowerDummy, []byte{}, 0600); err != nil {
return errors.Wrapf(err, "failed to create a dummy lower file %s", lowerDummy)
}
mOpts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lower, upper, work)
// lowerdir needs ":" to be escaped: https://github.com/moby/moby/issues/40939#issuecomment-627098286
lowerEscaped := strings.ReplaceAll(lower, ":", "\\:")
mOpts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerEscaped, upper, work)
// docker/pkg/mount.Mount() requires procfs to be mounted. So we use syscall.Mount() directly instead.
if err := syscall.Mount("overlay", merged, "overlay", uintptr(0), mOpts); err != nil {
return errors.Wrapf(err, "failed to mount overlay (%s) on %s", mOpts, merged)
Expand Down Expand Up @@ -236,7 +238,9 @@ func createDirWithOverlayOpaque(tmp string) (string, error) {
if err := os.MkdirAll(lowerDummy, 0700); err != nil {
return "", errors.Wrapf(err, "failed to create a dummy lower directory %s", lowerDummy)
}
mOpts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lower, upper, work)
// lowerdir needs ":" to be escaped: https://github.com/moby/moby/issues/40939#issuecomment-627098286
lowerEscaped := strings.ReplaceAll(lower, ":", "\\:")
mOpts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerEscaped, upper, work)
// docker/pkg/mount.Mount() requires procfs to be mounted. So we use syscall.Mount() directly instead.
if err := syscall.Mount("overlay", merged, "overlay", uintptr(0), mOpts); err != nil {
return "", errors.Wrapf(err, "failed to mount overlay (%s) on %s", mOpts, merged)
Expand Down

0 comments on commit 23743ee

Please sign in to comment.