Hi everyone,
First of all I'd like to thank all chromium devs for their work!
I've created a chromium-based application for Mac OS X and would like to distribute it via Mac App Store (MAS). As you may know MAS requires all applications to be sandboxed. Therefore i've codesigned my app with a corresponding
entitlement. However my sandboxed app crashes on start. The built-in
Console app helped me to find a number of different problems causing that crash. Most of such problems can be fixed by adding specific entitlements and
temporary exceptions to the entitlements property list. But there is a problem that I still can not find a solution to. It is related to OS X IPC that is based on the
Mach system.
Discovering the cause of my problem I've had to build chromium from the sources, and the source code debugging helped me to detect a tricky issue in the
MachPortBroker class.
As far as i can understand the workflow, during my app initialisation it's main process invokes `
MachPortBroker::Init` method, where it needs to register the "
rohitfork" service via bootstrap_check_in function. The service to be registered there should have a name that consists of my app's bundle id, service name itself and the main process (my app) id (`
MachPortBroker::GetMachPortName`).
Later the so registered service should be looked up by `
my app Helper` process (the child of my app's main process) that needs to send it's task port to the parent in `
MachPortBroker::ChildSendTaskPortToParent`.
So the problem is that the described workflow is breached when the app is running inside the Apple Sandbox, where all processes can only be started by the system launchd process. It means that inside the sandbox my app Helper is unable to look up a "rohitfork" service port because it does not know my app's main process id which is a service name's postfix.
Started outside the sandbox the app Helper can obtain required pid via `getppid` as it is a child of a main application process. However as i said before, inside the sandbox the launchd is a parent to all processes, hence `getppid` will always return "1" that makes the "rohitfork" service name to be like "my.app.bundle-id.rohitfork.1". As far as that service was registered with a different name the `bootstrap_look_up` call produces the following error:
[0422/224215.603951:ERROR:mach_port_broker.mm(138)] bootstrap_look_up Unknown service name (1102)
Finally i've tried to persist my app's main pid into a file and use it to manually reproduce the proper service name in `ChildSendTaskPortToParent`. However that name still remains "Unknown" for the `bootstap_lool_up` function, and the error mentioned above still appears in the built-in Console.
This is a problem i am totally confused with. So i really would like to know is it actually possible to run chromium-based app inside the Apple Sandbox? Can anyone please help me to find a workaround for my issue?
I will appreciate any help or advice. Thanks in advance!