Filling arguments for AuthorizationExecuteWithPrivileges (very newbie)
Filling arguments for AuthorizationExecuteWithPrivileges (very newbie)
- Subject: Filling arguments for AuthorizationExecuteWithPrivileges (very newbie)
- From: Jorge Salvador Caffarena <email@hidden>
- Date: Thu, 21 Jun 2001 14:13:48 +0200
Hello,
I am calling a CLI utility from my Cocoa app using
AuthorizationExecuteWithPrivileges, and I get a SIGBUS signal while
filling the arguments strings, here is the code I use:
- (void)execShutdownCountdownAtTime:(NSString *)minutes
{
NSString *prefix = @"+";
char* args[2];
OSStatus err = 0;
args[0] = "-h";
[[prefix stringByAppendingString:minutes] getCString:args[1]];
args[2] = NULL;
NSLog(@"Parameter passed: %s\nArguments: %s
%s",minutes,args[0],args[1]);
err = AuthorizationExecuteWithPrivileges(authorizationRef,
"/sbin/shutdown",0,args,NULL);
if(err!=0)
{
NSBeep();
NSLog(@"Error %d in AuthorizationExecuteWithPrivileges",err);
}
}
The problem seems to be in the getCString method, and it also seems to
be a really stupid one, so please be patient with me. I need to build a
C string like "+30", and I get "30" from a NSString via parameter.
Jorge Salvador Caffarena
http://homepage.mac.com/eevyl/