Protection from the dreaded "rm -fr /"

Chris Dillon cdillon at wolves.k12.mo.us
Tue Oct 5 08:37:08 PDT 2004


On Sat, 2 Oct 2004, Greg Black wrote:

> As for protecting against "rm -rf / foo" as a typo for "rm -rf 
> /foo", I don't mind if we offer protection against that; but I see 
> no reason at all to "protect" root from "rm -rf /".  It's fair to 
> say that somebody who types that means it, and it's fair to go as 
> far as we can in satisfying it.

I think you just nailed it on the head right here... if you say "rm 
-rf /" you probably mean it, but if you say "rm -rf / foo" you 
probably oopsed (pretty good bet, since rm / makes asking to rm foo 
redundant).  How about checking if there is more than one argument, 
and if one of those arguments is "/", fail.  If there is only one 
argument, even if it is "/", assume the user knows what he is doing 
and proceed normally.

-- 
  Chris Dillon - cdillon(at)wolves.k12.mo.us
  FreeBSD: The fastest, most open, and most stable OS on the planet
  - Available for IA32, IA64, AMD64, PC98, Alpha, and UltraSPARC architectures
  - PowerPC, ARM, MIPS, and S/390 under development
  - http://www.freebsd.org

Q: Because it reverses the logical flow of conversation.
A: Why is putting a reply at the top of the message frowned upon?



More information about the freebsd-hackers mailing list