cp: Properly preserves fifos and symlink attributes#8416
Merged
RenjiSann merged 3 commits intouutils:mainfrom Jul 31, 2025
Merged
cp: Properly preserves fifos and symlink attributes#8416RenjiSann merged 3 commits intouutils:mainfrom
cp: Properly preserves fifos and symlink attributes#8416RenjiSann merged 3 commits intouutils:mainfrom
Conversation
There was a mismatch between the test, the comment, and the code. The intention was to _preserve_ attributes if the source of a fifo/pipe still exists. Perhaps the clearest way is to modify the test (as that avoids code duplication). Also add a basic test for that, if permissions are preserved, the rest should also be preserved correctly. Fixes the first part of uutils#8402.
Most attributes can actually be applied to symlinks (mode and xattr are exceptions), so try to copy them, if possible. Fort those 2 exceptions, we don't need any special handling as: - Mode errors would be ignored anyway. - The source symlink cannot have any xattr anyway, so no attribute is attempted to be set on the destination.
|
GNU testsuite comparison: |
RenjiSann
reviewed
Jul 30, 2025
Co-authored-by: Dorian Péron <72708393+RenjiSann@users.noreply.github.com>
|
GNU testsuite comparison: |
Contributor
sweet! |
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 #8402,
misc/selinuxwill pass with this -- I just added test for 2 non-SELinux set of attributes in fifo and symlinks, it's really verbose to test everything.cp: Also copy attributes in copy_symlink
Most attributes can actually be applied to symlinks (mode and
xattr are exceptions), so try to copy them, if possible.
Fort those 2 exceptions, we don't need any special handling as:
attribute is attempted to be set on the destination.
cp: File logic error when preserving attributes for fifos
There was a mismatch between the test, the comment, and the code.
The intention was to preserve attributes if the source of a
fifo/pipe still exists. Perhaps the clearest way is to modify
the test (as that avoids code duplication).
Also add a basic test for that, if permissions are preserved, the
rest should also be preserved correctly.
Fixes the first part of #8402.