Fix resolving chained symlinks with the WinFSP VFS#213
Fix resolving chained symlinks with the WinFSP VFS#213tomgr wants to merge 1 commit intobuildbarn:mainfrom
Conversation
|
c953f2d to
3bd8efc
Compare
|
Just converting to draft whilst I do a bit more testing. |
There was a problem hiding this comment.
If we change this:
if err := path.Resolve(path.LocalFormat.NewParser(string(target)), &w); err != nil {to:
targetParser := path.LocalFormat.NewParser(string(target))
if err := path.Resolve(targetParser, &w); err != nil {Then we can also the path library to do the sanitization:
cleanPathBuilder, scopeWalker := path.EmptyPath.Join(path.VoidScopeWalker)
if err := path.Resolve(targetParser, scopeWalker); err != nil {
return 0, err
}
cleanPath, err := cleanPathBuilder.GetWindowsString()
return 0, err
}I know it's more code, but at the same time it's a bit more future proof. At some point we may consider changing VirtualSymlink() and VirtualReadlink() to accept/return a path.Parser. That way the VFS API is completely oblivious of path separators. If/when that happens, this code will continue to work as expected.
There was a problem hiding this comment.
I've done this but it required some work on the path library to make it correctly handle more exotic windows paths: see buildbarn/bb-storage#329.
Once that's merged I'll update this PR with a reference to the appropriate commit.
3bd8efc to
077e871
Compare
077e871 to
2b574c1
Compare
It turns out that WinFSP's FspFileSystemFindReparsePoint only splits on backslashes when calculating reparse depth. Forward slashes in symlink targets (e.g. from VirtualSymlink) caused chained symlinks to fail. We now convert forward slashes to back slashes when returning the reparse point.
2b574c1 to
93aca6b
Compare

It turns out that WinFSP's FspFileSystemFindReparsePoint only splits on backslashes when calculating reparse depth. Forward slashes in symlink targets (e.g. from VirtualSymlink) caused chained symlinks to fail. We now convert forward slashes to back slashes when returning the reparse point.