Man destroys his business with 1 line of code

so any one got an answer why anyone would write a line of code with a ww2 film reference for ****ing things up?

Foobar or foo and bar are terms used to reference something, as a placeholder. The computer science equivalent of using "X" and "Y".
 
Foo and Bar are traditional names used for generic variables in coding examples. And Fubar (****ed Up Beyond All Recognition) is a military term that long predates that movie (which I've never seen).

yes hats why that moive references it

as a total non coder im just trying to work out why a man would write a self destruct line into his code?
 
I once worked with someone who caused a dozen flight delays for several major airlines, all because he was trying to use net send to prank a colleague. He accidentally sent the message to everyone in the company.

Somehow, he didn't lose his job. Well not on that occasion anyway.
 
yes hats why that moive references it

as a total non coder im just trying to work out why a man would write a self destruct line into his code?

I suspect from reading between the lines he had a bash script that is normally called by another script filling in the variables with valid data and in this case he accidentally called that bash script directly and as the variables weren't provided it continued as if they were blank data and just executed the first bit before it which was a recursive forced delete of files.

EDIT: He claims a bug in the first script caused those variables when passed to be blank but I'd bet he accidentally executed the wrong script :P
 
how can 1 line of code deleted everything?!?

Apparently he had an entry in his script that went:

"rm -rf foo/bar" where foo and bar are variables. rm is a GNU/Linux command for removing files, hence "rm". -rf is passing two extra commands to rm with the -r meaning "recursive", i.e. it traverses all the way down the directory / folder system into all the sub-folders. And -f means "force". I.e. don't pause and ask for confirmation, just do it and don't bother me with questions about read-only files and so forth.

In UNIX systems "/" is the root directory where everything starts. He says in his question that foo and bar weren't set by mistake - which means they're blank. So "rm -rf foo/bar" becomes "rm -rf /". I.e. start at the root directory and recursively remove everything from there and below, without asking for confirmations or double-checking anything.

Allegedly, his back up systems were mounted under root as well. You can do that so that they should up as just regular directories. So he wiped his back-ups as well.

All this assumes it's true. Searching on his name throws up pages of news "sources" just circulating the same story over and over again with nobody actually showing any confirmation or a company name.
 
yes hats why that moive references it

as a total non coder im just trying to work out why a man would write a self destruct line into his code?

It's not a self destruct line, but a very powerful command to delete files/folders.

rm -rf will remove files from a folder without being prompted (f = force, r = recursive to include any folders), I'm guessing due to the program messing up, $foo may have held the value of * which $bar may have held nothing or /.

Meaning the command he run was 'rm -rf */' or the likes which will have removed everything from the root directory upwards (root is /), which would be the entirety of the server and anything connected.

Why he would mount backup drives to his file system makes no sense what so ever.
Why you would have rm in a script that has to do with backups is insane!
 
Last edited:
All this assumes it's true. Searching on his name throws up pages of news "sources" just circulating the same story over and over again with nobody actually showing any confirmation or a company name.

Even if this story and/or the consequences are made up it has happened before heh.
 
yes hats why that moive references it

as a total non coder im just trying to work out why a man would write a self destruct line into his code?

It's not a self-destruct line, it's a line that takes a given input and does something. I might want to have a script that does (simplified example):

rm -rf customer/old_data

to clean things up for maintenance. But both customer and old_data are variables that get passed in, otherwise you'd have to have a different command for every single time you ran this! He's saying that he accidentally passed in blank values for those things, meaning he was left with "rm -rf /" I.e. right command, completely the wrong place.

Think of it as if you shot yourself in the foot. People wouldn't ask you why you had a gun designed for shooting yourself in the foot, they'd ask why you pointed it at that in the first place.

If this is true, then there were serious flaws in his set-up, though this sort of stuff could happen with a one-person business not doing things by the book.
 
Easy to say in hindsight but a good idea to validate any variables immediately before any command that has a destructive effect. Need to make a note to keep that in mind for any future stuff :S
 
Easy to say in hindsight but a good idea to validate any variables immediately before any command that has a destructive effect. Need to make a note to keep that in mind for any future stuff :S

Even better idea to have your backups logically separated from your production systems. It's possible to both set up backups that can only add, not delete, and also to set up file systems that preserve history of all changes.
 
Any person worth their salt:
a) doesn't run in administrator privileges all the time
b) separates their live and development systems
c) has code/asset configuration management
d) has backup systems.

Seems amateur to have anything that allows someone todo "rm -rf *" and delete everything..
 
Even better idea to have your backups logically separated from your production systems. It's possible to both set up backups that can only add, not delete, and also to set up file systems that preserve history of all changes.

Yup - my personal home backup system is a bit primitive but:

-QNAP TS-419 NAS
-2 disc mirrored RAID internally (for uptime convenience if one fails) with realtime replication to a regular NTFS USB drive plugged in the back.
-Certain folders sync'd to online cloud storage
-Front USB copy port setup to synchronise critical data to whatever is plugged into the front port on pressing the button - with which I rotate between 3 external USB drives so as to have an offline copy.
 
It's not a self destruct line, but a very powerful command to delete files/folders.

rm -rf will remove files from a folder without being prompted (f = force, r = recursive to include any folders), I'm guessing due to the program messing up, $foo may have held the value of * which $bar may have held nothing or /.

Meaning the command he run was 'rm -rf */' or the likes which will have removed everything from the root directory upwards (root is /), which would be the entirety of the server and anything connected.

Why he would mount backup drives to his file system makes no sense what so ever.
Why you would have rm in a script that has to do with backups is insane!

If the system runs with it's working directory as / (root) then I'm not surprised.

rm -rf / will remove everything from root downwards IIRC.

Typically you'd need to do "sudo rm -rf /". If the two variables are empty then the path to the rm command will be "/". No code reviews?

So the back up is simply a mirror of the current state to a different system.. it's not a incremental backup that maintains the files over time...

Seriously I think the guy's professionalism is in doubt.
 
Last edited:
Seriously I think the guy's professionalism is in doubt.

80% of those smaller hosters are people who've a moderate amount of experience doing the best they can on the side to be fair - I spent a fair amount of time doing technical support for one of the GSPs which is a fairly similar environment.

EDIT: A large number go out of business one way or another largely due to lack of professionalism.
 
Last edited:
Back
Top Bottom