Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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)?

share|improve this question

3 Answers

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 is run via su -- and does the trick. It seems to be a user-setting, although SystemPrefs would ask for a admin password to tweak this setting...

#!/bin/sh

if [ -z "$HOME" ]; then
 echo "$0: HOME not set, cannot disable 802.1x thing. QUIT."
 exit 1
fi

if [ `whoami` = "root" ]; then
  echo "$0: Must run as regular user, not root! QUIT."
  exit 1
fi

# get host uuid
HOSTUUID=`/usr/sbin/ioreg -rd1 -c IOPlatformExpertDevice | grep -E '(UUID)' | cut -d\" -f4`
# define path to eapol prefs
PREFFILE="$HOME/Library/Preferences/ByHost/com.apple.network.eapolcontrol.$HOSTUUID.plist"

# write new setting 
defaults write $PREFFILE EthernetAutoConnect -bool false

Using opensnoop(1) or fs_usage(1) I could not see any other files being modified. Hope it helps.

share|improve this answer

Just disable the Enable automatic connection tickbox in the 802.1x tab of your advanced interface option as it is the equivalent of the terminal command.

share|improve this answer

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 ;-)

Cheers, Michele

share|improve this answer
Does this work, the first clause confuses me, also what do you pass in as a parameter to the script? – Mark Apr 9 at 11:38
The parameter $1 ist the username, which is automatically passed to this script by the LoginHook. – Michele Marcionelli Apr 9 at 11:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.