- I already have a TLS connection between the child process and the
daemon. Can I serialize the anonymous listener endpoint and funnel it
through that?
Presuming that you mean TLS as in Transport Layer Security, then the answer is “No.”
- I'm having trouble understanding the security model for XPC. All of my
executables are in the same bundle (hardened runtime, signed deep etc)
and I intend only those within the bundle to communicate with each
other. When exposing mach services via launchd.plist, is this the
default behavior or can any executable outside of the bundle connect
as well?
Yes. There are two ways to access an XPC listener:
The second option is the interesting one, because it’s how you ‘bootstrap’. macOS has a hierarchy of Mach bootstrap namespaces, as described in Technote 2083 Daemons and Agents. If you create a launchd
daemon then its service is registered in the global namespace, where any code on the system can access it [1]. If you want to restrict your clients, you’ll need to add code to do that.
This has been a persistent pain point for third-party XPC services. We’ve made some progress in recent releases — see Validating Signature Of XPC Process for more — but, as of macOS 12, the best solution is only available to folks using the XPC C API )-:
- In the spirit of [1], is it possible for me to use my existing TLS
connection between the child process and the daemon to smuggle the
metadata and then open a listener in the child process?
I’m not sure how this question differs from question 1.
I could also remove the child process and have it spawned via
launchd
and instead.
OK. That’s a viable solution if there’s only a single child process of any given type. Your thread title says “launch daemon children”, so I assumed that you wanted multiple child processes of the same type. If there’s only one child per-type, managing them via launchd
is fine.
If I do that, I'd have to configure it as Disabled
and manually
launch it using the daemon.
Do not do that. If you’re going to have launchd
manage the job, you should let it do its thing. That is, the job should start on demand.
I need the lifecycle of the child process to be tied to the lifecycle
of the daemon.
Can you explain more about this requirement?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Assuming it’s not blocked by the sandbox.