Live data from Hacker News

Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

github.com

21–30 of 280 posts

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#21
post #3

Here's the offending shell script code: # figure out the absolute path to the script being run a bit # non-obvious, the ${0%/*} pulls the path out of $0, cd's into the # specified directory, then uses $PWD to figure out where that # directory lives - and all this in a subshell, so we don't affect # $PWD STEAMROOT="$(cd "${0%/*}" && echo $PWD)" [...] # Scary! rm -rf "$STEAMROOT/"* The programmer knew the danger and di…

Gotta question why they used -f.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#23
post #8

The biggest lesson here is that backing up your files is extremely important. Both local backups and remote backups. I like the 3-2-1 rule: At least three copies, In two different formats, with one of those copies off-site. Software is written by humans who will undoubtably miss a corner case and not think of every possible environment.

You're too kind :)

Granted, part of the blame lies in the archaic Unix security model which doesn't sandbox applications. But ANY line containing "rm -rf" should be reviewed by the most senior dev in the company, or at least one who actually understands shell scripting. It has such a terrible failure mode, there's no excuse not to. (Especially when the dev to blame knew that it's "Scary!".)

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#25
We all make mistakes when coding. However, knowing an engineer at Valve did this in a way makes me feel a little bit better about my abilities as a software engineer. At the end of the day we are all human and makes something like working at Valve/Google/Big Name Corp a little less daunting.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#26
post #21
post #3

Here's the offending shell script code: # figure out the absolute path to the script being run a bit # non-obvious, the ${0%/*} pulls the path out of $0, cd's into the # specified directory, then uses $PWD to figure out where that # directory lives - and all this in a subshell, so we don't affect # $PWD STEAMROOT="$(cd "${0%/*}" && echo $PWD)" [...] # Scary! rm -rf "$STEAMROOT/"* The programmer knew the danger and di…

Gotta question why they used -f.

So the script wouldn't pause and ask for user input during normal operation.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#28
post #11

I don't want to blame anyone, but maybe there should be foolproof default security measures that prevent something like this from happening. For example rm -rf called on a home, documents, music, photos etc. directory could require an additional confirmation, perhaps through a GUI.

There are, it's called users, and groups, and file permissions. Applications like steam should really be running under a separate user so they can't write to personal files (and maybe just have read permissions). But of course proper application isolation and file permissions is something few people do correctly on their personal machines, let alone know about.

Window managers don't make it any easier, and I put a lot of the blame on them for not making it easy to configure applications to start under different users.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#29
post #8

The biggest lesson here is that backing up your files is extremely important. Both local backups and remote backups. I like the 3-2-1 rule: At least three copies, In two different formats, with one of those copies off-site. Software is written by humans who will undoubtably miss a corner case and not think of every possible environment.

You're too kind :) Granted, part of the blame lies in the archaic Unix security model which doesn't sandbox applications. But ANY line containing "rm -rf" should be reviewed by the most senior dev in the company, or at least one who actually understands shell scripting. It has such a terrible failure mode, there's no excuse not to. ( Especially when the dev to blame knew that it's "Scary!".)

Interesting:

https://github.com/search?q=rm+-rf&type=Code&utf8=%E2%9C%93

Post reply on HN