OS X Patch for LANL AirPort Rules
LANL has had a policy of disallowing wireless networking. This is fine, I
just had my LANL network location set to disable my built-in AirPort card.
But, as a consequence of typical LANL overreaction, LANL has installed
wireless monitoring equipment, so that even the few seconds between
waking my laptop and switching to the LANL location may produce an alarm.
Security may be an important thing to other people at LANL, but to me
this is a stupid annoyance.
Since I am incapable of remembering to switch the location before I actually
come to LANL, I have set up a kludgey system to set the LANL location
automatically when I put my laptop to sleep at home. This is not
extensively testing, and since these instructions involve commands as root,
you should back up your data before you hose your data.
This is what to do:
- Set up appropriate locations under “Network” in
Network preferences. The locations can be anything but one
called “LANL” is required, which contains your
LANL configuration and has AirPort powered down.
- Activate UI scripting. This is included in 10.3, and is available
as a beta addition in 10.2. In 10.3, in System Preferences,
select “Universal Access” and then check the box that
says “Enable access for assistive devices.”
- Download this AppleScript (switchtolanl,
plain Unix text) and put it in /usr/local/bin (you need to
do this as root). Running this script
(“osascript /usr/local/bin/switchtolanl”) will
switch the network location setting to “LANL”.
- Download this executable (lanlonsleep,
or get source)
and put it in /usr/local/bin (again
as root). This code is a modification of Apple's pm_callback
demo code that will receive a message before the computer goes to sleep
and calls the above script.
- Now make the executable start up automatically.
Download this tgz archive
(LANLonSleep.startup.tgz), unpack
and put the contents in /System/Library/StartupItems. (From
the command line, again as root, do
“curl -O http://george.ph.utexas.edu/~dsteck/code/LANLonSleep.startup.tgz
&& tar xvzf LANLonSleep.startup.tgz -C /System/Library/StartupItems”.)
Then start by saying
“/System/Library/StartupItems/LANLonSleep/LANLonSleep start”
or by rebooting.
- Finally, make the switch also when you shut down
(actually, log back in after shutting down).
Download this application (switchtolanl.app,
the same AppleScript but saved as an application) and put it somewhere
like /usr/local/bin. Then add this to your Startup Items under
Accounts in System Preferences. This is not exactly the desired behavior,
since the AirPort card may be powered on for a short time until this
point in login. It is better to only put your computer to sleep and
reboot when necessary.
- Test, test, and retest.