Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Calling kextunload / kextload on mac (need sudo privilege)
Forum Update on Monday, May 27th 2025

Calling kextunload / kextload on mac (need sudo privilege)

Scheduled Pinned Locked Moved Unsolved General and Desktop
kextsudoqprocessadministratorprivileges
3 Posts 2 Posters 945 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AloyseTech
    wrote on 2 Jun 2018, 13:23 last edited by
    #1

    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 :)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 Jun 2018, 21:18 last edited by
      #2

      HI and welcome to devnet,

      This stack overflow answer might be an interesting starting point.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        AloyseTech
        wrote on 3 Jun 2018, 21:16 last edited by
        #3

        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...

        1 Reply Last reply
        0

        1/3

        2 Jun 2018, 13:23

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved