From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 3 17:38:19 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0788D16A4CE for ; Sun, 3 Oct 2004 17:38:19 +0000 (GMT) Received: from harmony.village.org (rover.village.org [168.103.84.182]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D8BC43D41 for ; Sun, 3 Oct 2004 17:38:18 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (harmony.village.org [10.0.0.6]) by harmony.village.org (8.13.1/8.13.1) with ESMTP id i93HaGx0077468; Sun, 3 Oct 2004 11:36:20 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sun, 03 Oct 2004 11:37:39 -0600 (MDT) Message-Id: <20041003.113739.95785967.imp@bsdimp.com> To: tillman@seekingfire.com From: "M. Warner Losh" In-Reply-To: <20041003030946.GV35869@seekingfire.com> References: <20041002210554.GS35869@seekingfire.com> <20041002.192951.35870461.imp@bsdimp.com> <20041003030946.GV35869@seekingfire.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-hackers@freebsd.org Subject: Re: Protection from the dreaded "rm -fr /" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Oct 2004 17:38:19 -0000 In message: <20041003030946.GV35869@seekingfire.com> Tillman Hodgson writes: : On Sat, Oct 02, 2004 at 07:29:51PM -0600, M. Warner Losh wrote: : > In message: <20041002210554.GS35869@seekingfire.com> : > Tillman Hodgson 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