Live data from Hacker News

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

github.com

221–230 of 280 posts

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

#221
post #200

Earlier quoted context omitted.

While you're at it: set -e # exit on unchecked failure That way you don't trudge forward through an untested code path after a failure, you stop there and then.

I use this holy trinity in most of my scripts: set -o nounset # set -u set -o errexit # set -e set -o pipefail # I'm not sure this has a short form. I use the long forms for the option names because they're self documenting. If anyone has more suggestions, I'm all ears.

David A. Wheeler recommends setting IFS=$'\n\t' to handle spaces in filenames & variables.

http://www.dwheeler.com/essays/filenames-in-shell.html

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

#222

This seems like yet another good example of why robust application-level access control would be a helpful thing to build into modern operating systems, in addition to the typical user-based controls. This may have been both a rookie mistake and a regrettable failure of code review processes, but in any case it simply shouldn’t be possible for an application running on a modern system to wipe out all user data withou…

As a more immediate fix with less collateral damage, since Unix programmers refuse to stop putting `rm -rf` commands in shell scripts (they seem to think the suggestion is an insult to their manhood), change the behavior of rm so that by default it either disregards -rf or moves the target files to a trash directory where they can be retrieved in the event of an error.

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

#223
post #141

Wow, an awful bug -- and brings back memories of a very similar bug that we had back in the late 1990s at Sun. Operating system patches on Solaris were added with a program called patchadd(1M), which, as it turns out, was actually a horrific shell script, and had a line that did this: rm -rf $1/$2 Under certain kinds of bad input, the function that had this line would be called without any arguments -- and this (like…

>A self-destruct button really doesn't make sense Bryan--you mean Star Trek didn't get it right? Well, at least they didn't allow shell scripts. It's an interesting philosophical question though. At what point do you decide that the user truly really can't want to do this even though they've said that they do?

rm -rf is not self-destruct button. It's just a "take everything out of the closets, rip of the labels, and throw it on a heap".

A real self-destruct button would ensure you couldn't recover the data anymore.

So at least try "dd if=/dev/random of=/dev/sda" or more elegant when available, throw away the decryption key.

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

#224
post #91

Earlier quoted context omitted.

There are several problems with your ideas. The most important one is that programmers only call themselves engineers until it comes time to take legal responsibility for their work; then suddenly they're artists creating works for hire. Programmers have worked very hard through the years to create the current liability-free environment; people die because of health care programming bugs, pilots crash because of avio…

Can anyone design a safe and reliable bridge with a span of indeterminate length across unpredictable geography?

This is precisely why I hate comparing building software to building bridges. Nobody builds bridges without knowing exactly where that bridge will be standing, but it happens all the time with software - furthermore same piece of software usually must fit all kinds of "unpredictable geography". As such, yes, I do think that building software is a problem far more difficult than building bridges.

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

#225

Earlier quoted context omitted.

Not if the previous line was: STEAMROOT=$SOME_OTHER_UNSET_VARIABLE/ "rm -r " is a code smell, as much as "cc -o myprog .c" is. You should always know what files make up your system, and track them in a MANIFEST file. There's rarely a good reason to use wildcards when a program is dealing with its own files. xargs rm -df -- fixes this.

rm --preserve-root isn't a bad thing to have either. That way, even if you do screw up, you won't be able to run rm against '/', even with '-f'. It's one of the top aliases in my .bash_aliases file.

I think that

    rm --preserve-root -rf /*
doesn't save you.

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

#226
post #16

Since this kind of thing keeps happening, isn't there a need for a safer tool than shell scripts? Maybe with a little bit more safety around null/empty variables and not as stringly typed?

Tools that are safer then shell scripts exist, doesn't mean that end users have them installed, doesn't mean people will chose to you them either

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

#227
post #207

Earlier quoted context omitted.

Steam is another category of application which wants to write to directories used by other applications...

Why? In my Windows VM, all Steam data lives in C:\Program Files\Steam. (Plus start menu entries etc.)

Steam manages game installation and updates; those games are themselves separate applications. That's what I was referring to.

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

#228

Earlier quoted context omitted.

Just because you've invented solar panels does not mean that you've solved the energy crisis. Sometimes the implementation of technology is just as inventive as the invention itself.

lol, ok lets break this down Barney style: Converting sunlight to electricity is a solved problem. The "energy crisis" remains unsolved. Jailing processes is a solved problem. Preventing users from shooting themselves in the foot remains unsolved. Now let us reexamine the post: > ...would be a helpful thing to build into modern operating systems... Already built in. > Why can’t we also have something analogous where…

I’m well aware of strategies using chroot, virtual machines, and the like. These are useful tools up to a point, but a long way short of what I would ideally like to see. For example, they restrict access at a very coarse level compared to the kinds of user/group/ACL models we use in many other contexts. By their nature, they also do not admit convenient ways to break out of the jail with the user’s explicit consent. Once you get beyond individual applications with their own dedicated file types and consider more generic cases like text editors working on text files that are likely to exist throughout a filesystem, this lack of flexibility is a serious limitation. Another key distinction is that chroot and the like are voluntary mechanisms, usually off by default and therefore not completely enforced by the OS.

Some systems mentioned in this HN discussion are closer to the kind of model I had in mind. As other posters have pointed out, the difficulty is how you structure a system so that it is reasonably effective by default but still usable by non-experts. I believe we could achieve this — or at least get much closer than the typical security models we use at the moment — but it will surely take a lot more thought and experimentation than we have attempted as an industry so far. Microsoft’s UAC mechanism makes an interesting case study here: it was fundamentally a reasonable idea, but the first implementation proved too intrusive for average users to tolerate and lost much of its effectiveness as a result.

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

#229
post #227

Earlier quoted context omitted.

Why? In my Windows VM, all Steam data lives in C:\Program Files\Steam. (Plus start menu entries etc.)

Steam manages game installation and updates; those games are themselves separate applications. That's what I was referring to.

There seem to be several reasonable ways to address this kind of situation without requiring universal access.

One would be analogous to an ACL arrangement rather than simple ownership. Steam applications could be installed with Steam also having permission to access their resources.

A second possibility would be to have the operating system provide dedicated services for installing and maintaining software. We’re already heading in that direction on some platforms anyway, and it would be useful generally given the kind of security model I suggested. Then software like installers/updaters or package managers can do their jobs in a tightly controlled way, without needing any general access or introducing the accompanying security risks.

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

#230

This seems like yet another good example of why robust application-level access control would be a helpful thing to build into modern operating systems, in addition to the typical user-based controls. This may have been both a rookie mistake and a regrettable failure of code review processes, but in any case it simply shouldn’t be possible for an application running on a modern system to wipe out all user data withou…

Like AppArmor, or SELinux, or any of the other applications which have their hooks in the LSM? They do a fantastic job of this, if you can figure out how to use them. The truth is that they are too hard for even your average Sysadmin to configure & manage, let alone your average desktop user. setenforce=1 (yeah, right).

Yes, and I also agree that there are substantial unsolved problems in making such fine-grained systems practically useful for non-expert users.

I’d like to see the industry moving in that general direction, though. Even a much simpler model could bring real benefits relative to the status quo, where in application terms our current security model is analogous to everything being root.

Post reply on HN