The SMJobBlessUtil.py
script (which Apple provides for setting/checking the pairing between a privileged helper tool and its main app) does not work on M1 Macs.
$ ./SMJobBlessUtil.py check MyApp.app
/Users/Alex/MyApp.app/Contents/Library/LaunchServices/ca.momchilov.MyApp.helper: tool __TEXT / __info_plist section dump malformed (2)
I have filed a bug report under rdar://FB9726189
, which you can see here on Open Radar: https://openradar.appspot.com/radar?id=5006748255518720
I debugged this by putting in some calls to
traceback.print_exc()
throughout the script, because its default behaviour doesn't print stack traces.How it should work
The problem stems from the
readPlistFromToolSection
funciton, which usesotool
to read some sections out of the helper tool's executable (which is Mach-O file, which is broken into many sections. Some of those section are embedded plist files).It invokes:
(it also invokes a similar variant for
__launchd_plist
)Running this tool on an tool compiled for x86 (either natively, or via Rosetta) gives a result like:
The
SMJobBlessUtil.py
script then processes this down into a XML plist file by:\t
of each line)bytearray
, that's then parsed byplistlib.readPlistFromString
The issue
When you run the same
otool
command on a native ARM64 compiled binary, the issue becomes obvious:The bytes are clumped into groups of 4, and each group is reversed. I.e. instead of the expected format:
You get:
The solution
There are two main solutions I can think of for this:
SMJobBless.py
on that result. If thecheck
command passes for that, I think it's pretty reasonable to assume it would pass for a native ARM binary, too.