cp: don't chmod through the destination symlink#13443
Conversation
|
GNU testsuite comparison: |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Since dest_is_symlink is stale by this point anyway, just use if !dest.is_symlink() - that's what this line was before #6190, and it also fixes cp --remove-destination onto a symlink (we give 600, GNU gives 664). |
Drop the stale pre-copy dest_is_symlink from the guard and check dest.is_symlink() alone, as this line did before uutils#6190. Besides not chmodding through a freshly copied symlink, this also applies the mode when --remove-destination replaces a symlink with a regular file, matching GNU cp.
|
Done, switched the guard to a plain |
copy_file recreates a source symlink at the destination, but the following set_permissions used the stale pre-copy symlink check, so chmod followed the new link and changed its target's mode outside the copied tree; it now re-checks dest.is_symlink() before setting the mode, matching GNU cp. Fixes #12191.