gabriel rosenkoetter on Thu, 6 Jun 2002 08:20:08 +0200 |
I let it slide at to(last?)night's meeting, but here's the number 1 reason you never want to use -R (there are others): -R will follow sym links, whereas you can always tell find(1) not to. Suppose you're moving a bunch of users from one system to another. uids conflict, so you'll have to chown and chgrp (if you think you don't need to chgrp, you must not have any users sharing files, or no conflict gids for those shared groups) all over /home (or equivalent; while I'm at it, if you're on Solaris and you think you can get away with chown and chgrp at all rather than setfacl, you'll lose). You do it with -R, and Joe "Local Root" Cracker has a sym link to /etc/shadow in his home directory. Whoops. Then you realize you missed the dot-files and do -R on .*. Yikes. Go find a tape backup (you've got one, of course?): you're hosed. Note that some ch{mod,grp,own}(1)s have a -P flag which says "never follow sym links". That's nice. It's probably even a Posix standard. I don't trust it. Sun's stuff, for instance, still lacks it in Solaris 8 (and Solaris 9, I think, though I don't have a copy around any more to check). No, you don't want to use GNU's utilities for this on Solaris (or FreeBSD, btw), as they'll mangle ACLs. In any case, the point is that recursion should scare you a lot in file systems. You should take the time to make sure it won't hurt anything. But that's time you could take just thinking of all the cases (there really aren't that many) and constructing a proper find | xargs command line. (On a related note, you *really* want to use GNU find(1)'s -print0 and their xargs(1) -0 flags. You want to use them badly enough to install them on Sun systems, which still lack these intensely useful features. Especially where Samba and users unaware of Unix naming conventions are involved. You may not need them every time, but the first time you needed them and didn't use them, you'll know that you really just want to use them all the time and not repeat the agony.) -- gabriel rosenkoetter gr@eclipsed.net Attachment:
pgpLpNt01Jtwg.pgp
|
|