cp: keep permissions - #14176
Conversation
|
GNU testsuite comparison: |
you probably regressed this test |
|
Handling for non-regular destinations was missing. |
Merging this PR will not alter performance
Comparing Footnotes
|
| #[test] | ||
| #[cfg(unix)] | ||
| fn test_cp_f_i_verbose_non_writeable_destination_y() { | ||
| use uucore::process::geteuid; |
There was a problem hiding this comment.
Please use rustix directly. We will remove it soon.
There was a problem hiding this comment.
Moved over to rustix.
test_cp_f_i_verbose_non_writeable_destination_y has been changed to check for root first, as a privileged process can write to a 000-mode file regardless.
Moved this testcase to rustix also.
delete_dest_if_needed_and_allowed in cp.rs decided whether "cp -f" needs to recreate an existing destination by checking fs::metadata(dest)?.permissions().readonly().
Its only a mode-bit check, and ignores that a privileged process (root) can write to a file regardless of its mode bits, so it always treated a chmod 000 destination as needs recreating.
Fixes #14175