Once had a friend who fancied himself a sysadmin. We wrote a script to back up an Oracle database. He put this script in /bin. It was designed to back up the contents of the databases to some folder. It used another temp directory for intermediate files. It was located somewhere odd, like /opt/foo.
The first line of his script was:
cd /opt/foo
The next line was:
rm -rf *
We can see where this is going.
One day, someone doesn't know what this /opt/foo directory is for, and deletes it. The script runs. It tries to cd to a non-existent directory. It doesn't check the return code from the cd. It then executes rm on everything in the current directory, which is...
/bin
It is so much fun to try to restore a system without ls.
I have been there. I have done that. It was not fun, for very large values of NOT, even after I'd aliased "ls" to "echo *". I am casting pointy metal objects in the general direction of your ducking and running person.
Actually, it occurs to me that the scenario could have been worse. If the working directory was /bin when the rm command failed, you just lost /bin, and the tools for restoration are generally in /sbin. If the script was running as root on a non-Linux system, however, and had simply been running in the default directory for a cron job, i.e. the owner's home directory, i.e. /...
no subject
ln -s /usr/bin/vi /usr/bin/emacs
HTH. HAND.
no subject
no subject
Once had a friend who fancied himself a sysadmin. We wrote a script to back up an Oracle database. He put this script in
/bin
. It was designed to back up the contents of the databases to some folder. It used another temp directory for intermediate files. It was located somewhere odd, like/opt/foo
.The first line of his script was:
The next line was:
We can see where this is going.
One day, someone doesn't know what this
/opt/foo
directory is for, and deletes it. The script runs. It tries tocd
to a non-existent directory. It doesn't check the return code from thecd
. It then executesrm
on everything in the current directory, which is...It is so much fun to try to restore a system without
ls
.no subject
*duck and run*
no subject
no subject
I've done it too. I've also debugged boot code with nothing more
than ghetto printf, and other related adventures.
no subject
no subject