MacOS – How to create a custom readable symlink out of a sandboxed container

librarymacospermissionsymlink

How do I create a readable symlink from within a ~/Library/Containers/.../Data/ app folder to a file outside?

It seems that due to the macOS sandboxing mechanism, this doesn't work out of the box. That is, I can create a symlink fine, but the app I use won't be allowed to read the symlinked file.

Notes:

  • My intent is to customize the setup of my own machine. I'm not an app developer.
  • Editing the file Container.plist within ~/Library/Containers/.../ might help. So far, I've not had success yet.
  • Personal use case: being able to open an app from two different user accounts on the same machine and share the same app-database.

Best Answer

Unlikely to be Possible

I suspect that if this were possible with a symlink, Apple would consider it a serious security flaw.

That said, see Why is the symlink I created inside an application container to allow for external storage not working? for possible solutions.

Sandboxed applications can only read the contents their containers, some global locations, and the locations explicitly granted to them by the user – via the Powerbox mechanism.

See Powerbox and File System Access Outside of Your Container:

Your sandboxed app can access file system locations outside of its container in the following three ways:

  • At the specific direction of the user
  • By using entitlements for specific file-system locations (described in > - Entitlements and System Resource Access)
  • When the file system location is in certain directories that are world readable

Given the list above, you may be able to extend the entitlements for the application to include your specific location and then resign the application.

Bypass the Problem

Alternatively, consider stripping the application of its sandboxing entitlement. You could try ad-hoc resigning the application and omit the entitlements entirely.