Wednesday, January 28, 2009

Old School Keyboard Control and HTML Character Entities On Linux And Unix

Hey There,

I think the sickness is finally leaving my body (I'm referring to the virus, or whatever I have, and not the mental condition that I fear I'm going to be stuck with until they tag my toe ;), so, in between bouts of feeling like I'm not getting better, I'm cranking out this disjointed post. It's going to be a 2 point post, but there's absolutely no natural flow between the first and second topics. Basically, it goes against everything I was taught in school, but I'll be damned if "the man" is gonna keep me down any longer ;)

1. Stopping people from rebooting your Linux box with control-alt-delete and giving them something to think about.

This is pretty old-school (and, probably, old-hat) but I've never written about it before. Basically, what we want to do in this part of today's post is prevent folks with physical access to our Linux machines from rebooting them by hitting the control-alt-delete keys. Most people just disable this behaviour in /etc/inittab and use echo to issue a stern warning. I like to take it a bit too far ;)

a. Find the line in /etc/inittab that handles control-alt-delete functionality. It probably looks something like this:

ca::ctrlaltdel:/sbin/shutdown -r -t 4 now

Basically, we only need to worry about the last section (with sections being delimited by colons) that states the machine should execute "/sbin/shutdown -r -t 4 now" whenever someone presses the control-alt-delete key combination (ctrlaltdel in the file).

b. Now, edit this line so that no one can reboot the box using this key combo. Generally, this is how it's done:

ca::ctrlaltdel:/bin/echo "Control-Alt-Delete Key Combination Has Been Disabled"

and then run:

init q

or

init Q

to cause init to reread the /etc/inittab. This works very well, and is recommended for machines that need to meet certain availability requirements. If this is your personal machine, or a machine your group works on that isn't "important," try this change instead (followed by "init q" or "init Q")

ca::ctrlaltdel:/bin/crashland

And then make a little executable file that you can create by grabbing the worst errors out of your /var/log/messages log, or any other file, and adding a zinger at the end :)

host # chmod 755 /bin/crashland
host # cat /bin/crashland

#!/bin/sh

/bin/echo `date "+%b %d %H:%M:%S"` `hostname` kernel: rpcd[26560]: segfault at 00000000bafa1b44 rip 00000000555c3be9 rsp 0000000056e3ea90 error 4
/bin/echo `date "+%b %d %H:%M:%S"` `hostname` kernel: vcagentd[4968]: segfault at 0000000000000001 rip 000000005558d5d2 rsp 0000000056818858 error 4
/bin/echo `date "+%b %d %H:%M:%S"` `hostname` kernel: rpcd[16785]: segfault at 00000000bafa2b44 rip 00000000555c4be9 rsp 0000000056c3fa90 error 4
/bin/echo "This message has been repeated 537 times"
/bin/echo "Unrecoverable disk error on root disk. This partition may require"
/bin/echo "Emergency maintenance - please gracefully reboot if possible! - ctrl-alt-delete on your keyboard"


Oh, the fun ;)

2. Here's a little something goofy dealing with HTML character entities in general. It's a little exercise I started and then decided not to finish since it has no end that a human can reach without growing substantially older, slower and more bitter ;)

Enjoy the descent into meta-meta-meta-... Hell...



Testing Character Entities




printing < in HTML is actually typing &lt;


printing &lt; in HTML is actually typing &amp;lt;


printing &amp;lt; in HTML is actually typing &amp;amp;lt;


printing &amp;amp;lt; in HTML is actually typing &amp;amp;amp;lt;


printing &amp;amp;amp;lt; is becoming a much more apparent, never-ending, pain in the arse...




Hope everyone out there is staying healthy or, at least, not being sick ;)

Cheers,

, Mike




Discover the Free Ebook that shows you how to make 100% commissions on ClickBank!



Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Excellent Web Hosting At An Affordable Price!
www.authorswebhosting.com
These Are The Guys I Use To Host My Online Presence!