Protection from the dreaded "rm -fr /"

Tillman Hodgson tillman at seekingfire.com
Sat Oct 2 20:09:48 PDT 2004


On Sat, Oct 02, 2004 at 07:29:51PM -0600, M. Warner Losh wrote:
> In message: <20041002210554.GS35869 at seekingfire.com>
>             Tillman Hodgson <tillman at seekingfire.com> writes:
> : It'll never work, though, that's the thing. At some point it'll rm
> : something it itself needs and error out. There isn't a way to use `rm
> : -rf /` that /doesn't/ result in foot-shooting.
> 
> No.  You are wrong.  if you rm -rf in a chroot, then it won't result
> in foot shooting, necessarily, like it would outside a chroot.

If you're chrooted, where is the rm binary and associated libraries?
They're in the chroot, in a branch off hte virtual / tree root.

`rm -rf /`, even in chroot, won't delete everything that the command
looks like it will. At the very least the final unlink, that of /
itself, will likely result in undefined behaviour. Where do the dev's
go if there's no / to root them in? etc etc.

-T


-- 
"Waking a person unnecessarily should not be considered a capital crime.
 For a first offense, that is."
    -- Robert Heinlein


More information about the freebsd-hackers mailing list