From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 3 21:59:42 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 995A116A4CE; Sun, 3 Oct 2004 21:59:42 +0000 (GMT) Received: from smradoch.ath.cx (r2g224.chello.upc.cz [62.245.70.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id C6F2F43D3F; Sun, 3 Oct 2004 21:59:41 +0000 (GMT) (envelope-from neuhauser@chello.cz) Received: by smradoch.ath.cx (Postfix, from userid 1001) id D98441F87BEE; Sun, 3 Oct 2004 23:59:39 +0200 (CEST) Date: Sun, 3 Oct 2004 23:59:39 +0200 From: Roman Neuhauser To: Giorgos Keramidas Message-ID: <20041003215939.GB951@isis.wad.cz> Mail-Followup-To: Giorgos Keramidas , freebsd-hackers@freebsd.org References: <20041002175704.GB2230@gothmog.gr> <20041002230226.GC1381@gothmog.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041002230226.GC1381@gothmog.gr> User-Agent: Mutt/1.5.6i 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 21:59:42 -0000 # keramida@freebsd.org / 2004-10-03 02:02:26 +0300: > On 2004-10-02 17:22, Garance A Drosihn wrote: > > At 8:57 PM +0300 10/2/04, Giorgos Keramidas wrote: > > >On 2004-10-02 21:23, Lee Harr wrote: > > >> How about: > > >> chflags sunlnk / > > >> ? > > > > > >Setting sunlink on / will only protect the / directory, not its > > >descendants, so you don't gain much. > > > > We could add a new flag "srunlnk", or maybe even "srm-r". The "rm" > > command will always have to stat() the file it is given (just to > > see if it is a directory), so it could check to see if this flag > > is turned on. If it is turned on, then 'rm' could refuse to honor > > any '-rf' request on that directory. [...] > > Hmmm. This sounds much better indeed :-) have rm -r[f] behave just like find $@ -flags +sunlnk -prune -o -delete (I hope this is correct; if not: if the file has sunlnk among its chflags, skip it and its descendants) this is something I would, if not like, at least tolerate. specialcasing / stinks. it reminds me of all the RHEL machines I deal with at work that have alias rm rm -i, and I can only thank my luck this hasn't costed me an arm; ls | while read f; do rm -i $f; done is very dangerous, at least in bash. I have once deleted parts of my ~ with rm -fr *, but rm -fr / never happened to me, prolly because of my strong dependence on the shell completion. (I hope I'm not too drunk.) -- If you cc me or remove the list(s) completely I'll most likely ignore your message. see http://www.eyrie.org./~eagle/faqs/questions.html