Protection from the dreaded "rm -fr /"

Dmitry Frolov frolov at riss-telecom.ru
Sat Oct 2 12:37:55 PDT 2004


* Giorgos Keramidas <keramida at freebsd.org> [02.10.2004 16:07]:

> On 2004-10-02 11:51, Giorgos Keramidas <keramida at freebsd.org> wrote:
> > On 2004-10-02 10:34, Michael Reifenberger <mike at reifenberger.com> 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 <frolov at riss-telecom.ru>
RISS-Telecom Network, Novosibirsk, Russia
66415911 at ICQ, +7 3832 NO WA1T, DVF-RIPE


More information about the freebsd-hackers mailing list