safe traversal: adjust chmod & chgrp to use it #8632
Conversation
|
based on this PR: #8626 |
|
GNU testsuite comparison: |
2bcba37 to
21b334e
Compare
|
GNU testsuite comparison: |
src/uu/chmod/src/chmod.rs
Outdated
| let entry_path = dir_path.join(&entry_name); | ||
|
|
||
| // Get metadata for the entry | ||
| let follow = self.traverse_symlinks == TraverseSymlinks::All; |
There was a problem hiding this comment.
Is this correct? What about TraverseSymlinks::First?
There was a problem hiding this comment.
why do you think otherwise ? :)
There was a problem hiding this comment.
Because in walk_dir_with_context you use the following approach to determine whether to follow symlinks:
let should_follow_symlink = match self.traverse_symlinks {
TraverseSymlinks::All => true,
TraverseSymlinks::First => is_command_line_arg, // Only follow symlinks that are command line args
TraverseSymlinks::None => false,
};|
GNU testsuite comparison: |
a291ff0 to
b02315a
Compare
|
GNU testsuite comparison: |
b02315a to
8252cb1
Compare
CodSpeed Performance ReportMerging #8632 will create unknown performance changesComparing Summary
|
|
GNU testsuite comparison: |
src/uu/chmod/src/chmod.rs
Outdated
| let should_follow_symlink = match self.traverse_symlinks { | ||
| TraverseSymlinks::All => true, | ||
| TraverseSymlinks::First => false, // Only follow symlinks that are command line args | ||
| TraverseSymlinks::None => false, | ||
| }; |
There was a problem hiding this comment.
Hm, I'm still struggling with this snippet. If line 502 is correct, then your previous approach with if is cleaner. Anyway, in both cases you can define should_follow_symlink outside of the for loop as its value doesn't depend on entry_name.
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
8252cb1 to
a00d7d7
Compare
|
GNU testsuite comparison: |
No description provided.