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

walkdir: avoid symlink loops when follow_symlinks == false #35006

Merged
merged 2 commits into from
Mar 6, 2020

Conversation

staticfloat
Copy link
Member

Without this change, walkdir() errors out while trying to determine if a symlink is a directory or not. When follow_symlinks is false, we should never attempt to dereference a symlink.

This has a slight behavioral change in that valid symlinks to directories are now returned in files instead of dirs when follow_symlinks is set to false, which seems like the more correct behavior here.

@staticfloat staticfloat added filesystem Underlying file system and functions that use it backport 1.3 labels Mar 4, 2020
staticfloat added a commit to JuliaPackaging/BinaryBuilder.jl that referenced this pull request Mar 5, 2020
Julia has a bug with `walkdir()` and symlink loops:
JuliaLang/julia#35006
staticfloat added a commit to JuliaPackaging/BinaryBuilder.jl that referenced this pull request Mar 5, 2020
Julia has a bug with `walkdir()` and symlink loops:
JuliaLang/julia#35006
Because `isdir()` attempts to dereference symlinks, attempting to
`walkdir()` trees that contain symlink loops errors out. This change
modifies `walkdir()` to treat all symlinks as files when
`follow_symlinks == false`.
@staticfloat
Copy link
Member Author

Fantastic, it's working. I'm rebase-squashing down to two commits, then we're good to merge.

@staticfloat staticfloat force-pushed the sf/walkdir_symlink_loops branch from b46ec9d to 6e2177e Compare March 5, 2020 20:02
@staticfloat staticfloat merged commit 178ac97 into master Mar 6, 2020
@staticfloat staticfloat deleted the sf/walkdir_symlink_loops branch March 6, 2020 21:33
staticfloat added a commit to JuliaLang/Pkg.jl that referenced this pull request Mar 14, 2020
When doing Artifact tests, we need to be resilient to strange umasks
that we have inherited from our environment, screwing up git tree hash
calculations.  To do this, we have a `walkdir()` -> `chmod()` wrapper
function that started setting permissions on what it thought were files
(due to the fixed `follow_symlink == false` behavior in
JuliaLang/julia#35006) but were actually
directories.  This caused `chmod()` to apply `0o664` permissions to
directories, which were then inaccessible to `rm()` as it tried to
delete them.

This fixes #1716
staticfloat added a commit to JuliaLang/Pkg.jl that referenced this pull request Mar 14, 2020
When doing Artifact tests, we need to be resilient to strange umasks
that we have inherited from our environment, screwing up git tree hash
calculations.  To do this, we have a `walkdir()` -> `chmod()` wrapper
function that started setting permissions on what it thought were files
(due to the fixed `follow_symlink == false` behavior in
JuliaLang/julia#35006) but were actually
directories.  This caused `chmod()` to apply `0o664` permissions to
directories, which were then inaccessible to `rm()` as it tried to
delete them.

This fixes #1716
KristofferC pushed a commit that referenced this pull request Mar 23, 2020
* walkdir: avoid symlink loops when `follow_symlinks == false`

Because `isdir()` attempts to dereference symlinks, attempting to
`walkdir()` trees that contain symlink loops errors out. This change
modifies `walkdir()` to treat all symlinks as files when
`follow_symlinks == false`.

* rm: When checking `filemode()`, use `lstat()` to avoid following symlinks

(cherry picked from commit 178ac97)
@KristofferC KristofferC mentioned this pull request Mar 23, 2020
27 tasks
ravibitsgoa pushed a commit to ravibitsgoa/julia that referenced this pull request Apr 9, 2020
…ng#35006)

* walkdir: avoid symlink loops when `follow_symlinks == false`

Because `isdir()` attempts to dereference symlinks, attempting to
`walkdir()` trees that contain symlink loops errors out. This change
modifies `walkdir()` to treat all symlinks as files when
`follow_symlinks == false`.

* rm: When checking `filemode()`, use `lstat()` to avoid following symlinks
KristofferC pushed a commit that referenced this pull request Apr 11, 2020
* walkdir: avoid symlink loops when `follow_symlinks == false`

Because `isdir()` attempts to dereference symlinks, attempting to
`walkdir()` trees that contain symlink loops errors out. This change
modifies `walkdir()` to treat all symlinks as files when
`follow_symlinks == false`.

* rm: When checking `filemode()`, use `lstat()` to avoid following symlinks
fredrikekre pushed a commit to JuliaLang/Pkg.jl that referenced this pull request Apr 17, 2020
When doing Artifact tests, we need to be resilient to strange umasks
that we have inherited from our environment, screwing up git tree hash
calculations.  To do this, we have a `walkdir()` -> `chmod()` wrapper
function that started setting permissions on what it thought were files
(due to the fixed `follow_symlink == false` behavior in
JuliaLang/julia#35006) but were actually
directories.  This caused `chmod()` to apply `0o664` permissions to
directories, which were then inaccessible to `rm()` as it tried to
delete them.

This fixes #1716

(cherry picked from commit 7366c8c, PR #1721)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filesystem Underlying file system and functions that use it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants