Steam install can erase my home. How to prevent it?

Solution 1:

The problem starts around line 19 in the script "steam.sh.":

STEAMROOT="$(cd "${0%/*}" && echo $PWD)"
STEAMDATA="$STEAMROOT"

$STEAMROOT can become empty here effectively making the rm -rf "$STEAMROOT/"* further into the script the same as rm -rf "/"*.


There are patches showing up and there is a lot wrong with this script. Easiest to change and at least prevent deleting files it should not ...

rm -rf "$STEAMROOT/"*

to ...

[[ -n $STEAMROOT && $STEAMROOT =~ 'steam' ]] && rm -rf $STEAMROOT

Also possible to add an exit just after STEAMDATA is set:

STEAMROOT="$(cd "${0%/*}" && echo $PWD)"
STEAMDATA="$STEAMROOT"
if [ -z "$STEAMROOT" ]; then
    echo "stop script otherwise files are deleted from /."
    exit 1
fi

If anyone out there installed steam as root be warned: it will delete your WHOLE disk.