Bug 31633

Summary: cp is unable to copy trees with non-empty read-only directories
Product: Base System Reporter: Stephen McKay <mckay>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Stephen McKay freebsd_committer freebsd_triage 2001-10-30 10:30:01 UTC
SUSV2 defines special handling of read-only directories.  cp should
first create them writable (S_IRWXU set), copy the contents, then fix
up permissions later.  Since rev 1.1, cp.c has attempted to do this,
but does this in the wrong order (create-writable, set-read-only,
copy-contents, oops).

Fix: 

Gnu cp handles this by keeping a list of directory permissions to fix
after all copying has been done.  Such a mechanism could also be used to
close other outstanding PRs on cp problems (like preserving directory
modify times).
How-To-Repeat: % mkdir a
% touch a/x
% chmod a-w a
% cp -R a b
cp: b/x: Permission denied
%
Comment 1 Stephen McKay freebsd_committer freebsd_triage 2001-12-15 14:22:33 UTC
State Changed
From-To: open->closed

Fixed in cp.c rev 1.28 and 1.24.2.4