I just don't like /etc/passwd

12. November 2011 12:03



I was working on a line printer spooler, which lived in /etc.  I wanted to remove it, and so issued the command "rm /etc/lpspl."  There was only one problem.  Out of habit, I typed "passwd" after "/etc/" and removed the password file.  Oops.


I called up the person who handled backups, and he restored the password file.


A couple of days later, I did it again!  This time, after he restored it, he made a link, /etc/safe_from_tim.


About a week later, I overwrote /etc/passwd, rather than removing it.


After he restored it again, he installed a daemon that kept a copy of /etc/passwd, on another file system, and automatically restored it if it appeared to have been damaged.


Fortunately, I finished my work on /etc/lpspl around this time, so we didn't have to see if I could find a way to wipe out a couple of filesystems...


E-mail Kick it! DZone it! del.icio.us Permalink

Check the home directory

8. November 2011 12:00


A VMS mistake gone bad.



Our operations group, a VMS group but trying to learn UNIX, was assigned account administration. They were cleaning up a few non-used accounts like they do on VMS - backup and purge. When they came across the account "sccs", which had never been accessed, away it went. The "deleteuser" utility fom DEC asks if you would like to delete all the files in the account. Seems reasonable, huh?

Well, the home directory for "sccs" is "/". Enough said :-(


E-mail Kick it! DZone it! del.icio.us Permalink

The non-executable unix shell

6. November 2011 11:56


Here's a pretty bad story.  I wanted to have root use tcsh instead of the Bourne shell.  So I decided to copy tcsh to /usr/local/bin.  I created the file, /etc/shells, and put in /usr/local/bin/tcsh, along with /bin/sh and /bin/csh. 


All seems fine, so I used the chsh command and changed root's shell to /usr/local/bin/tcsh.  So I logged out and tried to log back in.  Only to find out that I couldn't get back in.  Every time I tried to log in, I only got the statement: /usr/local/bin/tcsh: permission denied!


I instantly realized what I had done.  I forgot to check that tcsh has execute privileges and I couldn't get in as root!


After about 30 minutes of getting mad at myself, I finally figured out to just bring the system down to single-user mode, which ONLY uses the /bin/sh, thankfully, and edited the password file back to /bin/sh.


I'll never do that again ....


E-mail Kick it! DZone it! del.icio.us Permalink

C# - Locking Example

5. November 2011 11:12


In this example we are going to use ThreadSimple to run a background which will happy process "something" until the input arrives. When input arrives in the console application we will aquire the lock which will block the background thread from running. The main idea here is to help give an visual understanding on what a lock between threads is actually doing in an application.


First off lets create a background thread. The only work it is performing is to print a counter to the screen and sleep for 100ms between runs. This uses the ThreadSimple class so you may need to read that post first.



class BackGround : ThreadSimple
	protected override void Run(object obj)
		int Counter = 0;

		while (true)
			lock (this)
				Console.WriteLine("Running ... {0}", Counter);



For the foreground thread which is where we are reciving end user input and we are using that to control the execution of the program. The idea here is to wait until return is pressed. Print something out then wait for 5 seconds until the lock is released and then the background thread continues to process what it was doing. Or in short it will present a message to an end user which would be visible for 5 seconds then continue what it was doing.



static void Main(string[] args)
	BackGround tmp = new BackGround();


	lock (tmp)
		Console.WriteLine("Locking ...");




When you run the application you should get the following output. With a 5 second delay after "Locking ...."



Running ... 0
Running ... 1
Running ... 2
Running ... 3
Running ... 4
Running ... 5
Running ... 6
Running ... 7
Running ... 8
Locking ...
Running ... 9
Running ... 10
Running ... 11
Running ... 12
Running ... 13
Running ... 14
Running ... 15
E-mail Kick it! DZone it! del.icio.us Permalink