Re: Debugging a privileged helper
Re: Debugging a privileged helper
- Subject: Re: Debugging a privileged helper
- From: John Brownie <email@hidden>
- Date: Fri, 27 Jan 2017 09:46:07 +0200
Damien DeVille wrote:
Are you specifying the MachService you use for your XPC connection in
your launchd job?
I believe so. The launchd plist is:
==============
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.sil.KLMHelper</string>
<key>MachServices</key>
<dict>
<key>org.sil.KLMHelper</key>
<true/>
</dict>
<key>Program</key>
<string>/Library/PrivilegedHelperTools/org.sil.KLMHelper</string>
<key>ProgramArguments</key>
<array>
<string>/Library/PrivilegedHelperTools/org.sil.KLMHelper</string>
</array>
</dict>
</plist>
==============
The code to connect to the helper is:
==============
helperToolConnection =
NSXPCConnection.init(machServiceName: toolIdentifier, options:
NSXPCConnection.Options.privileged)
helperToolConnection?.remoteObjectInterface =
NSXPCInterface.init(with: Keyboard_Layout_HelperProtocol.self)
helperToolConnection?.invalidationHandler = {
self.helperToolConnection?.invalidationHandler = nil
OperationQueue.main.addOperation({
self.helperToolConnection = nil
})
}
==============
where toolIdentifier is "org.sil.KLMHelper"
The code that invokes the code is like this:
==============
let connection = connectionManager.helperToolConnection
let proxy =
connection?.remoteObjectProxyWithErrorHandler { (error) in
NSApp.presentError(error)
} as! Keyboard_Layout_HelperProtocol
let authorization = connectionManager.authorization
// Call the proxy with the appropriate code
proxy.authenticatedCreateDirectory(url: location,
authorization: authorization) { handler($0, $1) }
==============
All of this is derived from Even Better Authorization Sample, translated
to Swift.
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden