Skip to content

Relative symlinks don't work with --device argument#22272

Merged
vdemeester merged 1 commit intomoby:masterfrom
yongtang:22271-relative-symlinks
Apr 25, 2016
Merged

Relative symlinks don't work with --device argument#22272
vdemeester merged 1 commit intomoby:masterfrom
yongtang:22271-relative-symlinks

Conversation

@yongtang
Copy link
Copy Markdown
Member

- What I did

This fix tries to address the issue raised in #22271 where relative symlinks don't work with --device argument.

- How I did it

Previously, the symlinks in --device was implemneted (#20684) with os.Readlink() which does not resolve if the linked target is a relative path. In this fix, filepath.EvalSymlinks() has been used which will reolve correctly with relative paths.

- How to verify it

An additional test case has been added to the existing TestRunDeviceSymlink to cover changes in this fix.

- A picture of a cute animal (not mandatory but encouraged)

This fix is related to #13840 and #20684, #22271.
This fix fixes #22271.

Signed-off-by: Yong Tang [email protected]

@thaJeztah
Copy link
Copy Markdown
Member

@mlaventure we may want to consider including this in 1.11.1 (the follow symlinks is a new addition in 1.11.0)

@thaJeztah thaJeztah added this to the 1.11.1 milestone Apr 23, 2016
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does os.Symlink error out if /dev/symzero already exists? if so, i dont think we should error out, because it is not impossible that the defer won't run in some weird cases. We could just print the error though and move on.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tiborvass just updated the pull request. Let me know if there are any other issues.

@tiborvass
Copy link
Copy Markdown
Contributor

I'm not opposed to this PR, in fact I don't even see why we wouldn't follow absolute symlinks too.

@yongtang yongtang force-pushed the 22271-relative-symlinks branch 2 times, most recently from 7731ab5 to 0608629 Compare April 23, 2016 20:20
@vdemeester
Copy link
Copy Markdown
Member

Same thought as @tiborvass so LGTM 🐼

@coolljt0725
Copy link
Copy Markdown
Contributor

coolljt0725 commented Apr 25, 2016

one nit, otherwise LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should defer os.Remove("/dev/symzero") below the if err != nil check?

@yongtang yongtang force-pushed the 22271-relative-symlinks branch 2 times, most recently from 36c1c37 to a73e631 Compare April 25, 2016 14:18
This fix tries to address the issue raised in moby#22271 where
relative symlinks don't work with --device argument.

Previously, the symlinks in --device was implemneted (moby#20684)
with `os.Readlink()` which does not resolve if the linked
target is a relative path. In this fix, `filepath.EvalSymlinks()`
has been used which will reolve correctly with relative
paths.

An additional test case has been added to the existing
`TestRunDeviceSymlink` to cover changes in this fix.

This fix is related to moby#13840 and moby#20684, moby#22271.
This fix fixes moby#22271.

Signed-off-by: Yong Tang <[email protected]>
@yongtang yongtang force-pushed the 22271-relative-symlinks branch from a73e631 to 632b314 Compare April 25, 2016 14:23
@tiborvass
Copy link
Copy Markdown
Contributor

LGTM

@vdemeester vdemeester merged commit 88d1ae1 into moby:master Apr 25, 2016
@yongtang yongtang deleted the 22271-relative-symlinks branch April 25, 2016 16:16
@mlaventure mlaventure mentioned this pull request Apr 25, 2016
@mlaventure mlaventure removed this from the 1.11.1 milestone Apr 25, 2016
@thaJeztah thaJeztah added this to the 1.12.0 milestone Jul 11, 2016
liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017
This fix tries to address the issue raised in moby#22271 where
relative symlinks don't work with --device argument.

Previously, the symlinks in --device was implemneted (moby#20684)
with `os.Readlink()` which does not resolve if the linked
target is a relative path. In this fix, `filepath.EvalSymlinks()`
has been used which will reolve correctly with relative
paths.

An additional test case has been added to the existing
`TestRunDeviceSymlink` to cover changes in this fix.

backport from: moby#22272

Signed-off-by: Yong Tang <[email protected]>
Signed-off-by: Yuanhong Peng <[email protected]>
liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017
Relative symlinks don't work with --device argument

This fix tries to address the issue raised in moby#22271 where
relative symlinks don't work with --device argument.

Previously, the symlinks in --device was implemneted (moby#20684)
with `os.Readlink()` which does not resolve if the linked
target is a relative path. In this fix, `filepath.EvalSymlinks()`
has been used which will reolve correctly with relative
paths.

An additional test case has been added to the existing
`TestRunDeviceSymlink` to cover changes in this fix.

backport from: moby#22272

Signed-off-by: Yong Tang <[email protected]>
Signed-off-by: Yuanhong Peng <[email protected]>


See merge request docker/docker!348
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relative symlinks don't work with --device argument

7 participants