Posted on 07-21-2015 12:04 PM
I've attached a snapshot of a "script exit code 2" from my logs. Just weeding out the bugs with this one, but I'm not certain that this particular script works best. Possible suggestions?
<?xml version="1.0" encoding="UTF-8"?>
<extensionAttribute>
<displayName>OS - Disable Automatic Login</displayName>
<displayInCategory>Security Reporting</displayInCategory>
<dataType>string</dataType>
<description>This attribute verifies that automatic login is disabled. The value to be verified will need to be specified when creating this extension attribute. Example: "true" verifies that automatic login is disabled. This extension attribute requires this preference be set using Managed Preferences (MCX).</description>
<scriptContentsMac>#!/bin/sh
desiredValue="EditFromTemplate_Desired_Value_-_Example:_true"
appDomain="com.apple.loginwindow"
keyName="com.apple.login.mcx.DisableAutoLoginClient"
result=""
tmpResult="dscl . mcxread /Computers/localhost "$appDomain" "$keyName" |grep Value:| sed 's/Value: //g'
"
if [ "$tmpResult" == "1" ]; then
result="true"
else
if [ "$tmpResult" == "0" ]; then
result="false"
else
if [ "$tmpResult" == "" ]; then
result="Domain or Key Not Found"
else
result="$tmpResult"
fi
fi
fi
if [ "$result" == "$desiredValue" ]; then
echo "<result>Pass ($result)</result>"
else
echo "<result>Fail ($result)</result>"
fi
</scriptContentsMac>
</extensionAttribute>
Posted on 07-21-2015 12:15 PM
I'm a bit confused. It looks like you're attempting to use an Extension Attribute script in a policy. If so, that's the issue. Extension Attribute scripts are designed for the purpose of inventory only (usually) All that EA script does is verify a value is set on the Mac and then echoes back a result, which is intended to be plugged into a field in the computer record in the db. It does not attempt to change anything on the Mac.
Also, the format of the script appears as it would in the xml format the JSS uses and not as an actual bash script, so that compounds the issue further and is the cause for the exit 2 error.
Posted on 07-22-2015 05:52 PM
@msample - The following script will disable the Automatic Login:
defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser
Tested on 10.10.4 :)
Posted on 07-22-2015 09:20 PM
@stevevalle Fantastic, Steve. Dropped it into place for testing this evening. I'll check the results after a couple of staged systems have been imaged. Thanks!