I need some help with the security framework please WAS: I cant get my helper tool to launch
I need some help with the security framework please WAS: I cant get my helper tool to launch
- Subject: I need some help with the security framework please WAS: I cant get my helper tool to launch
- From: April Gendill <email@hidden>
- Date: Tue, 21 Dec 2004 17:46:20 -0700
I give up.
This code does not work or I don't know how to make it work.
I need to get authorization to delete a list of files. Right now what happens with the code below is that about half way into it the app hangs up and asks for the password again. Why is it loosing authorization? Does any one know of an example that might help or perhaps how I can set the timeout length so that the main app can continue to execute the helper untill all files are gone?
April.
On Dec 21, 2004, at 3:43 PM, April Gendill wrote:
Ok I copied the example code from Apple's site and then modified it for my app. This code is suppose to step through a list of files and remove only files not directories.
It does not work. It races through the loop never launching the helper app at all. What am I doing wrong???
April.
OSStatus myStatus;
FILE *myCommunicationsPipe=NULL;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults;
AuthorizationRef myAuthorizationRef;
myStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, myFlags, &myAuthorizationRef);
AuthorizationItem myItems = {kAuthorizationRightExecute, NULL, 0};
AuthorizationRights myRights = {1, &myItems};
myFlags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights;
myStatus = AuthorizationCopyRights (myAuthorizationRef,&myRights, NULL, myFlags, NULL );
if (myStatus != errAuthorizationSuccess){
[progressWindow orderOut:self];
return;
}
while(current = [iter nextObject]){
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
BOOL fileThere = [[NSFileManager defaultManager] fileExistsAtPath:current isDirectory:&isDir];
if (myStatus != errAuthorizationSuccess){
[progressWindow orderOut:self];
return;
}
if(fileThere && !isDir){
NSString * t = [[NSBundle mainBundle]resourcePath];
NSString * toolPath = [NSString stringWithFormat:@"%@/helper",t];
char *myArguments[] = { [current cString], NULL };
char * tp = [toolPath cString];
FILE *myCommunicationsPipe = NULL;
char myReadBuffer[128];
myFlags = kAuthorizationFlagDefaults;
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, tp, myFlags,
myArguments,&myCommunicationsPipe);
if (myStatus == errAuthorizationSuccess){
[pi incrementBy:1.0];
}
}//end if there and not dir
else if (!fileThere || isDir){
[pi incrementBy:1.0];
}
}//end while
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden