MacOS – Get the PKG Installer To Prompt and Store Admin User/Pass


On Mac OSX, the third-party command line tool I have needs to run as super user unfortunately. I'm building a front-end GUI for it. My Qt/C++ application is using QProcess to shell out to Bash and run this command via echo "{PASS}" sudo -l "{USER}" -S {COMMAND}. I'm successful with that — just as long as I have the Apple ID user/pass.

Is there a way my PKG installer can graphically prompt for Apple ID user/pass? Second, how would you recommend I store this securely?

Best Answer

From this documentation... states that Apple PackageManager files (.PKG) files have an option to run with Administrator privileges. It specifically states:

If you install anything in /Applications or /Library, this option should be enabled.

Also, in this documentation... states that Bash scripts that you run will run under Administrator privileges (root) and therefore will not require sudo authentication to do powerful tasks.