[release/1.5] cherry-pick: windows: Use GetFinalPathNameByHandle for ResolveSymbolicLink#5454
Merged
AkihiroSuda merged 1 commit intocontainerd:masterfrom May 5, 2021
Merged
Conversation
This change splits the definition of pkg/cri/os.ResolveSymbolicLink by platform (windows/!windows), and switches to an alternate implementation for Windows. This aims to fix the issue described in containerd#5405. The previous implementation which just called filepath.EvalSymlinks has historically had issues on Windows. One of these issues we were able to fix in Go, but EvalSymlinks's behavior is not well specified on Windows, and there could easily be more issues in the future, so it seems prudent to move to a separate implementation for Windows. The new implementation uses the Windows GetFinalPathNameByHandle API, which takes a handle to an open file or directory and some flags, and returns the "real" name for the object. See comments in the code for details on the implementation. I have tested this change with a variety of mounts and everything seems to work as expected. Functions that make incorrect assumptions on what a Windows path can look like may have some trouble with the \\?\ path syntax. For instance EvalSymlinks fails when given a \\?\UNC\ path. For this reason, the resolvePath implementation modifies the returned path to translate to the more common form (\\?\UNC\server\share -> \\server\share). Signed-off-by: Kevin Parsons <kevpar@microsoft.com> (cherry picked from commit b0d3b35) Signed-off-by: Phil Estes <estesp@gmail.com>
Member
Author
|
//cc: @kevpar just FYI cherry-picked this into |
|
Build succeeded.
|
AkihiroSuda
approved these changes
May 5, 2021
This was referenced May 26, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #5411 for
release/1.5This change splits the definition of pkg/cri/os.ResolveSymbolicLink by
platform (windows/!windows), and switches to an alternate implementation
for Windows. This aims to fix the issue described in #5405.
The previous implementation which just called filepath.EvalSymlinks has
historically had issues on Windows. One of these issues we were able to
fix in Go, but EvalSymlinks's behavior is not well specified on
Windows, and there could easily be more issues in the future, so it
seems prudent to move to a separate implementation for Windows.
The new implementation uses the Windows GetFinalPathNameByHandle API,
which takes a handle to an open file or directory and some flags, and
returns the "real" name for the object. See comments in the code for
details on the implementation.
I have tested this change with a variety of mounts and everything seems
to work as expected. Functions that make incorrect assumptions on what a
Windows path can look like may have some trouble with the \?\ path
syntax. For instance EvalSymlinks fails when given a \?\UNC\ path. For
this reason, the resolvePath implementation modifies the returned path
to translate to the more common form (\?\UNC\server\share ->
\server\share).
Signed-off-by: Kevin Parsons kevpar@microsoft.com
(cherry picked from commit b0d3b35)
Signed-off-by: Phil Estes estesp@gmail.com