Skip to content

Commit 6e3bb8e

Browse files
authored
Merge pull request #317 from giuseppe/dont-resolve-symlinks-without-prefix-1.13.1-rhel
volume: skip resolving symlinks without a prefix
2 parents 6f36bd4 + a507f90 commit 6e3bb8e

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

volume/volume.go

Lines changed: 11 additions & 10 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/symlink"
1312
"github.com/docker/docker/pkg/stringid"
13+
"github.com/docker/docker/pkg/symlink"
1414
"github.com/opencontainers/runc/libcontainer/label"
1515
"github.com/pkg/errors"
1616
)
@@ -126,15 +126,16 @@ 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-
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
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+
}
138139
}
139140

140141
defer func() {

0 commit comments

Comments
 (0)