Calling kextunload / kextload on mac (need sudo privilege)
Unsolved
General and Desktop
-
Hi,
I need to unload a bunch of driver (kext) at the beginning of my Qt Desktop application on Mac OS.
I tried with QProcess, but kextunload requires to have admin privileges.
Anyone knows a workaround? Or how to start a QProcess with sudo?
I need this to be easy for the end user : one only has to enter the admin password when prompted and the application does the rest.Thanks in advance :)
-
HI and welcome to devnet,
This stack overflow answer might be an interesting starting point.
Hope it helps
-
Hi,
I have found something that works but that is not really "clean" in my opinion :
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);
I don't know how to use the Apple method linked by SGaist...