If the Terminal command requires Administrator Privilege (aka sudo), use AuthorizationExecuteWithPrivileges instead. The following will create a file named “com.developers-life.test” is the root directory “/System/Library/Caches”.
AuthorizationRef authorizationRef;
FILE *pipe = NULL;OSStatus err = AuthorizationCreate ( nil,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&authorizationRef );
char *command = "/usr/bin/touch";
char *args [ ] = { "/System/Library/Caches/com.developers-life.test", nil };
err = AuthorizationExecuteWithPrivileges (authorizationRef,
command,
kAuthorizationFlagDefaults,
args,
&pipe );