-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Inconsistent behaviour of skip_current_dir
when combined with same_file_system (false)
and symlinks to other file-systems
#166
Comments
I unfortunately can't make sense of your first paragraph. You mention the symlink is not recursed into, but also talk about skip_current_dir... So I'm not sure what you mean. I think examples will help, or else I'll have to repro it when I get time. (Which might be a while.) |
To be clear, I'm unsure what you're actually calling inconsistent. |
I'll try to summarize the issue:
When iterating, However, if one tries to asses both
The problem is that (For example I had tool that uses My proposal was to fix this corner-case by either making To summarize: when it comes to symlinks, For example in https://github.com/BurntSushi/walkdir/blob/master/src/lib.rs#L821-L823 |
Thank you for that thorough explanation! That makes things much clearer.
So I do like this answer, but I also worry that it might be problematic to represent a non-broken symlink as if it were a broken symlink. It's difficult to come up with concrete problems here, but I am worried. On the other hand, if one thinks of "same file system" as a conceptual model where anything outside the file system the root directory is on is considered to basically not exist, then I think it does make sense... Otherwise, I think it seems like the least worst option. I'd prefer not to add any new public APIs to fix this for example, because it's not reasonable to expect folks to deeply reason about this and correctly use some new API to work around it. The other option, making PRs for this are welcome, as I'm not sure when I'll have time to get around to this myself. |
So, you would accept a PR which implements the "broken symlink" workaround as described above? (I'm not promissing much, but if I get some time I'll try to implement it. At the moment I've made a workaround in my code that doesn't rely on |
I'm not 100% certain I would take it, but I'm pretty sure. I can't really
think of a better path here.
…On Sat, Aug 20, 2022, 13:52 Ciprian Dorin Craciun ***@***.***> wrote:
PRs for this are welcome, as I'm not sure when I'll have time to get
around to this myself.
So, you would accept a PR which implements the "broken symlink" workaround
as described above?
(I'm not promissing much, but if I get some time I'll try to implement it.
At the moment I've made a workaround in my code that doesn't rely on
.skip_current_dir().)
—
Reply to this email directly, view it on GitHub
<#166 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADPPYSMHXWPXFYZTUUO6XDV2ELMTANCNFSM57C7Y4WA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
When one uses
follow_links (true)
but alsosame_file_system (true)
, andwalkdir
encounters a symlink to a folder on a different file-system (which will thus not be recursed-into), it will report it as a file or folder (assuming the pointed-to exists), and thus callingskip_current_dir
will in fact skip iterating the parent folder of that symlink.I don't know if this is actually an issue within
walkdir
itself, or the code that useswalkdir
in such a manner.Perhaps the best solution is to add a new method
DirEntry::is_recursed
that states if the current entry is or not actually the subject of recursion, and thus if callingskip_current_dir
will affect this entry and not its parent.Another solution, perhaps best if viewed from a security point-of-view, is to treat symlinks to entities outside the current file-system as broken links, thus the
DirEntry::file_type
andDirEntry::metadata
would actually belong to the symlink and not to the pointed-to file or folder.The text was updated successfully, but these errors were encountered: