gpt4 book ai didi

macos - 尝试使用 codesign 命令进行沙箱时出错

转载 作者:行者123 更新时间:2023-12-02 07:12:17 38 4
gpt4 key购买 nike

我正在尝试使用codesign命令将我的OS X应用程序沙箱化(这是一个常见的lisp应用程序,不使用Xcode)。我创建了一个非常基本的 enentlements plist,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>

我正在调用codesign命令:

codesign -s - -f --entitlements "/path/to/my/app/MyApp.app/Contents/entitlements.plist" "/path/to/my/app/MyApp.app/"

但是此命令返回以下错误:

/path/to/my/app/MyApp.app/Contents/entitlements.plist: cannot read entitlement data

这个错误是否意味着我使用了错误的命令?如果是这样,该命令有什么问题?

最佳答案

Xcode 生成的 plist 是二进制格式,对于相当标准的有限沙箱设置如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>$(TeamIdentifierPrefix)com.company.appanme</string>
</array>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)com.company.appname</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.assets.movies.read-only</key>
<true/>
<key>com.apple.security.assets.music.read-only</key>
<true/>
<key>com.apple.security.assets.pictures.read-only</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.print</key>
<true/>
<key>com.apple.security.files.bookmarks.document-scope</key>
<true/>
</dict>
</plist>

我所能建议的是使用 Xcode 构建 plist 并手动删除那些您不需要的键。就你而言...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

我只是想知道签名工具是否因某种原因需要 !DOCTYPE 元素,并且编码属性应该为大写。

我还留下了一些可能需要的键,即使正如你所说,它是一个基本的 Lisp 应用程序,特别是 com.apple.security.files.user-selected.read-write 键,它将为您提供进程文件访问权限。

关于macos - 尝试使用 codesign 命令进行沙箱时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15231592/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com