Guard My DVD Drive against Destruction!

My kid likes to press the 'Eject' button of my DVD drive (or, to be precise, my *previous* drive) to open and close the drive's door. Recently he learned from observing how to put VCDs into the drives and watch them on my Ubuntu-powered computer! However, he still did not know how to use it properly, and I suspected that he had accidentally put some CD attached with some dirty sticky things and that spoiled my DVD drive! The drive was still usable, but whenever you wanted to eject the CD inside, the tray did not eject properly, and somehow almost all CDs put inside will be badly scratched when you eject them and rendered them unusable!

Luckily I found the problem early and only 3 CDs became victims. The DVD drive was already 3-year-old if I am not mistaken and suffered from some minor problems. So I decided to spend RM85 to buy a new one. Oh wait! I also need some program to lock the door of the drive to prevent similar tragedy! I tried to google some good Linux software for this but failed to find one. No choice, I finally delved into the Linux kernel's ioctl() for CD/DVD drives and wrote my own program to do the job. I did it and here it is. It's GPLv3-ed so get it if you need.

To lock the computer when it boots up, I add the following line in /etc/rc.local:

/usr/local/bin/cdlock

Of course, this loose safety control is not tight. If my kid discovers that

  • he can perform a "zero-day attack" which lasts for about half a minute before the execution of cdlock during boot up, or
  • he can simply issue cdunlock to unlock the door, (Update: The Unix's file ownership and permission can be used to protect against this. In Ubuntu, a CD drive's device file (under /dev/) has ownership root:cdrom and 660 permission. A user can use cdlock/cdunlock on a drive if and only if he is a cdrom group member.)

then the magic is gone. But when he discovers the loopholes someday, I think he should be smart enough to use the drives properly then.

Comments

Great article. Well written

Great article. Well written and very useful. Thanks alot!