问题
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 authorization plugin
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
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff7e0e622a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff7e0e676c mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff52065bee __CFRunLoopServiceMachPort + 328
3 com.apple.CoreFoundation 0x00007fff5206515c __CFRunLoopRun + 1612
4 com.apple.CoreFoundation 0x00007fff520648be CFRunLoopRunSpecific + 455
5 com.apple.ViewBridge 0x00007fff79b126c1 __invokeRunLoopInModeForDuration_block_invoke_2 + 25
6 com.apple.ViewBridge 0x00007fff79b1261b invokeRunLoopInModeForDuration + 504
7 com.apple.ViewBridge 0x00007fff79b123f1 __29-[NSCFRunLoopSemaphore wait:]_block_invoke_2 + 127
8 com.apple.ViewBridge 0x00007fff79b12318 __29-[NSCFRunLoopSemaphore wait:]_block_invoke + 308
9 com.apple.ViewBridge 0x00007fff79b11ee2 +[NSCFRunLoopSemaphore _observe:whilePerforming:] + 606
10 com.apple.ViewBridge 0x00007fff79b119fd -[NSCFRunLoopSemaphore wait:] + 437
11 com.apple.ViewBridge 0x00007fff79b110d1 -[NSCFRunLoopSemaphore wait] + 38
12 com.apple.ViewBridge 0x00007fff79b0ffc4 _ensureAuxServiceAwareOfHostApp + 683
13 libdispatch.dylib 0x00007fff7df635f8 _dispatch_call_block_and_release + 12
14 libdispatch.dylib 0x00007fff7df6463d _dispatch_client_callout + 8
15 libdispatch.dylib 0x00007fff7df6f68d _dispatch_main_queue_callback_4CF + 1135
16 com.apple.CoreFoundation 0x00007fff52065cd7 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
17 com.apple.CoreFoundation 0x00007fff52065401 __CFRunLoopRun + 2289
18 com.apple.CoreFoundation 0x00007fff520648be CFRunLoopRunSpecific + 455
19 com.apple.HIToolbox 0x00007fff5135096b RunCurrentEventLoopInMode + 292
20 com.apple.HIToolbox 0x00007fff513506a5 ReceiveNextEventCommon + 603
21 com.apple.HIToolbox 0x00007fff51350436 _BlockUntilNextEventMatchingListInModeWithFilter + 64
22 com.apple.AppKit 0x00007fff4f6ea987 _DPSNextEvent + 965
23 com.apple.AppKit 0x00007fff4f6e971f -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
24 com.apple.AppKit 0x00007fff4f6e383c -[NSApplication run] + 699
25 com.apple.AppKit 0x00007fff4f6d2d7c NSApplicationMain + 777
26 com.MyFolder.mfa1.Example 0x000000010ae1c33d main + 13
27 libdyld.dylib 0x00007fff7dfb13d5 start + 1
Thread 1 Crashed:: Dispatch queue: com.apple.root.default-qos
0 libxpc.dylib 0x00007fff7e1f86f9 _xpc_api_misuse + 75
1 libxpc.dylib 0x00007fff7e1ec837 xpc_connection_set_target_uid + 192
2 com.apple.ViewBridge 0x00007fff79b11221 +[NSXPCSharedListener endpointForListenerNamed:fromServiceNamed:queue:completion:] + 214
3 com.apple.ViewBridge 0x00007fff79b110a5 __76+[NSXPCSharedListener listenerEndpointForService:listener:queue:completion:]_block_invoke + 101
4 libdispatch.dylib 0x00007fff7df635f8 _dispatch_call_block_and_release + 12
5 libdispatch.dylib 0x00007fff7df6463d _dispatch_client_callout + 8
6 libdispatch.dylib 0x00007fff7df72509 _dispatch_root_queue_drain + 657
7 libdispatch.dylib 0x00007fff7df72b46 _dispatch_worker_thread2 + 90
8 libsystem_pthread.dylib 0x00007fff7e1a46b3 _pthread_wqthread + 583
9 libsystem_pthread.dylib 0x00007fff7e1a43fd start_wqthread + 13
Thread 2:
0 libsystem_pthread.dylib 0x00007fff7e1a43f0 start_wqthread + 0
Thread 3:: Dispatch queue: NSCGSDisableUpdates
0 libsystem_kernel.dylib 0x00007fff7e0e622a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff7e0e676c mach_msg + 60
2 com.apple.SkyLight 0x00007fff77239105 CGSUpdateManager::enable_updates_common() + 577
3 com.apple.SkyLight 0x00007fff772394a2 SLSReenableUpdateToken + 104
4 libdispatch.dylib 0x00007fff7df635f8 _dispatch_call_block_and_release + 12
5 libdispatch.dylib 0x00007fff7df6463d _dispatch_client_callout + 8
6 libdispatch.dylib 0x00007fff7df6a8e0 _dispatch_lane_serial_drain + 602
7 libdispatch.dylib 0x00007fff7df6b396 _dispatch_lane_invoke + 385
8 libdispatch.dylib 0x00007fff7df736ed _dispatch_workloop_worker_thread + 598
9 libsystem_pthread.dylib 0x00007fff7e1a4611 _pthread_wqthread + 421
10 libsystem_pthread.dylib 0x00007fff7e1a43fd start_wqthread + 13
Thread 4:: Dispatch queue: com.apple.CFNetwork.Connection
0 libsystem_kernel.dylib 0x00007fff7e0e71d6 __close_nocancel + 10
1 libsystem_dnssd.dylib 0x00007fff7e093aa7 deliver_request + 1333
2 libsystem_dnssd.dylib 0x00007fff7e093e5d DNSServiceGetAddrInfo + 221
3 libnetwork.dylib 0x00007fff7c43d1d6 nw_resolver_create_dns_service_locked + 678
4 libnetwork.dylib 0x00007fff7c43cead __nw_resolver_set_update_handler_block_invoke + 77
5 libnetwork.dylib 0x00007fff7c4268d7 nw_queue_context_async_if_needed + 87
6 libnetwork.dylib 0x00007fff7c43cb71 nw_resolver_set_update_handler + 321
7 libnetwork.dylib 0x00007fff7c43abfb -[NWConcrete_nw_endpoint_resolver startWithHandler:] + 1739
8 libnetwork.dylib 0x00007fff7c435a4d nw_endpoint_handler_path_change + 9677
9 libnetwork.dylib 0x00007fff7c42948f nw_endpoint_handler_start + 1247
10 libnetwork.dylib 0x00007fff7c428514 __nw_connection_start_block_invoke + 820
11 libnetwork.dylib 0x00007fff7c4268d7 nw_queue_context_async_if_needed + 87
12 libnetwork.dylib 0x00007fff7c428004 nw_connection_start + 148
13 libnetwork.dylib 0x00007fff7c422d0d tcp_connection_start + 1293
14 com.apple.CFNetwork 0x00007fff50fbb409 TCPIOConnection::_startConnection_Completion() + 313
15 com.apple.CFNetwork 0x00007fff50fbb13f Tube::preConnectConfiguration(tcp_connection*, void () block_pointer) + 535
16 com.apple.CFNetwork 0x00007fff50fb8905 TCPIOConnection::_startConnection() + 481
17 com.apple.CFNetwork 0x00007fff50fb861d Tube::_onqueue_startConnection() + 37
18 com.apple.CFNetwork 0x00007fff51116fad ___ZN4Tube23_onqueue_prepConnectionEU13block_pointerFvvEU13block_pointerFviE_block_invoke.53 + 815
19 com.apple.CFNetwork 0x00007fff5111741e ___ZN4Tube23_onqueue_prepConnectionEU13block_pointerFvvEU13block_pointerFviE_block_invoke_2.63 + 21
20 libdispatch.dylib 0x00007fff7df635f8 _dispatch_call_block_and_release + 12
21 libdispatch.dylib 0x00007fff7df6463d _dispatch_client_callout + 8
22 libdispatch.dylib 0x00007fff7df6a8e0 _dispatch_lane_serial_drain + 602
23 libdispatch.dylib 0x00007fff7df6b3c6 _dispatch_lane_invoke + 433
24 libdispatch.dylib 0x00007fff7df6c667 _dispatch_workloop_invoke + 2100
25 libdispatch.dylib 0x00007fff7df736ed _dispatch_workloop_worker_thread + 598
26 libsystem_pthread.dylib 0x00007fff7e1a4611 _pthread_wqthread + 421
27 libsystem_pthread.dylib 0x00007fff7e1a43fd start_wqthread + 13
Thread 5:
0 libsystem_pthread.dylib 0x00007fff7e1a43f0 start_wqthread + 0
Thread 6:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x00007fff7e0e622a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff7e0e676c mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff52065bee __CFRunLoopServiceMachPort + 328
3 com.apple.CoreFoundation 0x00007fff5206515c __CFRunLoopRun + 1612
4 com.apple.CoreFoundation 0x00007fff520648be CFRunLoopRunSpecific + 455
5 com.apple.AppKit 0x00007fff4f6f26a6 _NSEventThread + 175
6 libsystem_pthread.dylib 0x00007fff7e1a52eb _pthread_body + 126
7 libsystem_pthread.dylib 0x00007fff7e1a8249 _pthread_start + 66
8 libsystem_pthread.dylib 0x00007fff7e1a440d thread_start + 13
Thread 1 crashed with X86 Thread State (64-bit):
For full crash report look at the pastebin
来源:https://stackoverflow.com/questions/60812043/not-able-to-open-a-process-in-authorization-plugin-in-swift