All pastes #194934 Raw Edit

XAK

public text v1 · immutable
·published 2006-10-08 17:21 UTC
rendered paste body
	OSStatus myStatus;
	AuthorizationFlags myFlags = kAuthorizationFlagDefaults;
	AuthorizationRef myAuthorizationRef;
	 
	myStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, myFlags, &myAuthorizationRef);
	if (myStatus != errAuthorizationSuccess) return myStatus;
				
	AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
	AuthorizationRights myRights = {1, &myItems};
	
	myFlags = kAuthorizationFlagDefaults |
		kAuthorizationFlagInteractionAllowed |
		kAuthorizationFlagPreAuthorize |
		kAuthorizationFlagExtendRights;
		
	myStatus = AuthorizationCopyRights (myAuthorizationRef, &myRights, NULL, myFlags, NULL );	
	if (myStatus != errAuthorizationSuccess) return;
	myFlags = kAuthorizationFlagDefaults;
	
	char myReadBuffer[128];

	char myToolPath1[] = "/bin/cp";
	char *myArguments1[] = { "-R", [kextPath fileSystemRepresentation], [pathToInstalledKext fileSystemRepresentation], NULL };
	FILE *myCommunicationsPipe1 = NULL;		
	myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, myToolPath1, myFlags, myArguments1, &myCommunicationsPipe1);
	read (fileno (myCommunicationsPipe1),myReadBuffer, sizeof (myReadBuffer));