coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

cp: Do not canonicalize paths, just dereference as needed

Open drinkcat opened this issue 3 months ago • 2 comments

Fixes #8452.

Writing a test for this is... tricky, and racy, ended up importing the serial_test crate... I wonder (I'm sure) we can do better... But, I also wonder if this could help with our CI flakes.

--

test_cp: Run all tests in parallel

Except test_cp_preserve_unreadable_parent, that needs to change the current directory.

Cargo.toml: Add serial_test crate

test_cp: test attribute restoration when a parent directory is not accessible

tests/cp/preserve-gid indirectly/accidentally also tests for that, as it uses chroot with a different user.

Note that this test cannot run in parallel with others in the suite, as changing current directory has side effects.

cp: copy_attributes: Add parameter to tell if source should be dereferenced

We should not canonicalize pathnames unless absolutely necessary. Here, we are just interested in dereferencing symlinks, sometimes.

This used to break attribute restoration when a user doesn't have read access to one of the parent directories of the current path.

drinkcat avatar Aug 12 '25 06:08 drinkcat

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cp/preserve-gid is no longer failing!

github-actions[bot] avatar Aug 12 '25 07:08 github-actions[bot]

GNU testsuite comparison:

Congrats! The gnu test tests/cp/preserve-gid is no longer failing!

This, the good news.

The bad news is that so many tests are failing with... strange errors. I guess serial_test has... interesting side effects.

drinkcat avatar Aug 12 '25 09:08 drinkcat

it has been draft for a long time, please reopen when ready

sylvestre avatar Oct 06 '25 20:10 sylvestre