Re: Communicating with Privileged Helper Tool
Re: Communicating with Privileged Helper Tool
- Subject: Re: Communicating with Privileged Helper Tool
- From: Mark Allan <email@hidden>
- Date: Wed, 23 Dec 2015 18:04:31 +0000
Hi Damien,
Thanks for replying.
> On 23 Dec 2015, at 5:18 pm, Damien DeVille <email@hidden> wrote:
>
>> Unfortunately, this gives me the exact same issue:
>
> How are you creating the other end of the connection? The remote port will just attempt to connect to the local port and not actually register the mach service. If you never registered the mach service name it will fail as you’re seeing.
Oops, sorry for missing this out. Here's the code in my main GUI application:
CFMessagePortRef localPort = CFMessagePortCreateLocal(NULL, CFSTR("com.example.app.port.server"), Callback, nil, nil);
if (!localPort) {
NSLog(@"couldn't open localport");
}
CFRunLoopSourceRef runLoopSource = CFMessagePortCreateRunLoopSource(nil, localPort, 0);
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
I know the port is getting created, as I can connect from another GUI app, I just can't connect from the helper tool.
I'm using the following to try and connect to it from the helper tool:
CFMessagePortRef remotePort = CFMessagePortCreateRemote(NULL, CFSTR("com.example.app.port.server"));
> You can use `CFMessagePortCreateLocal` in you helper tool. This function will take care of registering the service name with the bootstrap server (on top of giving you a port to listen on). If you’re using objc you can register your mach port directly by calling `NSMachBootstrapServer.registerPort:name:`.
>
> If you helper tool is launched by launchd, you can add the MachService name to your job plist and launchd will bootstrap it in the right domain for you.
The helper tool *is* launched by launchd, however if I add the MachService name to the plist, won't that mean the connection is going the wrong way? I want the GUI to listen for connections from the helper tool.
Thanks again
Mark
_______________________________________________
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