From nobody  Thu Feb 12 18:50:34 1998
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id SAA03187;
          Thu, 12 Feb 1998 18:50:34 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199802130250.SAA03187@hub.freebsd.org>
Date: Thu, 12 Feb 1998 18:50:34 -0800 (PST)
From: rantapaa@uswest.net
To: freebsd-gnats-submit@freebsd.org
Subject: cp -r cannot copy un-writable directories
X-Send-Pr-Version: www-1.0

>Number:         5733
>Category:       bin
>Synopsis:       cp -r cannot copy un-writable directories
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 12 19:00:03 PST 1998
>Closed-Date:    Thu Jun 24 12:39:02 PDT 1999
>Last-Modified:  Thu Jun 24 12:40:15 PDT 1999
>Originator:     Erik Rantapaa
>Release:        2.2.5
>Organization:
USWest Interact
>Environment:
FreeBSD source1.oss.uswest.net 2.2.5-STABLE FreeBSD 2.2.5-STABLE #0: Mon Dec  8 12:54:06 CST 1997     root@amanda1.oss.uswest.net:/usr/src/sys/compile/SOURCE  i386

>Description:
 mkdir /tmp/foo
 touch /tmp/foo/bar
 chmod a-w /tmp/foo
 cp -r /tmp/foo .

cp: ./foo/bar: Permission denied
>How-To-Repeat:
see above

>Fix:
change the cp code to set the directory permissions after
it's done recursing through the directory.
>Release-Note:
>Audit-Trail:

From: Nick Hibma <nick.hibma@jrc.it>
To: freebsd-gnats-submit@freebsd.org, rantapaa@uswest.net
Cc:  
Subject: Re: bin/5733: cp -r cannot copy un-writable directories
Date: Thu, 24 Jun 1999 21:24:16 +0200

 cp does not recurse itself. It uses fts_read for that. This
 makes a solution very difficult. The only solution would be to remember
 the mode of every file being copied like tar does.
 
 Use tar for this and you should be allright:
 
 mkdir /tmp/foo
 touch /tmp/foo/bar
 chmod a-w /tmp/foo
 mkdir /tmp/hello
 tar -C /tmp -cf - foo | tar -C /tmp/hello -xf -
 ls -ld /tmp/hello/foo/
 
 Shows
 
 tar: Added write and execute permission to directory foo
 drwxr-xr-x  2 n_hibma  wheel  512 Jun 24 21:22 /tmp/hello/foo/
 
State-Changed-From-To: open->closed 
State-Changed-By: n_hibma 
State-Changed-When: Thu Jun 24 12:39:02 PDT 1999 
State-Changed-Why:  
Possible solution is very difficult. Other possible way of 
achieving same goal offered. 
>Unformatted:
