【发布时间】:2014-01-27 10:28:54
【问题描述】:
我的 cocoa 应用程序设计是一个 .app(UI)和三个 XPC 服务。
主应用需要文件只读来显示powerbox并在UI中显示选择的路径
- com.apple.security.app-sandbox
- com.apple.security.files.bookmarks.app-scope
- com.apple.security.files.user-selected.read-only
两个 XPC 服务需要文件只读
- com.apple.security.app-sandbox
- com.apple.security.files.bookmarks.app-scope
- com.apple.security.files.user-selected.read-only
一个XPC服务需要文件读写
- com.apple.security.app-sandbox
- com.apple.security.files.bookmarks.app-scope
- com.apple.security.files.user-selected.read-write
由于用户交互的流程,主应用程序会打开一个 powerbox 对话框以允许用户选择一个目录并将其显示在 UI 中。然后,主应用程序将其保存为安全范围的书签。书签数据根据需要通过 XPC 连接发送,每个单独的 XPC 进程解析书签以访问其自己的沙箱中的这些文件。
问题是,除非我将主应用程序(打开电源盒)设置为具有文件 read-write 访问权限,否则需要写入访问权限的 XPC 服务将无法获得它,即使它的权利file 指定文件读写访问权限。控制台中记录了以下内容:
deny file-write-unlink <file path>
解决这个问题的唯一方法是为打开 powerbox 文件的主应用程序提供读写权利,还是重新设计 UI 流程以便需要写入权限的进程显示 powerbox?最终目标是让每个进程拥有尽可能少的权限。理想的权利是在主 .app 进程中没有文件访问权限,两个 XPC 服务具有文件只读和一个 XPC 服务文件读写。谢谢!
编辑:
Powerbox and File System Access Outside of Your Container:
与用户交互以扩展的 OS X 安全技术 您的沙箱称为 Powerbox。 Powerbox 没有 API。您的应用使用 使用 NSOpenPanel 和 NSSavePanel 时 Powerbox 透明 类。
【问题讨论】:
-
我已经更新了我的问题,并提供了指向 powerbox 上相关文档的链接。
标签: macos cocoa appstore-sandbox entitlements xpc