From owner-freebsd-hackers@FreeBSD.ORG Sat Oct 2 19:37:55 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 6FFA716A4CE; Sat, 2 Oct 2004 19:37:55 +0000 (GMT) Received: from nerve.riss-telecom.ru (nerve.riss-telecom.ru [80.66.65.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id 78A7143D41; Sat, 2 Oct 2004 19:37:54 +0000 (GMT) (envelope-from frol@nerve.riss-telecom.ru) Received: from nerve.riss-telecom.ru (localhost [127.0.0.1]) i92JboVQ019982; Sun, 3 Oct 2004 02:37:50 +0700 (NOVST) (envelope-from frol@nerve.riss-telecom.ru) Received: (from frol@localhost) by nerve.riss-telecom.ru (8.12.10/8.12.10/Submit) id i92Jboaq019981; Sun, 3 Oct 2004 02:37:50 +0700 (NOVST) (envelope-from frol) Date: Sun, 3 Oct 2004 02:37:50 +0700 From: Dmitry Frolov To: Giorgos Keramidas Message-ID: <20041002193750.GA19271@nerve.riss-telecom.ru> References: <20041002081928.GA21439@gothmog.gr> <20041002102918.W22102@fw.reifenberger.com> <20041002085143.GA52519@gothmog.gr> <20041002090635.GA71050@gothmog.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041002090635.GA71050@gothmog.gr> Organization: RISS-Telecom, JSC X-PGP-Fingerprint: 5232 98E7 596E 21C2 52B5 FCAE 8088 3F87 88BC 27B0 User-Agent: Mutt/1.5.1i 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: Sat, 02 Oct 2004 19:37:55 -0000 * Giorgos Keramidas [02.10.2004 16:07]: > On 2004-10-02 11:51, Giorgos Keramidas wrote: > > On 2004-10-02 10:34, Michael Reifenberger wrote: > > > > > > This does only help for the obvious case of '/' but not for the > > > './' and '../' or '../../' ... accidents. > > > > Hmm, indeed. This can be fixed, but it might take a little thinking > > over about ways to implement it without adding too much overhead to the > > way rm(1) works now. > > One way to do that is to use realpath(3), but I have to ask more > knowledgeable people about the comment immediately below my change: Other way that may be cheaper is to stat '/', stat each argument and then compare device and inode numbers. wbr&w, dmitry. -- Dmitry Frolov RISS-Telecom Network, Novosibirsk, Russia 66415911@ICQ, +7 3832 NO WA1T, DVF-RIPE