uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.8k stars 1.28k forks source link

cp -a does not copy attributes (owner, rights) of directories #6875

Open vadimcojuhar opened 4 days ago

vadimcojuhar commented 4 days ago

When copying directories from one to another with the -a option, only file attributes are copied, attributes of subdirectories are ignored.

Tested in Alpine Linux 3.20 with uutils 0.0.28.

Below is an example:

/ # ls -l /bin/cp 
lrwxrwxrwx 1 root root 17 Nov 19 10:17 /bin/cp -> ../usr/bin/uutils
/ # cp --version
cp 0.0.28
/ # mkdir -p /app/folder1
/ # echo test > /app/file1
/ # echo test > /app/folder1/file1
/ # chown -R nobody:nobody /app
/ # ls -l /app/
total 4
-rw-r--r-- 1 nobody nobody  5 Nov 19 10:20 file1
drwxr-xr-x 2 nobody nobody 19 Nov 19 10:20 folder1
/ # ls -l /app/file1 
-rw-r--r-- 1 nobody nobody 5 Nov 19 10:20 /app/file1
/ # mkdir /app-copy
/ # cp -a /app/. /app-copy
/ # ls -l /app-copy/
total 4
-rw-r--r-- 1 nobody nobody  5 Nov 19 10:20 file1
drwx------ 2 root   root   19 Nov 19 10:22 folder1
/ # ls -l /app-copy/folder1/
total 4
-rw-r--r-- 1 nobody nobody 5 Nov 19 10:20 file1