AuthorizationExecuteWithPrivileges + StdErr + PID

February 7, 2006

AuthorizationExecuteWithPrivileges is a MacOSX function can be used to programmatically execute a command as root. (It presents a dialog asking for administrator password).There’s 2 information that this function doesn’t give you back:

  • executed process’s pid – so that you can wait for it, and get the exitCode of it
  • file handle to stderr
Please note that this function is probably not secure enough. (But probably not much worse than most uses of AEWP). See the BetterAuthorizationSample code for truly secure solution.

My AuthorizationExecuteWithPrivilegesStdErrAndPID tries to overcome both limitation. Here’s the code.


Advertisements