-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
cp: fix -p to not preserve xattrs by default #9708
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
base: main
Are you sure you want to change the base?
cp: fix -p to not preserve xattrs by default #9708
Conversation
Fixes uutils#9704 The -p flag should only preserve mode, ownership, and timestamps, matching GNU cp behavior. Extended attributes require explicit --preserve=xattr or -a (archive mode). Changed Attributes::DEFAULT to set xattr preservation to No, preventing unintended security risks and filesystem compatibility issues. Adds regression test.
|
GNU testsuite comparison: |
CodSpeed Performance ReportMerging #9708 will not alter performanceComparing Summary
Footnotes
|
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
tests/by-util/test_cp.rs
Outdated
| ); | ||
|
|
||
| // mode, ownership, and timestamps should be preserved | ||
| #[cfg(not(any(target_os = "freebsd", target_os = "macos")))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are redundant because its at the top of the test already
tests/by-util/test_cp.rs
Outdated
| use std::process::Command; | ||
| use uutests::util::compare_xattrs; | ||
|
|
||
| let scene = TestScenario::new(util_name!()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the at_and_ucmd macro here?
|
I think the issue that was provided was an oversimplification and luckily the GNU test catches it. The issue #9704 is correct that cp -p shouldn't preserve general xattrs, the implementation in PR #9708 is too expansive - it also removes ACL preservation, which GNU cp -p does support. We need to make a fix with granular xattr handling that preserves ACLs but not other xattrs. |
|
Maybe combining your approach with changing of the preserve code to also add ACL xattrs? |
|
i will look into this today |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
implement granular xattr handling to preserve ACLs with -p but not general xattrs
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
| use std::{fmt, io}; | ||
| #[cfg(all(unix, not(target_os = "android")))] | ||
| use uucore::fsxattr::copy_xattrs; | ||
| use uucore::fsxattr::{copy_acl_xattrs, copy_xattrs}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clippy warning here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason this doesn't come up for me when I locally run it, should I be adding the openbsd flag here too, that we have on :1722?
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Fixes #9704
The -p flag should only preserve mode, ownership, and timestamps, matching GNU cp behavior. Extended attributes require explicit --preserve=xattr or -a (archive mode).
Changed Attributes::DEFAULT to set xattr preservation to No, preventing unintended security risks and filesystem compatibility issues.
Adds regression test.