Bug #3619

cp -p clobbers permissions/ownership following symbolic links

Added by Alexander Eremin over 4 years ago. Updated over 4 years ago.

Status:ResolvedStart date:2013-03-11
Priority:NormalDue date:
Assignee:Alexander Eremin% Done:

20%

Category:cmd - userland programs
Target version:-
Difficulty:Medium Tags:

Description

When using cp(1) with preserve option recursively, it calls chmod/chown also for symlinks, which affects on symlinks sources:

root@indy:/tmp/testcp# ls -l .
total 12
-rw-r--r-- 1 alex staff   0 Mar 11 16:49 a
lrwxrwxrwx 1 alex staff   1 Mar 11 16:49 b -> a
lrwxrwxrwx 1 root root    1 Mar 11 16:49 x -> a
drwxr-xr-x 2 alex staff 291 Mar 11 16:51 z
root@indy:/tmp/testcp# ls -l z
total 8
lrwxrwxrwx 1 root root  4 Mar 11 16:49 f -> ../a
-rw-r--r-- 1 alex staff 0 Mar 11 16:49 v
lrwxrwxrwx 1 root root  1 Mar 11 16:51 w -> v
root@indy:/tmp/testcp# rm -rf c; mkdir c
root@indy:/tmp/testcp# /usr/bin/cp -pPR a b x z c
root@indy:/tmp/testcp# ls -l c
total 12
-rwxrwxrwx 1 root root    0 Mar 11 16:49 a
lrwxrwxrwx 1 alex staff   1 Mar 11 16:53 b -> a
lrwxrwxrwx 1 root root    1 Mar 11 16:53 x -> a
drwxr-xr-x 2 alex staff 291 Mar 11 16:51 z
root@indy:/tmp/testcp# ls -l c/z
total 8
lrwxrwxrwx 1 root root 4 Mar 11 16:53 f -> ../a
-rwxrwxrwx 1 root root 0 Mar 11 16:51 v
lrwxrwxrwx 1 root root 1 Mar 11 16:53 w -> v

History

#1 Updated by Rich Lowe over 4 years ago

  • Tags deleted (needs-triage)
  • Subject changed from Wrong symlinks preserve mode for cp -pPR to cp -p clobbers permissions/ownership following symbolic links

#2 Updated by Gordon Ross over 4 years ago

commit 6cdb72227544a5f07e7428e591c2ed84825f4d1f
Author: Alexander Eremin <a.eremin@nexenta.com>
Date:   Thu Mar 28 00:04:59 2013 +0400

    3619 cp -p clobbers permissions/ownership following symbolic links
    Reviewed by: Garrett D'Amore <garrett@damore.org>
    Reviewed by: Richard Lowe <richlowe@richlowe.net>
    Approved by: Gordon Ross <gwr@nexenta.com>

#3 Updated by Gordon Ross over 4 years ago

  • Status changed from New to Resolved

Also available in: Atom