• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Communicating with Privileged Helper Tool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Communicating with Privileged Helper Tool (From: Mark Allan <email@hidden>)

  • Prev by Date: Re: Any way to intercept the URL-opening mechanism on OS X?
  • Next by Date: Frameworks in the Helper LoginItems app
  • Previous by thread: Communicating with Privileged Helper Tool
  • Next by thread: Frameworks in the Helper LoginItems app
  • Index(es):
    • Date
    • Thread