fix: do not double-prefix symlink paths that already contain volume names (#2051)

Signed-off-by: Joseph Palermo <jpalermo@vmware.com>
Signed-off-by: Chris Selzo <cselzo@vmware.com>
Co-authored-by: Joseph Palermo <jpalermo@vmware.com>
This commit is contained in:
Chris Selzo 2023-08-24 07:45:22 -07:00 committed by GitHub
parent 1848aa22cf
commit 5ceef48949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -349,9 +349,13 @@ func (r directoryIndexer) addSymlinkToIndex(p string, info os.FileInfo) (string,
} }
if filepath.IsAbs(linkTarget) { if filepath.IsAbs(linkTarget) {
linkTarget = filepath.Clean(linkTarget)
// if the link is absolute (e.g, /bin/ls -> /bin/busybox) we need to // if the link is absolute (e.g, /bin/ls -> /bin/busybox) we need to
// resolve relative to the root of the base directory // resolve relative to the root of the base directory, if it is not already
linkTarget = filepath.Join(r.base, filepath.Clean(linkTarget)) // prefixed with a volume name
if filepath.VolumeName(linkTarget) == "" {
linkTarget = filepath.Join(r.base, filepath.Clean(linkTarget))
}
} else { } else {
// if the link is not absolute (e.g, /dev/stderr -> fd/2 ) we need to // if the link is not absolute (e.g, /dev/stderr -> fd/2 ) we need to
// resolve it relative to the directory in question (e.g. resolve to // resolve it relative to the directory in question (e.g. resolve to