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

installkeychainmacospasswordpkg

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

http://s.sudre.free.fr/Software/documentation/Packages/en/Package_Settings_Customization.html#6

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

http://s.sudre.free.fr/Stuff/PackageMaker_Howto.html

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