尝试在kext文件上运行kextutil返回权限错误

时间:2020-10-19 13:55:36

标签: xcode macos iokit kernel-extension

嗨,Stackoverflow社区。

尝试完成以下教程-这样我就可以学习如何编写驱动程序实用程序。
http://www.robertopasini.com/index.php/2-uncategorised/625-osx-creating-a-device-driver

我正要在构建生成的kext文件上运行kextutil。 按照说明,将其复制到我的临时文件夹中。 但出现以下错误:

admins-Mac-mini:Debug admin$ kextutil -n -t /tmp/ssvac.kext
Skipping staging and system policy checks because not running as root, expect staging errors.
Kext rejected due to improper filesystem permissions: <OSKext 0x7f91d402f140 [0x7fff898b2cc0]> { URL = "file:///private/tmp/ssvac.kext/", ID = "myappleid.ssvac" }
Code Signing Failure: code signature is invalid
Authentication Failures: 
    File owner/permissions are incorrect (must be root:wheel, nonwritable by group/other): 
        /private/tmp/ssvac.kext
        Contents
        _CodeSignature
        CodeResources
        MacOS
        ssvac
        Info.plist

Diagnostics for /private/tmp/ssvac.kext:
Authentication Failures: 
    File owner/permissions are incorrect (must be root:wheel, nonwritable by group/other): 
        /private/tmp/ssvac.kext
        Contents
        _CodeSignature
        CodeResources
        MacOS
        ssvac
        Info.plist

admins-Mac-mini:Debug admin$ 

我试图像这样更改权限/所有者:

admins-Mac-mini:Debug admin$ chown root:wheel /tmp/ssvac.kext/

admins-Mac-mini:Debug admin$ ls -lah /tmp/ssvac.kext/
total 0
drwxrwxrwx  3 root   wheel    96B 16 Oct 16:37 .
drwxrwxrwt  7 root   wheel   224B 19 Oct 08:08 ..
drwxr-xr-x  5 admin  wheel   160B 16 Oct 16:37 Contents
admins-Mac-mini:Debug admin$ kextutil -n -t /tmp/ssvac.kext

不确定确切的解决方法。 如果您有任何提示,我将不胜感激。

谢谢!

编辑1

My mistake was when I copied from the debug folder to /tmp/, I didn't use the -r switch.  Now that I have, this is the error I'm getting: 

admins-Mac-mini:Debug admin$ cp -r ssvac.kext/ /tmp/
admins-Mac-mini:Debug admin$ sudo kextutil /tmp/
Contents/                     com.apple.launchd.GufwRL5Sf0/ com.google.Keystone/          powerlog/                     ssvac.kext/
admins-Mac-mini:Debug admin$ sudo kextutil /tmp/ssvac.kext/
Password:
Untrusted kexts are not allowed
Kext with invalid signature (-67050) denied: /private/var/db/KernelExtensionManagement/Staging/tmp.RLlmC1/59AFE9EA-12E3-42C0-B3FC-E98EF987D9B2.kext
Bundle (/private/tmp/ssvac.kext) failed to validate, deleting: /private/var/db/KernelExtensionManagement/Staging/tmp.RLlmC1/59AFE9EA-12E3-42C0-B3FC-E98EF987D9B2.kext
Unable to stage kext (/private/tmp/ssvac.kext) to secure location.
admins-Mac-mini:Debug admin$ 

1 个答案:

答案 0 :(得分:0)

ls输出中可以看到,kexts实际上是至少包含一个Info.plist文件以及预定义目录布局中的代码签名信息的目录。 (从Contents子目录开始)通常它还包含一个二进制可执行文件。 kext中的所有文件和子目录必须具有适当的权限,才能考虑将kext加载。这意味着在使用-R时必须使用chown标志以递归方式应用权限。

通常不建议使用chown而不是简单地将kext复制为根用户的 临时位置,因为这样您就不会遇到尝试用更新的替换它的问题。在您的代码/编译/加载/调试周期中以非特权用户的身份版本:

# Copies kext to /tmp, owned by root
sudo cp -r "path/to/built.kext" "/tmp/"
# Attempts to load kext
sudo kextutil "/tmp/built.kext"

(强制性免责声明指出,现在已经不建议使用许多类型的kext,并且您要确保确实,确实,确实是编写kext的正确方法您的项目。)