Repository navigation
fix(sftp): folder upload skips a symlink back to an ancestor (#543) - #567
Merged
Merged
Conversation
LocalFs listings follow symlinks, so a link like `sub/up -> ..` made
`walk` copy the tree once per level until the kernel's 40-hop limit
stopped it with ELOOP.
`visit` now tracks the canonical path of each directory's ancestors
and leaves out a directory that resolves to one of them; `walk`
reports it on `sftp-skipped-{tid}`, as the tar path already does.
Symlinks to files and to unrelated directories are still followed.
Remote endpoints never follow links, so `real_dir` is None there and
nothing changes for them.
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.
Fixes #543.
LocalFs::listfollows symlinks, so a link back to an ancestor (sub/up -> ..) madewalkcopy the tree once per level. It stopped only when the kernel's 40-hop limit hit ELOOP, about 40 copies deep.Change
Endpoint::real_dir: a directory's canonical path.LocalFsreturnscanonicalize; remote endpoints returnNone, because their listings never follow links.visitcarries each directory's ancestor chain of canonical paths and leaves out a child directory that resolves to one of them. It returns those paths.walkreports them onsftp-skipped-{tid}, as the tar path already does (local_tar::Walkuses the same ancestor check).large_by_walkignores the returned list. A looped entry is no longer counted; before, its ELOOP made the tree count as large.Tests
a_link_back_to_an_ancestor_is_skipped_and_other_links_followed. Before the fix it failed withsub/up/sub/up/…dirs about 80 components deep. After: dirssub, sub/empty, sub/ext, a followed file link, and onlysub/upreported as skipped.cargo test --lib -- resume::passes: 66 passed, 1 ignored.cargo fmt --checkandcargo clippy --workspace --all-targets -D warningsare clean.