4 ms·
The best protection against this is ... to create a hundred million files in /aaa/ ?
by JBiserkov 12y ago
The best protection against this is ... to create a hundred million files in /aaa/ ?
- ajross 12y agoSurely " ", as space is the lowest ASCII character you can reliably put in a filename. But only shell globbing is going to sort the output. Saving something from rm -rf of the superdirectory would require ensuring that the name pops out of readdir/getdents first, which is filesystem-specific and not always possible.
- twic 12y agoAnd a complete copy of /bin in /z.
- anon4 12y agoThe best protection is to do chattr +i on all binaries and shared objects in /bin, /lib and /usr, and only lift it for upgrades. Possibly also for everything under /etc except /etc/mtab. And for everything under /boot, preferably mounting it read-only if it's on a separate fs. It might get really annoying really fast though and only iron discipline will prevent you from forgetting to chattr +i something back after chattr -i to do an upgrade. And if you have such a good discipline, you're extremely unlikely to ever do a rm -rf /*. It would be nice if you could have some hook in the package manager so you could write something to automatically chattr -i relevant files and then chattr +i them back. And a vim macro to do the same when you save a file in /etc.