So in the spirit of this question I was wondering if it is possible to disable automatic 802.1X connection via terminal as well. Am I right to assume that this is a computer setting (meaning that if I run this script with no user logged in it still disables it for all existing and future users)?
It took me some hours to learn that it's a boolean value (and not just 0 or 1 as 'defaults' would report) but finally i came up with the following LoginHook which does the trick. As LoginHooks get executed as root user, you have to 'su' to the user currently being logged in before running the script below. As Michele points out below, that username is available as $1 to the Hook-Script running as root. It seems to be a user byHost-Setting, although SystemPrefs would ask for a admin password to tweak this setting... My hook script being executed in user-context looks like this:
#!/bin/sh if [ `whoami` = "root" ]; then echo "$0: Must run as regular user, not root! QUIT." exit 1 fi # write new setting defaults write -currentHost com.apple.network.eapolcontrol EthernetAutoConnect -bool false
Using opensnoop(1) or fs_usage(1) I could not see any other files being modified. Hope it helps.
This is what we implemented at work. It runs as a login script for each user that logs into the computer. Since OS X 10.9, the location has changed and the file name is different for each user. The script looks for the unique file for that user and changes the auto connect value.
#!/bin/bash ### Variables user=`/usr/bin/logname` x=$(find ~/Library/Preferences/ByHost -name "com.apple.network.eapolcontrol*.plist") ### Functions defaults write $x EthernetAutoConnect -bool false
I don't know how this solution can work, since a LoginHook is executed as
root and not as the user itself.
Here my solution:
#! /bin/sh su - $1 -c "defaults -currentHost write com.apple.network.eapolcontrol EthernetAutoConnect -bool false";
Note that the option
-currentHost will do the stuff with the host uuid ;-)