Disable Automatic Login

msample
Contributor II

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?

b9edd35f08c84cbcba3ed5b3bc9faca3

<?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 "&lt;result&gt;Pass ($result)&lt;/result&gt;"
else
echo "&lt;result&gt;Fail ($result)&lt;/result&gt;"
fi </scriptContentsMac>
</extensionAttribute>

3 REPLIES 3

mm2270
Legendary Contributor III

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.

stevevalle
Contributor III

@msample - The following script will disable the Automatic Login:

defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser

Tested on 10.10.4 :)

msample
Contributor II

@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!