如何在不使用GUI的情况下“从身份不明的开发人员打开应用程序”?


13

基本上,我使用本机Safari.appWeb浏览器下载了第三方应用程序,并且希望在shell / CLI open的舒适环境下运行它。尽管出现以下错误消息:bashTerminal.app

“<unidentified_thirdparty.app>” can’t be opened because it is from an unidentified 
 developer. Your security preferences allow installation of only apps from the Mac 
 App Store and identified developers. Safari downloaded this file on <today's_date> 
 from <the.inter.net>.
                                          |[OK]|

Answers:


31

您要么必须在“ 系统偏好设置” >“ 安全性和隐私” >“ 常规” >“ 允许从以下位置下载的应用程序” 下更改设置到 任何地方, 要么在终端中,从下载的文件中删除xattr com.apple.quarantine属性。

xattr -dr com.apple.quarantine "unidentified_thirdparty.app"

我知道GUI方法。下一部分看起来不错。com.apple.quarantine(属性)参数到底指的是什么?
— 声音

1
@ tjt263,对不起,直到现在我还没有看到您的评论...所有文件系统对象都有属性,例如,您在ls -l file命令输出中看到的信息。文件系统对象还具有扩展的属性,该属性com.apple.quarantine是OS X分配给从Internet下载的对象的属性,以帮助防止任意执行,从而保护系统的一级。使用ls -lR@ file或xattr −lr file将显示扩展的属性信息,后者将输出更广泛的信息。请参阅man xattr以获取更多信息。
— user3439894'1

哇。那很有意思。我对此一无所知。其他操作系统是否具有类似的功能?
— 声音

您也可以右键单击(也可以按住Ctrl键单击)并选择“打开”,以仅执行该应用程序。
— 霍文·里维斯

1
@HawkenRives,是的,因为它是全局设置,而不是像右键单击文件一样实际运行或打开文件。使用xattr我的答案的一部分覆盖命令行和终端。
— user3439894 '16

0

在终端中以管理员帐户输入以下内容: sudo spctl --master-disable


这将完全关闭Gatekeeper。这不是问题的答案。
— l1ghthouse's

0

在命令行中明智地做到这一点

  • attr -p com.apple.quarantine unidentified_thirdparty.app 输出类似 0081;5e7fec61;Chrome;6585C1D3-E260-4275-9E6E-505DF8D6B7EE
  • 复制输出字符串,将前4个字符替换为 00c1
  • 跑 attr -w com.apple.quarantine 00c1;5e7fec61;Chrome;6585C1D3-E260-4275-9E6E-505DF8D6B7EE unidentified_thirdparty.app

要么

将这些步骤合并为一个命令

attr -w com.apple.quarantine "$(attr -p com.apple.quarantine unidentified_thirdparty.app | sed 's/^.\{4\}/00c1/' )" unidentified_thirdparty.app

我的博客文章。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.