Sorry, buried in $DAYJOB stuff again for a bit. Where was I? > Rob Landley <r...@landley.net> hat geschrieben: > Right, lemme take a stab at doing this right. -D should act like -r in > terms of "what we're copying" (the blog entry I linked to above gave me > the impression it already _was_ just from what uses they considered > obvious). If we're mkdir-ing the destination then we should do so for > the top level one too just for conceptual consistency. Another fun corner case, related to the rm -f chmod thing, does this mkdir -p copy the permissions and ownership of the parent directories it creates? (In which case I can't just use the lib function but have to recurse...)
$ mkdir -p sub/two $ chmod 700 sub/two $ touch sub/two/three $ mkdir banana $ cp --parents sub/two/three banana $ ls -l banana/sub total 4 drwx------ 2 landley landley 4096 Jul 28 01:42 two So yeah, that. The cp plumbing itself isn't set up to do this (we don't recurse down through starting directories in our source arguments) so I need to mkdir -p permissions 700 so there's no exploitable race exposing stuff to other users with wrong permissions, then have a loop that will stat() each directory element so we can apply permissions (and chown if we're root) And then there's the fun that is --preserve, now with xattrs. I... need to factor out the "copy credentials from here to here" logic into a function, don't I? And what do I do if the directory gets deleted mid-traversal? (Somebody can rm -rf while I cp.) If the path already exists with different credential do I chmod it? $ chmod 700 banana/sub $ cp --parents sub/two/three banana $ ls -l banana total 4 drwx------ 3 landley landley 4096 Jul 28 01:42 sub $ ls -ld sub drwxrwxr-x 3 landley landley 4096 Jul 28 01:41 sub Answer: nope. Leave it alone unless you're creating it. (I ran the cp again with --preserve=all just to be sure, and the result was the same.) Grrr. This is fiddly and unpleasant to implement and it would be SO nice if there was a spec. Are we _creating_ parent directories, or are we _copying_ parent directories? The man page says: --parents use full source file name under DIRECTORY I.E. it doesn't say! Alexandar: as the guy who asked for this feature, do you care if I do the simple thing or the "copy corner cases of implementation the man page doesn't document" thing? Rob _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net