That's indeed an odd cp
behavior I reproduced on the same Solaris release.
Not sure there is a patch for Solaris 10 but the issue is fixed in Solaris 11.1.
题
I've encountered an oddity when doing a copy in Solaris 10 update 10 (sparc, 147440-25).
Here is the setup (done as root):
# cd /tmp
# mkdir foo
# touch foo/thing1
# ln -s thing1 foo/thing2
# chown -hR joe:user foo
If you look at the directory and the link, everything is owned by the user "joe". Now comes the interesting part:
# cp -rpP foo bar
The options to cp here are to recurse, preserve permissions and ownership, and to act on links instead of following them. But when I do this, while the link is copied with the correct permissions, the directory itself, bar, is set to root:root. Is there some reason for this behavior?
It only acts this way if there is a link in the directory. If the directory contains only files all ownership is preserved (I assume because the -P never comes into play).
解决方案
That's indeed an odd cp
behavior I reproduced on the same Solaris release.
Not sure there is a patch for Solaris 10 but the issue is fixed in Solaris 11.1.