One way to do this is AuthorizationExecuteWithPrivileges(), but it discourages the normal course of things. This is mainly for installers, I understand.
Sort of:
AuthorizationRef auth = NULL;
OSStatus err = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagInteractionAllowed, &auth);
err = AuthorizationExecuteWithPrivileges(auth, command, kAuthorizationFlagDefaults, args, NULL);
And you add the appropriate check err...
See the Authorization documentation .
source
share