News for hackers. Stuff that matters.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by dvdhnt on Tuesday January 17, 2017 @09:11AM (#13417617)
From the next web write up -

> The command that had been run was most likely ‘rm -r -f *’, which—roughly speaking—commands the system to begin removing every file below the current directory. This is commonly used to clear out a subset of unwanted files. Unfortunately, someone on the system had run the command at the root level of the Toy Story 2 project and the system was recursively tracking down through the file structure and deleting its way out like a worm eating its way out from the core of an apple.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by knodi123 on Tuesday January 17, 2017 @09:52AM (#13417978)
As a linux neophyte, I once struggled to remember whether the trailing slash on a directory was important. So I typed "rm -rf", and pasted the directory name "schoolwork/project1 " (with a trailing space), but then I waffled and decided to add a trailing slash. So I changed it to "rm -rf schoolwork/project1 /".

That's my theory as to what they did.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by Symbiote on Tuesday January 17, 2017 @10:08AM (#13418116)

  rm -Rf test /
  rm: it is dangerous to operate recursively on ‘/’
  rm: use --no-preserve-root to override this failsafe
GNU rm, but I don't know when it was introduced.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by r3bl on Tuesday January 17, 2017 @10:19AM (#13418200)
Quick googling around, and it seems like this behavior (in Ubuntu) changed somewhere near the end of 2008: https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/174...

tl;dr That's when coreutils Ubuntu package switched from "--no-preserve-root" to "--preserve-root" by default.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by blitzkrieg3 on Tuesday January 17, 2017 @10:57AM (#13418545)
This is relatively recent, and caused quite a stir when it was introduced. Certainly not around during Toy Story 2.

edit: More info:

https://lwn.net/Articles/327141/

Re:Did Pixar accidentally delete Toy Story 2 during producti... by coldpie on Tuesday January 17, 2017 @11:10AM (#13418670)
One feature I've always wanted is to make a directory non-deletable without otherwise changing the directory's functionality. So if I do "rm -rf ~/work" I don't lose anything, but I can still do "touch ~/work/whatever". As far as I know, this is impossible.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by slau on Tuesday January 17, 2017 @12:46PM (#13419474)
You don't actually need write access to a file/directory to delete it. You only need write access to the parent (removing or adding a file modifies the container, not the contained).

Remove write access to the parent directory, while keeping traversal and read rights, and you'll be sorted.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by coldpie on Tuesday January 17, 2017 @01:43PM (#13419943)
But then I can't add files to my home directory...
Re:Did Pixar accidentally delete Toy Story 2 during producti... by vidarh on Tuesday January 17, 2017 @02:17PM (#13420245)
So don't put the stuff you want to protect this way in your home directory, but somewhere else, and symlink the relevant directories to your home directory.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by coldpie on Tuesday January 17, 2017 @03:32PM (#13420896)
Quite clumsy, but I guess it works. I'll keep it in mind, thanks for the idea.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by slau on Tuesday January 17, 2017 @02:05PM (#13420138)
You said it was impossible. I simply indicated it wasn't.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by coldpie on Tuesday January 17, 2017 @03:06PM (#13420679)
The question was perhaps imprecisely phrased, but I think you can figure out what I'm trying to accomplish.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by knodi123 on Tuesday January 17, 2017 @02:32PM (#13420372)
# mkdir /tmp/foo

# touch /tmp/foo/.immutable

# chattr +i /tmp/foo/.immutable

# rm -rf /tmp/foo

It's not EXACTLY what you asked for, but the .immutable file cannot be deleted until you call chattr -i on it, which protects the directory....

Re:Did Pixar accidentally delete Toy Story 2 during producti... by coldpie on Tuesday January 17, 2017 @03:05PM (#13420675)
That doesn't protect siblings of <foo/.immutable>...
Re:Did Pixar accidentally delete Toy Story 2 during producti... by alephnil on Tuesday January 17, 2017 @02:07PM (#13420159)
If I remember correctly, they were using Solaris at the time, and I know for sure that Solaris did not have this safety net, nor did Linux at the time. The requirement of --no-preserve-root was introduced almost a decade later.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by cobbzilla on Tuesday January 17, 2017 @09:48AM (#13417940)
obligatory call for everyone to use safe-rm [1].

it's one thing to shoot yourself in the foot, but without safe-rm you (or someone else less cautious) will eventually fire the accidental head-shot. it's happened to me a couple times; but never again since I started using safe-rm everywhere.

[1] http://serverfault.com/questions/337082/how-do-i-prevent-acc...

Re:Did Pixar accidentally delete Toy Story 2 during producti... by hh2222 on Tuesday January 17, 2017 @10:31AM (#13418307)
I'll add another obligatory, make sure you have a working backup system.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by esquevin on Tuesday January 17, 2017 @11:06AM (#13418627)
And that you already tried to restore from it
Re:Did Pixar accidentally delete Toy Story 2 during producti... by wmil on Tuesday January 17, 2017 @09:17AM (#13417673)
It's more likely they wanted to remove all hidden directories from their home directory, and ran `rm -rf .*`.

Under some shells (eg bash) that will expand to include `..` and `.`.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by reacweb on Tuesday January 17, 2017 @09:38AM (#13417868)
The last time it happened to me, it was caused by a space. Instead of rm -rf toto٭, I had rm -rf toto ٭.

Hopefully, it was not at the root directory and we have frequent snapshots.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by aptwebapps on Tuesday January 17, 2017 @09:43AM (#13417903)
I have totally never done that. If I had done that, I might have been saved by a lack of permissions. Like if I was on a mounted external drive, so not in my home directory and it didn't get too far.

Edit: What would have been much more worse, if I had done it, would have been

    rm -rf ~ /foo
instead of

    rm -rf ~/foo
Re:Did Pixar accidentally delete Toy Story 2 during producti... by majewsky on Tuesday January 17, 2017 @09:50AM (#13417961)
Such a bug was in an Nvidia driver install script a few years ago:

  rm -rf /usr /lib/modules/something/something
Re:Did Pixar accidentally delete Toy Story 2 during producti... by czinck on Tuesday January 17, 2017 @10:29AM (#13418294)
Bumblebee specifically, https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/commi... is the fix. Pretty sure Steam had the same issue early in their linux release, probably lots of other programs too.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by cookiecaper on Tuesday January 17, 2017 @05:46PM (#13422216)
Yes, I specifically remember a lot of hub bub about Steam deleting entire home directories if a path was input incorrectly. Glad that never bit me.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by peterkelly on Tuesday January 17, 2017 @11:11AM (#13418681)
And also iTunes, back in the early days of OS X:

https://www.wired.com/2001/11/glitch-in-itunes-deletes-drive...

Re:Did Pixar accidentally delete Toy Story 2 during producti... by Slackwise on Tuesday January 17, 2017 @10:53AM (#13418500)
This is why I never use bash for scripting, and opt for Ruby instead.

You can use the `Pathname` class to treat paths as objects, which you can concatenate only valid paths with. Aside from obviously all the other sanity-saving features.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by cookiecaper on Tuesday January 17, 2017 @05:52PM (#13422264)
Same. Ruby isn't my preference, but I avoid bash scripting whenever possible. I see very little need to use it when practically every machine requires Python, Ruby, and other high-level dynamic languages as pre-requisite for some basic software that's included by default. I respect bash, but it's from a bygone time. Why deal with the esoteric one-character test operators, the nitpicky spacing issues, etc? Use modern, readable, testable code. So much nicer and easier to read and work with that way.

I'd love to see someone deploy a Python or Ruby-based shell. I'm sure these are available, but they're not widely used.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by dragonwriter on Tuesday January 17, 2017 @06:01PM (#13422328)
Bash may be worse than Ruby or Python for scripting, but it's far better as an interactive shell.

And I'm quite happy not having shell use hold back evolution of Ruby or Python, and not having drama like Ruby 1.8 -> 1.9 or Python 2.x -> 3.x affecting shell use.

Re:Did Pixar accidentally delete Toy Story 2 during producti... by yomly on Tuesday January 17, 2017 @10:28AM (#13418286)
That's mortifying!
Re:Did Pixar accidentally delete Toy Story 2 during producti... by grkvlt on Tuesday January 17, 2017 @10:17PM (#13423693)
Or, maybe you forget which directory you are in, and delete the wrong one that way: `rm -rf ../*` when you think you're in `/mnt/work/grkvlt/tmp` but are actually in `/mnt/work/grkvlt` at the time.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by cobbzilla on Tuesday January 17, 2017 @12:10PM (#13419157)
or perhaps it was the dreaded "rm -rf ${DIR}/*" when $DIR is not defined.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by throwawayish on Tuesday January 17, 2017 @12:49PM (#13419507)
Safe shell coding tip #10451: Variables containing directories always have to end in a slash, and paths may never be built using variables and slashes.
Re:Did Pixar accidentally delete Toy Story 2 during producti... by ChristianBundy on Tuesday January 17, 2017 @09:28AM (#13417782)
Why is that more likely?