[英]MacOS: check for "Full disk access" privacy option
How can I check with my C application whether it has "Full disk access" permission in the System Preferences > Security & Privacy > Privacy?如何检查我的 C 应用程序在系统偏好设置 > 安全和隐私 > 隐私中是否具有“全盘访问”权限?
There is a similar question but the answer uses an outdated link and actually does not answer the question.有一个类似的问题,但答案使用了一个过时的链接,实际上并没有回答这个问题。
Actually it's pretty easy.其实这很容易。
Try to read/open a file in /Library.尝试读取/打开 /Library 中的文件。
If this fails and you get an error 257 you don't have Full Disk Access.如果此操作失败并且您收到错误 257,则您没有完整的磁盘访问权限。
It is now 2021, and there is still no API that prompts the user to enable Full Disk Access or queries on is it enabled.现在是 2021 年,仍然没有 API 提示用户启用全盘访问或查询是否启用。
There are some hacks with reading read some files, which on some system versions would be accessible only if the app has FDA enabled.读取某些文件有一些技巧,只有在应用程序启用了 FDA 的情况下,才能在某些系统版本上访问这些文件。
There are also some useful info if you could disable SIP.如果您可以禁用 SIP,还有一些有用的信息。
Nothing more.而已。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.