Date: Sun, 03 Oct 2004 11:37:39 -0600 (MDT) From: "M. Warner Losh" <imp@bsdimp.com> To: tillman@seekingfire.com Cc: freebsd-hackers@freebsd.org Subject: Re: Protection from the dreaded "rm -fr /" Message-ID: <20041003.113739.95785967.imp@bsdimp.com> In-Reply-To: <20041003030946.GV35869@seekingfire.com> References: <20041002210554.GS35869@seekingfire.com> <20041002.192951.35870461.imp@bsdimp.com> <20041003030946.GV35869@seekingfire.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20041003030946.GV35869@seekingfire.com> Tillman Hodgson <tillman@seekingfire.com> writes: : On Sat, Oct 02, 2004 at 07:29:51PM -0600, M. Warner Losh wrote: : > In message: <20041002210554.GS35869@seekingfire.com> : > Tillman Hodgson <tillman@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 doesn't have to live in the chroot. Consider chroot /some/path/to/a/chroot rm -rf / in this case, everything under the /some/path/to/a/chroot would be removed. However, the rm that's running is outside of the chroot. This is typically how chroot commands are run, often from shell scripts. : `rm -rf /`, even in chroot, won't delete everything that the command : looks like it will. It can delete just about everything, see above. : At the very least the final unlink, that of / : itself, will likely result in undefined behaviour. Purhaps, but that's not rm's job: to protect you from something that might be undefined. unlink(2) is undefined for remote file systems as well. Maybe it will work, maybe it won't. : Where do the dev's : go if there's no / to root them in? etc etc. Doesn't matter. Irrelevant. The chroot might not have a devfs mounted in it, or any dev nodes at all. /dev isn't required for most operations. Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041003.113739.95785967.imp>