BH4FFUBH4FFU

程序员
业余无线电爱好者

解决方案 | mac安装Navicat,显示已损坏无法打开的

问题

在mac上安装非app sotre上的应用时,大概率会见到过以下的提示框
请输入图片描述

大意就是,这个东西是坏的,老子不喜欢,扔了吧。
呵~有点嚣张!接下来一招治的服服帖帖...

解决方案

打开终端,输入以下命令

sudo xattr -d com.apple.quarantine /Applications/xxxx.app

注意:/Applications/xxxx.app 换成你的App路径(推荐直接将.app文件拖入终端中自动生成路径,以防空格等转义字符手动复制或输入出现错误)

重启app即可

延伸亿点点

1)xattr干嘛的?
命令不懂的问男人,男人说:

The xattr command can be used to display, modify or remove the extended attributes of one or more files, including directories and symbolic links. Extended attributes are arbitrary metadata stored with a file, but separate from the filesystem attributes (such as modification time or file size). The metadata is often a null-terminated UTF-8 string, but can also be arbitrary binary data.

One or more files may be specified on the command line. For the first two forms of the command, when there are more than one file, the file name is displayed along with the actual results. When only one file is specified, the display of the file name is usually suppressed (unless the -v option described below, is also specified).

In the first form of the command (without any other mode option specified), the names of all extended attributes are listed. Attribute names can also be displayed using ``ls -l@''.

In the second form, using the -p option (``print''), the value associated with the given attribute name is displayed. Attribute values are usually displayed as strings. However, if nils are detected in the data, the value is displayed in a hexadecimal representation.

The third form, with the -w option (``write''), causes the given attribute name to be assigned the given value.

The fourth form, with the -d option (``delete''), causes the given attribute name (and associated value), to be removed.

In the fifth form, with the -c option (``clear''), causes all attributes (including their associated values), to be removed.

Finally, the last form, with either the -h or --help option, displays a short help message and exits immediately.

一句话总结一下:xattr 命令用于展示,修改或者删除扩展属性;问题又来了,拓展属性干嘛的?

2)拓展属性是什么?
新词不懂问维基,维基这么说:

Mac OS X 10.4 and later support extended attributes by making use of the HFS+ filesystem Attributes File B-tree feature which allows for named forks. Although the named forks in HFS+ support arbitrarily large amounts of data through extents, the OS support for extended attributes only supports inline attributes, limiting their size to that which can fit within a single B-tree node.[citation needed] Any regular file may have a list of extended attributes. HFS+ supports an arbitrary number of named forks, and it is unknown if macOS imposes any limit on the number of extended attributes.

Each attribute consists of a name and the associated data. The name is a null-terminated Unicode string. No namespace restrictions are present (making this an open xattr system) and the convention is to use a reverse DNS string (similar to Uniform Type Identifiers) as the attribute name.

macOS supports listing,[18] getting,[19] setting,[20] and removing[21] extended attributes from files or directories using a Linux-like API. From the command line, these abilities are exposed through the xattr utility.[22]

Since macOS 10.5, files originating from the web are marked with com.apple.quarantine via extended file attributes.[23] In some older versions of macOS (such as Mac OS X 10.6), user space extended attributes were not preserved on save in common Cocoa applications (TextEdit, Preview etc.).[citation needed]

只摘录了关于mac os x的描述,完整的可以参考:维基百科-extended file attribute
总结一下:
1)Mac OS X 10.4和更高版本通过使用HFS +文件系统属性文件B *-树功能来支持扩展属性
2)每个属性都包含一个名称和关联的数据。该名称是一个以空字符结尾的Unicode字符串
3)macOS支持使用命令xattr从文件或目录中列出,[18]获取,[19]设置,[20]和删除[21]扩展属性
4)从macOS 10.5开始,源自网络的文件通过扩展文件属性标记为com.apple.quarantine

另外,扩展文件属性是文件系统功能,典型的用途包括存储文档的作者,纯文本文档的字符编码或校验和,密码哈希或数字证书,以及访问控制信息。

看到这里,你是否已经看出为什么删除拓展属性就可以正常打开了呢?

参考资料

https://xclient.info/a/4f212972-733a-5d3d-b3a5-dca2557cf2db.html
https://en.wikipedia.org/wiki/Extended_file_attributes

本原创文章未经允许不得转载 | 当前页面:BH4FFU » 解决方案 | mac安装Navicat,显示已损坏无法打开的

评论 8510

文章评论已关闭!