Important: Please read the Qt Code of Conduct -

Sudo Qt Application on OS X from the created DMG

  • Hi,
    I would like to find out the most suitable way in order to deliver a Qt Application on OS X that requires root privileges. I'm using macdeployqt tool that let me resolve all dependencies and ship everything in a DMG, but I need to sudo the Qt binary to open some privileged port (<1024) thus I need to ask the user password before executing it.
    Right now, I'm just calling Cocoasudo binary from a C program that makes:

    execlp("./cocoasudo", "cocoasudo", "./qtbinary");

    this binary is called modifying Info.plist Application file, thus the Application ask for user password and cocoasudo does it job, but I wonder if there is another more standard way in order to do this without this tricky mode. Maybe integrating directly Cocoasudo code inside the Qt Project, but how to run grant the program from Qt main loop?