Live data from Hacker News

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

github.com

11–20 of 280 posts

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

#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.

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

#12
A while ago I made a small program to cache Steam's grid images and search missing ones (https://github.com/boppreh/steamgrid). More of an experiment in programming in Go, really, but it works and makes Steam a little better.

When I tried on Linux, it threw a permission error. Turns out Steam installs the folder "~/.local/share/Steam/userdata/[userid]/config/grid" without the executable permission bit. Without this bit no one can create files in there, Steam included, and the custom images feature gets broken.

I reported the problem, saying they should fix their installer, and got a "have you tried reinstalling it?" spiel. When I said I did, and manually changing the permission fixes the problem, so it must really be it, they closed the ticket with "I am glad that the issue is resolved".

This was a ticket at support.steampowered.com, because I didn't know Valve had a github account. I would open an issue there, but I don't have a linux installation to test again and this sort of misunderstanding burns a lot of goodwill.

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

#13

# Scary! rm -rf "$STEAMROOT/"* Anybody who writes a line like this deserves their software engineer license revoked. This isn't the first time I've seen shit like this (I've seen it in scripts expected to be run as root, no less); it makes my blood boil. Seriously. "xargs rm -df -- EDIT: I shouldn't be so harsh, if it weren't for the comment admitting knowing how poor an idea this line is.

The programmer committed a cardinal sin to be sure. But, so did everyone on the code review that let it slide.

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

#14

Note to all, prepend all your bash script with "set -o errexit -o nounset -o pipefail" It'll save you headaches.

Yep, my thought exactly. My standard bash header is

    #!/bin/bash
    set -eu
    IFS=$'\n\t'
(Wish there was a shorthand version of pipefail, then I'd always use that too.)

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

#15

# Scary! rm -rf "$STEAMROOT/"* Anybody who writes a line like this deserves their software engineer license revoked. This isn't the first time I've seen shit like this (I've seen it in scripts expected to be run as root, no less); it makes my blood boil. Seriously. "xargs rm -df -- EDIT: I shouldn't be so harsh, if it weren't for the comment admitting knowing how poor an idea this line is.

[deleted]

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

#17
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…

Yikes. That should never have passed a code review. I know mistakes happen, I often defend screw-ups, but anything in a shell script that has an "rm" command should automatically get the squinty eyes.

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

#19
Something like this with Steam happened to my friend not too long ago. It was very saddening because he literally lost years of files (including personal projects) and salvaged what he could. That was with the Steam Beta and I caught Steam doing this myself (after he told me what happened). I was lucky to stop the script and switched out of the beta. At the time he reported this to Valve themselves and said they were "investigating the issue and knew of it". Seems to still be here, sigh.

I know the morale here is keep your files backed up but come on, this is a ridiculous issue Valve still hasn't fixed.

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

#20
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…

Would this have stopped things getting deleted?

    if [ -z "$STEAMROOT" ]
       # something isnt right...
Post reply on HN