软件包安装程序如何检测用户是否同意 kext

Packages installer how to detect if user consent to kext

我有一个 Packages created installer,人们总是忘记同意加载 kext,有没有办法在隐私设置中检测用户是否允许,以便安装程序可以提示用户允许它?

我知道的唯一方法是在 bash 脚本中使用 kextstat 来检查 kext 是否 运行 以确定用户是否允许。

引用自the official documentation on the kext approval "feature"

To determine if a KEXT has failed to load because it does not have user approval:

If you are using kextutil or kextload, check for the exit code 27. In addition, kextutil will produce the error message System policy prevents loading the kernel extension. If you are using the KextManager APIs in IOKit/kext/KextManager.h, check for the result code kOSKextReturnSystemPolicy.

因此,您可以从安装程序包调用 shell 脚本或类似脚本,或使用安装程序插件来调用 kextload/kextutil 或 KextManager API.请注意,在 Big Sur 上,用户还必须重新启动才能加载 kext,因此即使在用户批准后,kext 仍然不会立即加载。