cp: fix --preserve=ownership permissions bug
commit5012223d78b8dc40159c30b391e2ce257f465bcd
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 20 Nov 2021 21:48:40 +0000 (20 13:48 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 20 Nov 2021 21:50:35 +0000 (20 13:50 -0800)
treea2ae8846ea71c53d4dcd2e37debb167d49ac0559
parent3e2d64448300ea91be258af5b64ed3b97b865bd6
cp: fix --preserve=ownership permissions bug

This fixes a bug that I introduced in
2006-12-06T19:44:08Z!eggert@cs.ucla.edu.
* src/copy.c (USE_XATTR): New macro.
(copy_reg): Use it to help the compiler.  Prefer open u+w to a
later chmod u=rw; u+r isn’t needed for xattr.  For the later u-r,
do only one (or zero) chmod calls instead of two (or one).
In the last chmod, respect the umask instead of ignoring it.
* tests/cp/preserve-mode.sh: Test for the bug.
NEWS
src/copy.c
tests/cp/preserve-mode.sh