10.4: Disable IR port on new Macs via a startup script

Mar 27, '06 05:28:00AM

Contributed by: hagus

Tiger only hintHaving searched high and low for a way to disable the Infrared Port on new Macs, I decided to go ahead and write my own Preference Pane to do so. No sooner had I finished writing it and telling everyone about it, someone pointed out that -- well -- this feature already existed in the Security section of System Preferences. Oops.

However, the general technique is still a useful hint to consider. We simply unload the appropriate kernel driver. In some cases, this might be the only way you can disable a particular device (e.g. the keyboard) or a useful way of disabling a device so a non-Unix savvy user would have trouble re-enabling it.

Let's look at the IR controller as an example. All we need to do is unload the AppleIRController kernel extension, and make sure it stays unloaded. Directly on the command line, this can be done like so:

kextunload /System/Library/Extensions/AppleIRController.kext
Now we just want to persist this across reboots. We can do this with a simple StartupItems script. Finally, we control whether this StartupItems script actually takes any action by adding the following line to /etc/hostconfig. This also provides an easy way of toggling the change on and off:
DISABLEIR=-YES-
To trigger the StartupItems script without needing to reboot, you can just use the SystemStarter tool:
sudo SystemStarter start DisableIR
Of course it's worth being very careful when it comes to messing with kernel drivers. You might disable some critical part of the system that requires you to force reboot, or you might kernel panic your machine. Tread with caution.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2006032102235522