In a Mac OS X with more than one users , is there any API or piece of code that Run a process as another user in Objective C?
Asked
Active
Viewed 391 times
1 Answers
2
You need to use AuthorizationExecuteWithPrivileges, take a look e.g. at http://www.michaelvobrien.com/blog/2009/07/authorizationexecutewithprivileges-a-simple-example/
// Create authorization reference
AuthorizationRef authorizationRef;
OSStatus status;
status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults, &authorizationRef);
// Run the tool using the authorization reference
char *tool = "/sbin/dmesg";
char *args[] = {NULL};
FILE *pipe = NULL;
status = AuthorizationExecuteWithPrivileges(authorizationRef, tool,
kAuthorizationFlagDefaults, args, &pipe);

Leo Chapiro
- 13,678
- 8
- 61
- 92