@@ -30,7 +30,6 @@ import (
3030 "github.com/docker/docker/layer"
3131 libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
3232 "github.com/docker/docker/oci"
33- "github.com/docker/docker/pkg/containerfs"
3433 "github.com/docker/docker/pkg/idtools"
3534 "github.com/docker/docker/pkg/ioutils"
3635 "github.com/docker/docker/restartmanager"
@@ -345,7 +344,7 @@ func (container *Container) GetResourcePath(path string) (string, error) {
345344 }
346345 // IMPORTANT - These are paths on the OS where the daemon is running, hence
347346 // any filepath operations must be done in an OS-agnostic way.
348- r , e := symlink .FollowSymlinkInScope (filepath .Join (container .BaseFS , containerfs . CleanScopedPath (path )), container .BaseFS )
347+ r , e := symlink .FollowSymlinkInScope (filepath .Join (container .BaseFS , cleanScopedPath (path )), container .BaseFS )
349348
350349 // Log this here on the daemon side as there's otherwise no indication apart
351350 // from the error being propagated all the way back to the client. This makes
@@ -356,6 +355,18 @@ func (container *Container) GetResourcePath(path string) (string, error) {
356355 return r , e
357356}
358357
358+ // cleanScopedPath prepares the given path to be combined with a mount path or
359+ // a drive-letter. On Windows, it removes any existing driveletter (e.g. "C:").
360+ // The returned path is always prefixed with a [filepath.Separator].
361+ func cleanScopedPath (path string ) string {
362+ if len (path ) >= 2 {
363+ if v := filepath .VolumeName (path ); len (v ) > 0 {
364+ path = path [len (v ):]
365+ }
366+ }
367+ return filepath .Join (string (filepath .Separator ), path )
368+ }
369+
359370// GetRootResourcePath evaluates `path` in the scope of the container's root, with proper path
360371// sanitisation. Symlinks are all scoped to the root of the container, as
361372// though the container's root was `/`.
0 commit comments