5 ms·
Reminds me of the Steam bug back in 2015 [1] where on Linux, if you tried to move where Steam stored downloaded games, it would wipe your hard drive by running
by michaelt 7y ago
Reminds me of the Steam bug back in 2015 [1] where on Linux, if you tried to move where Steam stored downloaded games, it would wipe your hard drive by running "rm -rf "$STEAMROOT/"*" with $STEAMROOT being null.
[1] https://github.com/valvesoftware/steam-for-linux/issues/3671#issuecomment-70021818 https://github.com/valvesoftware/steam-for-linux/issues/3671...
- outworlder 7y agoThere was a similar issue with EVE Online deleting boot.ini https://www.eveonline.com/article/about-the-boot.ini-issue https://www.eveonline.com/article/about-the-boot.ini-issue
- olafure 7y agoI start bash scripts, by setting the holy trinity: set -eou That prevents end-of-the-world scenario like the one above, if the script derails.
- saagarjha 7y agoMaybe also add "pipefail" to the end of that?
- scarejunba 7y agoHaha right, I feel like these should always be popularized as `set -eu` and `set -o pipefail` rather than making it look like you an `set pipefail`. I wonder if that chap has been uselessly printing options at the beginning of scripts for a while now.
- loeg 7y agoalias rm='rm --no-preserve-root'
- jen20 7y agoOf course, Linux could do what Solaris did decades ago and define the directory order in which `rm -rf /` works to start with `pwd` - and thus fail immediately. That would fix that problem completely.
- w-m 7y agoHow did they fix that, in the rm binary? In the example above, the command would be `rm -rf /` without the variable present, and the shell would expand / to all the folders in /. So it's not a direct call to `rm -rf /`, you would need to handle the shell expansion of /* as well?
- jen20 7y agoI missed the * on the end.
- techslave 7y agoyou can rmdir $PWD no problem. as long as there are no files in it. i guess it catches almost all cases though. come to think of it, when would you ever want to rm -rf/? even in a chroot it doesn’t seem like a thing you’d want to do.
- thenewwazoo 7y agoWhen working in chroot jails on embedded distributions, I have needed to run `rm -rf /`. It's admittedly really edge-casey, but it's happened.
- css 7y agoDid they remove this from the git history? I cannot find the original code or the commit that fixed it.