Protection from the dreaded "rm -fr /"
Jacques A. Vidrine
nectar at FreeBSD.org
Sat Oct 2 09:46:44 PDT 2004
On Sat, Oct 02, 2004 at 10:43:49PM +1000, Peter Jeremy wrote:
> I've had a customer write a cronjob that did almost exactly this.
> He managed to 'test' it on all the (redundant) production systems
> as well as the test model. We were only called in when he found
> that there were some unexpected console messages and the systems
> wouldn't boot when he pressed the reset button. Luckily it
> managed to kill itself before it destroyed all the evidence (since
> the culprit initially denied doing anything).
>
> Based on that, I'm definitely in favour of some anti-foot-shooting
> measures.
[...]
FWIW, I'm not in favor of adding ad-hoc "features" to handle edge-cases.
("feature" because this is actually introducing a bug :-)
I picked this email to which to respond, because I can share my own
stupidity. Case much like the one described above, but my cronjob
included something like:
cd /path/to/directory/with/temporary/files
rm -fr *
Only another admin removed
`/path/to/directory/with/temporary/files'... so the `cd' failed
and left the current directory as `/'. For some reason the system
crashed :-) ... and then crashed again a few days after restoring
from backup... doh!
Will the next step be to prevent `rm -fr *' iff the current working
directory is '/' ? Please explain your answer. :-)
Cheers,
--
Jacques A Vidrine / NTT/Verio
nectar at celabo.org / jvidrine at verio.net / nectar at FreeBSD.org
More information about the freebsd-hackers
mailing list