MacBook Firmware Password After Using Setregproptool – How to Find

command linefirmwarepasswordscript

In attempting to automate setting up firmware passwords through DeployStudio, I accidentally wrote a bad script loosely based off Dash's post Setting a firmware password that did not work as intended.

#!/bin/sh    
diskutil mount Recovery\ HD & wait
hdiutil attach -quiet -nobrowse /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg & wait
OLDPASSWORD= ""
CONFIRMPASSWORD= "password"
/Volumes/OS\ X\ Base\ System/Applications/Utilities/Firmware\ Password\ Utility.app/Contents/Resources/setregproptool -m command -p $CONFIRMPASSWORD -o $OLDPASSWORD
diskutil unmount force Recovery\ HD & wait
echo "New Firmware Password is Set"

If you can tell already, when setting the variables for OLDPASSWORD and CONFIRMPASSWORD, I should not have added that extra space because I got "command not found" errors.

However, I ran the script through DeployStudio (Postponed execution not checked) and a password WAS set. I just don't know what it is. I tried "password" and empty password. Does anyone have an idea what it could be? The only this else I could do is send the macbook to Apple Repair.

Best Answer

Since OLDPASSWORD and CONFIRMPASSWORD are both unset, the command your script executed was:

/Volumes/OS\ X\ Base\ System/Applications/Utilities/Firmware\ Password\ Utility.app/Contents/Resources/setregproptool -m command -p -o

I don't know for certain (and I'm not about to test it), but I'd expect that this has taken "-o" as an argument to the "-p" option, and hence set the firmware password to "-o".

BTW, in addition to removing the spaces after the "=" in assignments, you should also double-quote all references to variables, like this:

/Volumes/OS\ X\ Base\ System/Applications/Utilities/Firmware\ Password\ Utility.app/Contents/Resources/setregproptool -m command -p "$CONFIRMPASSWORD" -o "$OLDPASSWORD"

This will prevent the shell from doing weird things with variables that contain spaces and/or wildcards, or are blank (like OLDPASSWORD in your script).