On Oct 24, 2012, at 11:30 AM, Jan Schaumann <[email protected]> wrote: >> A new user I knew was trying to clean out some old accounts on a system >> he was given. As root, he changed directories to one of the old user >> directories, and then did 'rm -r *' but noticed it left a directory >> called .X11 behind. To get rid of it, and to be sure it wouldn't fail, >> he did 'rm -rf .*'. Sad to say he didn't realize that '.*' could and >> would expand into '..', and it would continue to do so recursively. > > Did early versions of (any) Unix really behave this way? I don't see > how: > > '.*' is expanded by the shell at command invocation time. That does in > fact get expanded to include '.' and '..', but it does not recursively > expand to '../.' and '../..' etc.
"-r" ... so it recursively runs the command against anything marked as a directory,... which ".." satisfies. So it would recursively go "into" the .. directory tree, and then delete whatever files/directories were in that directory. Lather, rinse, repeat. Trust me when I tell you that I've done this myself, firsthand, (ca. 1997) on a Linux host, and it worked just "fine" (for ugly ugly values of "fine"). > Today's unix versions tend to agree that a user cannot remove '.' and > '..', and NetBSD's earliest import from March 1993 also includes this > explicit check > (http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/rm/rm.c?rev=1.1). It seems though (when I went to go try this on a test-host) that the rm in Linux has been "fixed" to explicitly prevent it. D _______________________________________________ Discuss mailing list [email protected] https://lists.lopsa.org/cgi-bin/mailman/listinfo/discuss This list provided by the League of Professional System Administrators http://lopsa.org/
