Main application can't access the new/modified file cache from the URL given by the File Provider

Our application which isn't a sandboxed app tries to access(copies) the file from the URL given by the file provider to the application's cache path but fails with the 'operation not permitted' error. This happens in two cases 1. File Creation & 2. File Modification. Also, on checking the path, it is like "/Library/Application Support/FileProvider/{RandID}/wharf/wharf/propagate".

Even we tried to access the folder using a Python script and run it via the terminal but it also failed with the same error.

But when we enable the 'full disk access' option in the 'privacy & security' tab of the system settings for the application(our main app/terminal), the files can be accessed.

Our application doesn't need the 'full disk access' instead it needs permission to access the file provider extension's cache path where the temp files were stored.

  1. How to get permissions for that folder and access the files (like setting the entitlement keys or other ways)? Or else
  2. Is there any way to inform the system to use our application cache path as the file provider's cache path?

Any help would be appreciated.

Replies

Your extension can obtain sandbox access to the file URL passed on createItem and modifyItem, by using the startAccessingSecurityScopedResource method on the URL passed. https://developer.apple.com/documentation/foundation/nsurl/1417051-startaccessingsecurityscopedreso?language=objc

Once your extension has sandbox access to the URL, your extension could copy (or preferably, clone), the URL to another location where your main app does have access.

@clenart

We tried the startAccessingSecurityScopedResource method on the URL passed. But the same 'operation not permitted' error is still occurring.

What might be the reason for this? Are there any other ways to get access to the URL?