- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I looovveeee hazards! (NOT!!!)
Once upon a time there was this program that had two input parameters: U1 (update type 1) and U2.
Normally, the program was run with one or the other or both set to Y:
One day we ran the program, but we just wanted the report - no updates. That was when we discovered the result of the (normally unused) remaining combination:
Turned out this was the gist of the code:
Sigh.
Admin
Admin
Thank you for bringing this to my attention. Guards, have Mr. Heltoupee executed.
Admin
Admin
The root thing is annoying: scripts should never need to run as root, just set up your users and groups intelligently.
But the rm -rf thing is inexcusable. It's the exact same problem as above: they're too lazy to do it right. But rm -rf always goes astray at the worst possible time. Put that in an automated script, and you're guaranteed a failure like this.
Admin
Happened here too. Actually, it was the guy who just quit that did it.
Admin
FTFY
Admin
We see what you are doing there, you almost got us.
Admin
C:>cd a:\dir\to\wipe
C:>del . Are you frikking sure? Yes ...
"Hmm... why does this take so long, but the diskette driver isn't working? OMFG, it is still in C: !"
(And yes, I used to like keeping lots of files/games in C:\ at some age)
Admin
Hey, it happens in Windows, too!
If you're running a batch file from Task Scheduler, and do a 'del .' to clean up your work, and you didn't set the startup directory in Task Scheduler, your current working directory is c:\windows\system32.
I fielded that call (worked MS support for malware) many times. Told many customers that nope, it wasn't a virus, it was your script that deleted your operating system.
Admin
FTFY
Admin
Yes, I just can't believe that any programmer in the history of the world has ever logged in as root rather than take the trouble to get all the permissions set so he could do what he needed to do as an ordinary user. Someone taking a short cut because doing it the right way would be too much trouble? That's just unbelievable.
Why, next they'll be trying to tell us that employees sometimes call in sick when really they just don't feel like coming to work today, or that there are politicians who don't live up to their campaign promises.
Admin
Ehm, no: var1="../../../../../../.." var2="."
Oops...
Admin
Someone doesn't use unix very much.
First off, nobody calls it "a Bourne shell script". Just call it a shell script, or maybe even a bash script.
That's not a flaw in sudo, it's a feature. The flaw is when they set up sudo access, they added a line like "luser ALL = NOPASSWD: ALL", which is braindead beyond belief.
A "system set up with NFS" doesn't grant access to the entire network. The people who set up those NFS exports were morons, because they would have had to export / in read-write mode on every single machine affected, with the no_root_squash option no less. Which is braindead beyond belief. In other words, the admins are fucking morons, and they are responsible -- not NFS -- for allowing a remote process to delete the root directory on every server.
Anyone who writes a script that executes "rm -rf $var1/$var2" and fails to check the values of $var1 and $var2 should be fired instantly and never allowed nea ra computer again. His manager should be fired for not requiring code reviews.
sshing into your own machine is retarded, and I'm not buying it.
If you don't verify your backup plan, you get exactly what you deserve.
Admin
Wait a sec.... if the script is ssh'ing into each machine, why is NFS a factor? If it can remotely access files through NFS, why the need to ssh at all? If it can ssh, why bother with NFS?
Something is fishy.
Admin
It's so incredibly sad and reprehensible when I come across code that uses user-input variables and doesn't check the values for obvious things like empty strings or characters that don't match a certain data type. And don't get me started on the lack of range checking I've seen.
People: sanitize your inputs. And not just the Bobby Tables inputs. Use lookup tables for things like states. Use pre-defined values for users to select if you can; instead of letting them enter values free form.
I could go on and on. But Jakob Nielson has already beat this dead horse deader. If you're a programmer and you've never heard of him or at least Donald Norman, you've got some work to do.
Admin
I was sure that most people had learned way back in the 1980s to first check for the folder/directory you want to work in. Then change your default to that folder/directory. Then verify you're actually in that folder/directory. And then happily delete away.
Hell, we even knew this in VMS' hay days.
Admin
In recent Un*x varieties this no longer works.
rm -rf /
rm: cannot remove root directory '/'
rm checks for the explicit string '/' and refuses a recursive removal of it. rm -r '//' or '/*' (expanded by the shell to all of the top-level directories) will still work, but this still prevents screw-ups such as in the shell.
IIRC this is a fairly recent change (c. 2004) of POSIX and it's Sun we need to thank for pushing the change through the standard comities.
Admin
Kudos for bloating a 30 year old one liner into a 800 word snoozefest!
Maybe tomorrow we can get a 50,000 word set up for "to get to the other side".
Admin
Actually bourne shell's simplest error handling mode is "bomb out on error". This is done by setting '-e' ("set -e" or "-e" at the command line of /bin/sh).
This means that basically every command that fails, causes the whole script to exit. The idea is that you don't want to spend too much time thinking about error conditions.
This prevents errors such as that 'cd'.
Admin
I worked for a small business once where the owner blamed me (behind my back) for various screw-ups on projects I wasn't even assigned to (i.e. "I think he messed up the Cornerstone database").
My last month of employment there, he refused to give me work to do, putting me off constantly with "in a minute" and "i'll be there after this phone call" and whatnot. Yes, an entire month. I made myself useful by replacing large swaths of a co-worker's job with some very small shell scripts (for which he thanked me profusely). When I ran out of things to replace with shell scripts, I played most of Half-Life 2.
I decided not to show up to my last day of work. Gee, I wonder why. Former co-workers sent me messages every few months to let me know when the boss was blaming me for yet another thing I couldn't possibly have done...
That same friend (for whom I wrote those shell scripts) quit a month later without notice; the boss had left vital steps out of a series of instructions, then blamed my friend for the Bad Things(tm) that happened as a result, saying something like "you should have just known to do that".
There were a lot of WTFs at that place. I should post about it sometime...
Admin
We should crucify you for telling us that.
Admin
TRWTF is that someone thinks a documented feature is an 'unpatched flaw'. No, the idiot that wrote that code proved his idiocy many times over. SSH is not at fault in the least.
Admin
This is exactly like that show Wordpress did a couple of weeks ago when they released a new version:
rm -rf $TEMP_UPDATE_DIR/*
Guess what happens if $TEMP_UPDATE_DIR is null and you're running the httpd as root? Yeah, that's right. Charlie Foxtrot.
Admin
It does if you have no_root_squash set in your export definition.
Cleaning up as root would make sense if the test suite also runs as root - there are a few (although not many) tasks which would require that.
Admin
... at least my backup script fuckup only managed to fill the remote filesystem and then corrupt it by powering the remote host down while it was still writing to the disk... all my data on the local machine was still present :)
Admin
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz tar xzf asterisk-extra-sounds-en-wav-current.tar.gz play tt-monty-knights.wav
(The tt-* sounds are sound files for the the "telemarketing torture". See extra-sounds-en.txt for the full listing).
Homework: what does this file have in the French version of this sound sets?
Admin
We'll call it QuikProtect. http://www.dilbert.com/strips/comic/1995-09-17/
Admin
By default, NFSv3 (and earlier) map userid X on the client machine to userid X on the server; NFSv4 does the same, but with usernames not ids.
That includes root, unless some option is set to prevent it. On Linux, its set by default (option root_squash), but it can be turned off (no_root_squash) and other Unix variants may not enabled that option by default, or have it at all. Or the sysadmin could have turned it off.
Admin
There's nothing wrong with specifying the shell for the sake of the readers.
Admin
This reminded me of a similar problem, where (on a test machine, thankfully) someone coded a DCL command script that accidentally had an infinite loop in it. It was launched from an account that had the EXQUOTA (ignore all disk quotas) privileges. When we got in Monday AM, the machine had crashed pretty hard, because the logfile from this script used up -every byte- of free space on the system disk drive.
dave (p.s. it wasn't me who coded the script, but it was me who figured out what happened :-)
Admin
I think you just did.
Admin
Agreed. Although I wouldn't knock anyone for doing the mental exercise, just to convince themselves they could...
Admin
Actually I think the real worse than failure is turning such a buggy and complex shittastrifuck of a script loose on a production network. Oh and the ops guys not being bothered to test their backup strategy is just the icing on the cake.
An old boss of mine gave me an excellent bit of advice. "No one give a shit about backups. The do however give a shit about restores."
Admin
Admin
Admin
Admin
Do I know You?
Admin
Ah, the famous "why don't you Google it" comment on a forum! Now somebody already searching Google with "What does SNAFU'd stand for" will end up finding this site, telling them to look on Google. StackOverFlowError...
Admin
Admin
Possibly off-topic - what's the difference between sudo su and sudo -i ?
Admin
Try the other side of your bed tomorrow.
Admin
In my experience, the first to work out what happened is usually the one who (accidentally, no doubt) made the blunder.
Admin
sudo su : executes the 'su' (switch user) command as root. if you use 'sudo su -' this will attempt to start a new shell as root (but you could specify any other user too) sudo -i: opens you a new shell as root
sudo su - is much the same as sudo -i (which is roughly equivalent to sudo sh)
Admin
Oh, there were far more than I posted here... a small part of me wants to curl into a fetal position and cry whenever I think about it. The rest of me wants to start a competing business and do what they do but better, possibly by stealing their clients.
Admin
Admin
the situation sounds familiar... almost the same thing happened at my work, except on a way smaller scale. We put out a new release of our document management system, with one little bug that caused one client's DB to get whipped... The default ID for a document under some circumstances was set to "0" which is also meant “the root”... so, when some one deleted a document with ID "0" it wiped their entire tree structure. Luckily we had a backup...
Admin
I've accidentally run "rm -rf" while in / before. It was on a server. I was root. I realised my mistake about 2 minutes in when I saw a pile of permission denied errors.
Thankfully in my case it was actually a new server that I'd just partially configured... All in all I lost about 1 hours work. But it made me a heck of a lot more careful about running "rm".
Admin
I rm -fred my system once. I was using a livecd to make a backup, and it went wrong, so I did rm -fr . to delete the backup. But I was in the mounted root partition, not the backup location. DOH! Reinstall time.
Admin
That way, it could never have been extended so much that it was no longer obvious that it needed to be told what $var1 and $var2 were, simply because no-one (possibly including the author) would know how to hook the new code in.