gpt4 book ai didi

macos - 在 Mac OS 上卸载/加载应用内内核扩展

转载 作者:行者123 更新时间:2023-12-02 04:29:10 25 4
gpt4 key购买 nike

我需要在 Mac OS 上的 Qt 桌面应用程序开头卸载一堆驱动程序 (kext)。我尝试使用 QProcess,但 kextunload 需要具有管理员权限。有人知道解决方法吗?或者如何使用 sudo 启动 QProcess?我希望这对最终用户来说很容易:用户只需在出现提示时输入管理员密码,其余的由应用程序完成。

问题是苹果在我想使用特定驱动程序(FTDI232H 和 FT2Dxx 驱动程序)的设备上加载他们自己的驱动程序。

最佳答案

我发现了一些似乎对我有用的东西:

QString password = "yourRootPassword"; //could be asked with QInputDialog::getText(...)
QString cmd = QString("sudo -S kextunload -b %1 > /dev/null").arg(driverName);
FILE *pipe = popen(cmd.toStdString().c_str(), "w");
if(pipe != nullptr)
{
fprintf(pipe, "%s\n", password.toStdString().c_str());
if (ferror(pipe))
{
qDebug() << "Failed to write to pipe";
}
else
{
qDebug() << "Written to pipe";
}
}
else
{
qDebug() << "Failed to open pipe";
}
qDebug() << "Pipe returned : " << pclose(pipe);

关于macos - 在 Mac OS 上卸载/加载应用内内核扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50657464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com