FreeBSD 5.4: 'cp -p' does not behave as documented

David King dking at ketralnis.com
Mon Aug 28 21:33:06 UTC 2006


>> According to the cp man page:
>> -p  Cause cp to preserve the following attributes of each source file
>>    in the copy: modification time, access time, file flags, file  
>> mode,
>>    user ID, and group ID, as allowed by permissions.
>>
>>    If the user ID and group ID cannot be preserved, no error message
>>    is displayed and the exit value is not altered.
>> However, when I run this script or when I do a cp -p manually I am  
>> seeing:
>> 	cp: chown: /stats/maillogs/maillog-copy-test.bz2: Permission denied
> You need to run this as root so the permissions and ownership all  
> can be set.
> -Derek

I think you misunderstand the poster's complaint. It's not that the  
permissions aren't being set, it's that the documentation is  
incorrect. This part:
	If the user ID and group ID cannot be preserved, no error message
	is displayed and the exit value is not altered.
is not in accordance to the behaviour that they are seeing. The owner  
and/or group could not be set, but cp(1) fails, and displays a  
message, but the documentation says that it should not display an  
error message or fail. 


More information about the freebsd-questions mailing list