steam-for-linux icon indicating copy to clipboard operation
steam-for-linux copied to clipboard

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

Open keyvin opened this issue 11 years ago • 266 comments

Edit: Please stop posting stupid image memes or unhelpful messages. This interferes with Valve's ability to sift through the noise and see if anyone can figure out what triggers it.

This may not be a common problem because I change all sorts of configuration about my system. The script in question does something in a really, really stupid way, but it probably doesn't trigger the fail scenario for every system because...

Original Bug: I am not sure what happened. I moved the folder in the title to a drive mounted under /media/user/BLAH and symlinked /home/user/.local/steam to the new location.

I launched steam. It did not launch, it offered to let me browse, and still could not find it when I pointed to the new location. Steam crashed. I restarted it.

It re-installed itself and everything looked great. Until I looked and saw that steam had apparently deleted everything owned by my user recursively from the root directory. Including my 3tb external drive I back everything up to that was mounted under /media.

Everything important, for the most part, was in the cloud. It is a huge hassle, but it is not a disaster. If there is the chance that moving your steam folder can result in recursively deleting everything in the directory tree you should probably just throw up an error instead of trying to point to other stuff. Or you know, allow the user to pick an install directory initially like on windows.

My system is ubuntu 14.04, and the drive I moved it to was ntfs if its worth anything.

keyvin avatar Jan 14 '15 23:01 keyvin

I am impressed how calm you stay about this. This is terrible. I just lost my home directory. All i did was start steam.sh with STEAM_DEBUG=1. I will investigate this and report back.

edit1: I suspect steam.sh got some bugs(does not check own variables) and when it tried to do scary things it crapped himself. Line 468: rm -rf "$STEAMROOT/"*

edit2: It gets better. Seems on windows Steam is overeager too! https://support.steampowered.com/kb_article.php?ref=9609-OBMP-2526 (The warning part is interesting. Because everybody reads this before uninstalling...)

doofy avatar Jan 15 '15 00:01 doofy

I agree, that line minimally requires an exists and not null check for $STEAMROOT

Tele42 avatar Jan 15 '15 01:01 Tele42

#scary!

As an ex programmer, that really makes me chuckle. Can I at least get an apology from whoever committed that comment without adding a fix?

keyvin avatar Jan 15 '15 02:01 keyvin

This also happened to me a few weeks ago, my entire home was deleted by the steam.sh script.

CamilleScholtz avatar Jan 15 '15 20:01 CamilleScholtz

introduced here Sep 10, 2013 https://github.com/indrora/steam_latest/commit/21cc14158c171f5912b04b83abf41205eb804b31 line 359

rm -rf "$STEAMROOT/"* could be evaluated as rm -rf "/"* if $STEAMROOT is empty

but what exactly caused this? i've symlinked ~/.local/share/steam to, so i am a bit afraid to start steam :/

pythoneer avatar Jan 15 '15 20:01 pythoneer

pythoneer,

I believe the issue starts on line 19:

# 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)"
STEAMDATA="$STEAMROOT"

This probably returns as empty which mean: rm -rf "$STEAMROOT/"* is the same ass rm -rf "/"*.

TcM1911 avatar Jan 15 '15 21:01 TcM1911

TcM1911,

that's my guess, too.

pythoneer avatar Jan 15 '15 21:01 pythoneer

@keyvin @d00fy : Line proceeded by # Scary! comment is in reset_steam() function, which is executed if and only if steam.sh is invoked with --reset as first argument.

Did any of you deliberately invoked that script with that option? If yes, why did you do it? What were you trying to achieve?

Removing user data is obviously wrong, no doubt about it. But if this happens only when user requests certain action, scope of that issue is somewhat limited.

ghost avatar Jan 15 '15 21:01 ghost

Yeah, they kinda need a readlink in there.

STEAMROOT=$(readlink -nf "${0%/*}")

jthill avatar Jan 15 '15 21:01 jthill

@Minio Not "only if". reset_steam is also invoked by removing your .steam directory, since that sets INITIAL_LAUNCH

jthill avatar Jan 15 '15 21:01 jthill

@Minio A script accidentally running rm -rf /* is unacceptable in any scenario.

soren121 avatar Jan 15 '15 21:01 soren121

it is like bumblebee all over again! https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/issues/123

gtmanfred avatar Jan 15 '15 21:01 gtmanfred

I encountered Steam behaviour like with «--reset» for several times: when I added «--reset» AND when I didn't. So — not «only if», can confirm this, even having not deleted ~/.steam/ dir, too.

Plaque-fcc avatar Jan 15 '15 21:01 Plaque-fcc

wonder what the code path is to hit that rm without --reset

prometheanfire avatar Jan 15 '15 22:01 prometheanfire

Can confirm; I have Steam bounded in an SELinux context ("Steam") and SELinux spits out:

Context violation: process /home/indrora/.local/share/Steam/ubuntu12_32/steam is only allowed in context steam_context, attempted to remove /boot/efi/grub/efistub

Ooops. I'll write a patch and PR it :beer:

indrora avatar Jan 15 '15 22:01 indrora

https://github.com/lrusak/steam_latest/pull/1 PR

indrora avatar Jan 15 '15 22:01 indrora

Does anybody have reliable repro steps for this? I can easily add the checks for STEAMROOT being empty, but I would also like to fix the root cause if possible.

johnv-valve avatar Jan 15 '15 23:01 johnv-valve

It will definitely fail if you run steam.sh as bash steam.sh. I don't know if that's the cause in this case. In terms of root cause, I would say you should use set -e, set -u, and similar options in order to make the script less likely to silently ignore errors.

rcxdude avatar Jan 15 '15 23:01 rcxdude

Using ${STEAMROOT:?} instead of $STEAMROOT would have helped, too.

(For those not familiar, ${FOO:?} is identical to $FOO except that it errors out automatically if $FOO is empty or unset.)

ayust avatar Jan 15 '15 23:01 ayust

Which is the same thing that would have happened had the unnecessary '/*' not been there anyway, it would have errored out. Its not necessary because the rm was set to recursive already...

if [ ! -z "${STEAMROOT}" ]; then
   rm -rf "${STEAMROOT}"
fi

ju2wheels avatar Jan 16 '15 00:01 ju2wheels