我正在制作一个 Mac OS X 应用程序(沙盒),它从 /etc/myfolder 中安装的配置文件读取。当我尝试使用 NSFileHandle 读取文件时,我在控制台中收到以下错误:
sandboxd: ([3251]) MyApp(3251) deny file-read-data /private/etc/myfolder/myconfig.conf
我已在我的 Entitilements 文件中设置了以下权利,但我仍然被 sandboxd 拒绝。
- com.apple.security.temporary-exception.files.home-relative-path.read-only
- com.apple.security.temporary-exception.files.absolute-path.read-only
- com.apple.security.files.user-selected.read-only
编辑:看来我误用了
com.apple.security.temporary-exception.files.absolute-path.read-only
.
我将其设置为布尔值。我的印象是,将其设置为 YES 将启用使用绝对路径的所有文件读取。上述权利的值必须是允许的绝对路径。
你需要使用com.apple.security.temporary-exception.files.absolute-path.read-only
和绝对路径/private/etc/myfolder/myconfig.conf
- (10.8.3) 沙箱似乎不接受/etc/myfolder/myconfig.conf
包含符号链接的路径。
Note:如果您正在 Mac App Store 进行沙箱处理,那么您可能会面临一项几乎不可能完成的任务:让您的应用程序接受并具有读取 /etc 中文件的临时权限。您最好将此文件存储在应用程序的容器中 - 在 MAS 中,每个应用程序都是一个被鲨鱼出没的水域包围的岛屿。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)