openrc bootmisc script rm -rf'd my box
This was discussed extensively on IRC when it happened at the end of June, and I thought an issue had been opened, but apparently not. So here it is.
Somehow, after rebooting following a system crash, the boot hung during init scripts with "Wiping /tmp directory" on the screen. After about 15 or 20 seconds I realized it was probably wiping something other than /tmp and hit the power switch, but the damage had already been done. Thankfully I was able to recover most important things, but this should never have happened.
bootmisc init script has some Rube Goldberg machine around figuring out which directories it should wipe, and performs the deletion via
cd "$dir" || return 1 followed by
rm -rf -- [!ajlq\.]* which might as well be
rm -rf *. I don't know how it got past the
cd without being in the right directory or if that's even how it happened, but a command line that
rm command should not be present anywhere in any script, much less one that's preinstalled as part of the base system. There should be no complex logic to determine the directories to wipe, and the absolute pathname should be in the glob on the
rm command line itself, not depending on being in a particular working directory. If it's even done at all.