Jamfhelper not running properly

bruth85
New Contributor III

We have our jamfhelper.sh set to run at enrollment to prompt to enter the new computer name. That part of the script has stopped working recently. We are not getting the popup anymore to enter the name but the part of the script after the sleep to show the please wait message is working fine. The ones we have seen the issue on are 10.13.x systems.

What is odd is if we just test the script using something like code runner the box pops up and everything works just fine but when it tries during enrollment its no dice, also if i test it in the built in script editor it wont work either.

The script is set to run Before as well.

Here is our script:

!/bin/sh

assignment=$(/usr/bin/osascript<<END
tell application "System Events"
activate
set the answer to text returned of (display dialog "Enter the name of this device Ex. CHOSXxxxxLPT1" default answer "" buttons {"Continue"})
end tell
END)

scutil --set HostName "$assignment"
scutil --set LocalHostName "$assignment"
scutil --set ComputerName "$assignment"

sleep 3
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -title "Imaging in progress." -heading "Please wait until the machine reboots." -description "Imaging in progress." -icon /System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns &

exit 0

2 REPLIES 2

mm2270
Legendary Contributor III

If I had to take a guess, I'd say it stopped working because of the AppleScript call in it. I'm not sure when that was working for you before, but it's not just a High Sierra thing. Generally speaking, those types of osascript calls for user input need to be run as the user, which Jamf policies don't usually do. They often run as root, and the OS tends to stop that from running and requesting user input. It's a security thing that Apple has been doing for a while now.

The reason it works if you call the script yourself is because you're not running it as root.

You'll probably have to use some well known tricks to get the osascript part to run as the user and capture the input. Search here for references to launchctl asuser, which I find the most reliable, or the less reliable sudo -u $username type of calls. One of those should work and present the dialog properly.

bruth85
New Contributor III

@mm2270 Thanks! I will take a look. It worked just fine on our El Capitan systems we got originally and the script was written by the Jamf rep who was with us for our Jump Start.