Posted on
02-25-2022
07:06 AM
- last edited on
05-15-2023
10:56 AM
by
CalleyO
Script works properly when launched from terminal, but fails after being executed as a policy. Self Service tries to open, then crashes. App version is 10.35.0, the OS it gets executed from is 10.14.6, fully patched.
The same script fails on a manually upgraded Catalina as well. (Did it for testing purposes, just to see what happens; system is already running 10.15.7).
Posted on 02-25-2022 08:17 AM
Maybe try this...
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
uid=$(id -u "$currentUser")
Then run your
policyID=set your policy ID
policyAction=set your policy action
policy="jamfselfservice://content?entity=policy&id=$policyID&action=$policyAction"
launchctl asuser $uid sudo -iu $currentUser open $policy
Posted on 02-26-2022 10:37 AM
Original script was ran with elevated privileges.
Posted on 03-01-2022 09:17 AM
Process: Self Service [6093]
Path: /Applications/Self Service.app/Contents/MacOS/Self Service
Identifier: com.jamfsoftware.selfservice.mac
Version: 10.35.0 (10.35.0-t1640197529)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Self Service [6093]
User ID: 1017136713
Date/Time: 2022-03-01 12:07:35.104 -0500
OS Version: Mac OS X 10.14.6 (18G103)
Report Version: 12
Anonymous UUID: F4591EB4-C5E6-A4DB-AFAD-3CB1B511C5E2
Sleep/Wake UUID: 5E3186F7-71FE-402D-8B3A-62E279644990
Time Awake Since Boot: 4900 seconds
Time Since Wake: 370 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff63df22c6 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff63eadbf1 pthread_kill + 284
2 libsystem_c.dylib 0x00007fff63d5c6a6 abort + 127
3 org.cocoapods.Sentry 0x000000010403b19b -[SentryCrashExceptionApplication _crashOnException:] + 58
4 com.apple.AppKit 0x00007fff3575c748 -[NSApplication reportException:] + 916
5 org.cocoapods.Sentry 0x000000010403b134 -[SentryCrashExceptionApplication reportException:] + 371
6 com.apple.AppKit 0x00007fff3535234c -[NSApplication finishLaunching] + 3110
7 com.apple.AppKit 0x00007fff353513c7 -[NSApplication run] + 250
8 com.apple.AppKit 0x00007fff35340ac8 NSApplicationMain + 777
9 com.jamfsoftware.selfservice.mac 0x00000001038a4ea9 0x10389f000 + 24233
10 libdyld.dylib 0x00007fff63cb73d5 start + 1
Thread 1:
0 libsystem_pthread.dylib 0x00007fff63eaa3f0 start_wqthread + 0
Thread 2:
0 libsystem_pthread.dylib 0x00007fff63eaa3f0 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x00007fff63eaa3f0 start_wqthread + 0
Thread 4:
0 libsystem_pthread.dylib 0x00007fff63eaa3f0 start_wqthread + 0
Thread 5:
0 libsystem_pthread.dylib 0x00007fff63eaa3f0 start_wqthread + 0
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00000001108da5c0 rcx: 0x00007ffeec3604f8 rdx: 0x0000000000000000
rdi: 0x0000000000000307 rsi: 0x0000000000000006 rbp: 0x00007ffeec360530 rsp: 0x00007ffeec3604f8
r8: 0x0000000000000010 r9: 0x000000000000031c r10: 0x0000000000000000 r11: 0x0000000000000206
r12: 0x0000000000000307 r13: 0x000000010406fd86 r14: 0x0000000000000006 r15: 0x000000000000002d
rip: 0x00007fff63df22c6 rfl: 0x0000000000000206 cr2: 0x00007fff9a546188
Logical CPU: 0
Error Code: 0x02000148
Trap Number: 133
Posted on 09-24-2022 09:32 PM
@Hermenegildah Did you ever find a solution for this? I am seeing the same problem with Self Service 10.40.1 on macOS 12.5.1 where it crashes due to a SIGABRT when called from a script triggered by a LaunchDaemon. Running the same script from Terminal via sudo does successfully launch Self Service. And the script _should_ be doing all the needed things to open Self Service in the user context:
/bin/launchctl asuser "$currentUserID" sudo -u "$currentUser" /usr/bin/open "jamfselfservice://..."
Posted on 03-02-2022 07:11 AM
I notice your messageText="Your computer is currently running......
is missing the " at the end of ......in ${timeout} seconds.
I removed all the logging part and focus on the main script itself.
Self Service wouldn't launch with your if statement, but worked when I replaced your
sudo -u $loggedInUser /usr/bin/open jamfselfservice://content?entity=policy&id=1609&action=view
with mine
launchctl asuser $uid sudo -iu $currentUser open jamfselfservice://content?entity=policy&id=1609&action=view
Posted on 03-02-2022 10:47 AM
I have made appropriate chances, but the policy fails now.
Script result: /Library/Application Support/JAMF/tmp/AG - Notification - macOS Catalina Upgrade:95: unmatched "
Error running script: return code was 1.
Posted on 03-02-2022 10:53 AM
Posted on 03-02-2022 11:22 AM
I'd suggest find a script that work here and customize it. Here is a stripped down version. I just use Monterey as example.
#!/bin/zsh
# current logged in user
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
uid=$(id -u "$currentUser")
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
title="Notification"
heading="macOS Monterey Upgrade"
icon=/Applications/Install\ macOS\ Monterey.app/Contents/Resources/InstallAssistant.icns
windowType="utility"
button1="Upgrade OS"
button2="Postpone"
timeout=300 # activate default button after timeout, remove default button if you don't want to run the script after the timeout
message="Your computer is currently running an older and unsupported version of macOS.
Please start the upgrade process at your earliest convenience.
To start it now please select Upgrade OS from the options below.
Click '${button2}' to view the installer in Self Service.
Click '${button1}' to initialize the upgrade now.
This notification will time out in ${timeout} seconds."
# Policy ID and Action
policyID="1609"
policyAction="view" # view or execute
policy="jamfselfservice://content?entity=policy&id=$policyID&action=$policyAction"
#jamfHelper window
userChoice=$("$jamfHelper" \
-windowType "$windowType" \
-title "$title" \
-heading "$heading" \
-description "$message" \
-timeout "$timeout" \
-button1 "$button1" \
-button2 "$button2" \
-icon "$icon" \
-iconSize 200)
# Button 1 to view policy in Self Service
if [ "$userChoice" = 0 ]; then
launchctl asuser $uid sudo -iu $currentUser open $policy
else
# Button 2 do whatever you want
launchctl asuser $uid sudo -iu $currentUser open /Applications/Install\ macOS\ Monterey.app/
fi
exit 0