Not able to open a process (Cocoa application) from Authorization Plugin

I am trying to open a cocoa GUI application from authorization plugin which runs during login. I have placed the application in /Library/Application Support/MyFolder/Example.app. I am using below environment and code to open the application.



Environment:

OSX: 10.14.5 (Mojave)

Xcode: 11.2.1

Swift: 4.2


Code:

let task = Process.init()
task.launchPath = "/Library/Application Support/MyFolder/Example.app/Contents/MacOS/Example"
task.arguments = ["Hi", "Hello"]   
task.launch()
task.waitUntilExit()


While the above code works perfectly fine when trying to open process from normal cocoa application it doesn't when I am trying the same from a bundle project which is used as an authorization plugin (https://developer.apple.com/documentation/security/authorization_plug-ins/using_authorization_plug-ins)


Crash Report:

Process: Example [2236]

Path: /Library/Application Support/MyFolder/Example.app/Contents/MacOS/Example

Identifier: com.MyFolder.mfa1.Example

Version: 1.0 (1)

Code Type: X86-64 (Native)

Parent Process: SecurityAgent [2223]

Responsible: Example [2236]

User ID: 92



Date/Time: 2020-03-23 01:23:26.652 +0530

OS Version: Mac OS X 10.14.5 (18F132)

Report Version: 12

Bridge OS Version: 3.5 (16P5125)

Anonymous UUID: 42E41D19-877E-2567-CBFA-B03BAF4D4DE8





Time Awake Since Boot: 8800 seconds



System Integrity Protection: enabled



Crashed Thread: 1 Dispatch queue: com.apple.root.default-qos



Exception Type: EXC_BAD_INSTRUCTION (SIGILL)

Exception Codes: 0x0000000000000001, 0x0000000000000000

Exception Note: EXC_CORPSE_NOTIFY



Termination Signal: Illegal instruction: 4

Termination Reason: Namespace SIGNAL, Code 0x4

Terminating Process: exc handler [2236]



Application Specific Information:

XPC API Misuse: Attempt to look up cross UID boundaries by unprivileged process.



Application Specific Signatures:

API Misuse



For full crash report look at the https://pastebin.com/ZtRrpMFe

Replies

I am trying to open a cocoa GUI application from authorization plugin which runs during login.

There’s no supported way to do this. Authorisation plug-ins are intended to be small, self-contained units of code. Launching an app from your plug-in would be a horrendously bad idea, so I’m kinda glad the system is stopping you from doing it (-:

What are you trying to achieve here?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Creating a cocoa app is straight forward when compared to creating an authorization plugin and so I tried to open a Cocoa application from authorization plugin and establish inter-process communication between them and let the cocoa application tell the authorization plugin if to log the user in or not.

Yeah, sorry, that’s just not going to work.

One thing you can do here is create a test app to host your auth plug-in’s view controller. That allows you develop your UI, and all the stuff underlying that, in a nice environment. However, when it comes to deploy, all of this code has to run within your auth plug-in.

Also, please drop me a line via email (my address is in my signature). Make sure to reference this thread because I get a lot of email (-:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"