When performing privileged operations...
When performing privileged operations...
- Subject: When performing privileged operations...
- From: Clark Mueller <email@hidden>
- Date: Tue, 2 Jul 2002 00:55:21 -0600
Is the authorized operation performed as a separate thread? I am experiencing some interesting behavior where my method for performing the operation returns a result code before the operation itself has completed. Is that normal, or might I have a bug elsewhere? Following is the method to perform the operation. The method is called and its result code examined. Basically what I am doing, in the case where I am having problems, is copying a file to a new location (that's what the tool called does), and I'd like to open the new file after it is created. Unfortunately, the new file does not exist when I try to open it. That shouldn't be... programatically, the new file is definitely supposed to be opened after it has been created. Apparently, the operation as called from this code below finishes successfully in copying the file, but not until _after_ I need it...
Can anyone give me some pointers?
TIA,
Clark
- (BOOL)performAuthorizedOperation:(NSString *)operation withPath:(NSString *)path andArgument:(NSString *)argument andResult:(int *)result{
char* args[4];
OSStatus err = 0;
if(![self authenticateUser])
return NO;
//the arguments parameter to AuthorizationExecuteWithPrivileges is
//a NULL terminated array of C string pointers.
args[0]=(char*)[operation cString];
args[1]=(char*)[path cString];
if(argument){
args[2]=(char*)[argument cString];
args[3]=NULL;
}
else{
args[2]=NULL;
args[3]=NULL;
}
err = AuthorizationExecuteWithPrivileges(authorizationRef,
[[[NSBundle mainBundle] pathForResource:@"mfig" ofType:@""] cString],
0, args, NULL);
if(err!=0)
{
// NSBeep();
FDLog([NSString stringWithFormat:@"Error %d in AuthorizationExecuteWithPrivileges",err]);
*result = err; // for now. in the future, let's make this return the result value of the function...
return NO;
}
return YES;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.