Skip to content

Commit 884931b

Browse files
committed
Revert "volume: skip resolving symlinks without a prefix"
This reverts commit a507f90.
1 parent e4a7c38 commit 884931b

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

volume/volume.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99

1010
mounttypes "github.com/docker/docker/api/types/mount"
1111
"github.com/docker/docker/pkg/idtools"
12-
"github.com/docker/docker/pkg/stringid"
1312
"github.com/docker/docker/pkg/symlink"
13+
"github.com/docker/docker/pkg/stringid"
1414
"github.com/opencontainers/runc/libcontainer/label"
1515
"github.com/pkg/errors"
1616
)
@@ -126,16 +126,15 @@ type MountPoint struct {
126126
// Setup sets up a mount point by either mounting the volume if it is
127127
// configured, or creating the source directory if supplied.
128128
func (m *MountPoint) Setup(prefix, mountLabel string, rootUID, rootGID int) (path string, err error) {
129-
var sourcePath string
130-
if prefix == "" {
131-
sourcePath = m.Source
132-
} else {
133-
sourcePath, err = symlink.FollowSymlinkInScope(filepath.Join(prefix, m.Source), prefix)
134-
if err != nil {
135-
path = ""
136-
err = errors.Wrapf(err, "error evaluating symlink from mount source '%s'", m.Source)
137-
return
138-
}
129+
symlinkRoot := prefix
130+
if symlinkRoot == "" {
131+
symlinkRoot = "/"
132+
}
133+
sourcePath, err := symlink.FollowSymlinkInScope(filepath.Join(prefix, m.Source), symlinkRoot)
134+
if err != nil {
135+
path = ""
136+
err = errors.Wrapf(err, "error evaluating symlink from mount source '%s'", m.Source)
137+
return
139138
}
140139

141140
defer func() {

0 commit comments

Comments
 (0)