OS X plist files

(imported topic written by SystemAdmin)

Trying to modify some .plist files on a Mac 10.7 Lion. UGH - if anyone thinks Windows is hard to manage, think again. Anyhow, can anyone share any code to modify things like the global preferences.plist file? We are trying to add a proxy config to both the wifi and ethernet adapters section of the .plist file. I can’t wrap my head around the logic and the relevance debugger on the mac isn’t as, umm, robust as the windows version.

Parse the file to find / change the Airport and / or Ethernet adapter

Find the Interface keys where Hardware key exists and where the Hardware string value is set to AirPort or Ethernet

See if the Proxies section exists

See if the key ProxyAutoConfigEnable exists

See if the integer value is set to 1

See if the key ProxyAutoConfigURLString exists

See if the string value is set to the url of the proxy.pac file

XML snippet

2D90067E-4105-4ABC-8F32-CBF8B2889D72

DNS

IPv4

ConfigMethod

DHCP

IPv6

ConfigMethod

Automatic

color=blue

Interface[/color]

DeviceName

en1

color=blue

Hardware

AirPort[/color]

Type

Ethernet

UserDefinedName

string>Wi-Fi

color=blue

Proxies[/color]

ExceptionsList

*.local

169.254/16

FTPPassive

1

color=blue

ProxyAutoConfigEnable

1

ProxyAutoConfigURLString

http://webproxyserver/proxy.pac[/color]

SMB

UserDefinedName

Wi-Fi

John

(imported comment written by NoahSalzman)

Why not avoid plist editing and use the

networksetup

command. From the man page:

-setproxyautodiscovery on | off

Set Proxy Auto Discover for to either or .

-setautoproxyurl url

Set proxy auto-config to url for and enable it.

(imported comment written by SystemAdmin)

Noah - well now, that would be the smart way of doing it. As you can tell, we don’t have much knowledge on os x. So Thank you!

Using your method, how would you write relevance to tell if the setting already exists?

John

(imported comment written by NoahSalzman)

Well… you have to do the BigFix “unix two-step”: write out the results from the utility to a temp file (in one Fixlet) and then read them in with relevance (in a second).

Here is what my Mac looks like:

roquefort:~ noah$ networksetup -getproxyautodiscovery Wi-Fi

Auto Proxy Discovery: Off

roquefort:~ noah$ networksetup -getautoproxyurl Wi-Fi

URL: (null)

Enabled: No

So, if you had an action write that out:

waithidden /bin/sh -c “networksetup -getproxyautodiscovery Wi-Fi > /tmp/proxyautodiscovery_state”

Here is one way to test for that condition:

Q: (following text of last ": " of line whose (it contains “Auto Proxy Discovery”) of file “/tmp/proxyautodiscovery_state”) is “Off”

A: True