• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Filling arguments for AuthorizationExecuteWithPrivileges (very newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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/


  • Follow-Ups:
    • Re: Filling arguments for AuthorizationExecuteWithPrivileges (very newbie)
      • From: Brendan Younger <email@hidden>
  • Prev by Date: Re: Multiple NSTableView question
  • Next by Date: Preferences using NSUserDefaults (newbie)
  • Previous by thread: Setting text delegate for an NSTableView?
  • Next by thread: Re: Filling arguments for AuthorizationExecuteWithPrivileges (very newbie)
  • Index(es):
    • Date
    • Thread