Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolver.ResolveLocal: fully dereference basedir before walking #883

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

drafnel
Copy link

@drafnel drafnel commented Jul 24, 2017

Commit 52f7192 taught NewResolver to detect when the basedir argument is
a symlink and to extract the target of the symlink and use it in place
of the original basedir. This works correctly and allows ResolveLocal
to walk the directory tree when the symlink target is a fully qualified
path to a directory. But, if the symlink points to another symlink, or
if it provides a relative path, then the traversal by filepath.Walk()
will fail as before.

The path/filepath package already provides a function to fully evaluate
a path and dereference any symbolic links: filepath.EvalSymlinks().

So instead of using checkForBasedirSymlink() to perform a single
dereference of basedir and storing that into the Resolver object, let's
just record the original path into the Resolver object and then call
filepath.EvalSymlinks() to fully resolve the path in ResolveLocal before
walking the tree with filepath.Walk().

Commit 52f7192 taught NewResolver to detect when the basedir argument is
a symlink and to extract the target of the symlink and use it in place
of the original basedir.  This works correctly and allows ResolveLocal
to walk the directory tree when the symlink target is a fully qualified
path to a directory.  But, if the symlink points to another symlink, or
if it provides a relative path, then the traversal by filepath.Walk()
will fail as before.

The path/filepath package already provides a function to fully evaluate
a path and dereference any symbolic links: filepath.EvalSymlinks().

So instead of using checkForBasedirSymlink() to perform a single
dereference of basedir and storing that into the Resolver object, let's
just record the original path into the Resolver object and then call
filepath.EvalSymlinks() to fully resolve the path in ResolveLocal before
walking the tree with filepath.Walk().
@drafnel
Copy link
Author

drafnel commented Aug 4, 2017

Ping. Hi @mattfarina can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant