• 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
Authenthicate only once
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Authenthicate only once


  • Subject: Authenthicate only once
  • From: Vincent Pottier <email@hidden>
  • Date: Tue, 20 Jan 2004 13:55:13 +0100

Hello all,

I've got an issue with authenthication, i've write an application
calling quite frequently ipfw, as you know to change the ipfw parameter
you need to pass command as root.
Currently, i'm using something like that:
- (NSString *) commandAsRoot: (NSString *) ipToCancel
{
NSString *outPut=[[NSString alloc] init];
OSStatus myStatus; //OSStatus to create Authorization
OSStatus err = 0; //OSStatus to execute command with authorization
create in myStatus
AuthorizationRef *authorizationRef;
//Converting the IP adress from the NSString to a UTF8String format to
be paased in the command arguments
//(converting in cString is discouraged as it will be deprecated in the
near future)
char *cstring = [ipToCancel UTF8String];
FILE *commPipe;
//Creating the command arguments
char* args[9];
args[0]= "add"; args[1]="deny"; args[2]= "ip";
args[3]= "from"; args[4]= cstring; args[5]= "to";
args[6]= "any"; args[7]= "in"; args[8]= NULL;

myStatus = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment, kAuthorizationFlagExtendRights,
&authorizationRef);
if ((err = AuthorizationExecuteWithPrivileges (authorizationRef,
"/sbin/ipfw", 0, args, &commPipe)) != noErr)
{
NSLog (@"error %d", err);
}
else if (err == noErr)
{
//Get the command output and pass it in outPut
NSFileHandle *taskOutHandle = [[NSFileHandle alloc]
initWithFileDescriptor:fileno(commPipe)];
outPut=[[NSString alloc] initWithData:[taskOutHandle
readDataToEndOfFile] encoding:NSASCIIStringEncoding];
fclose(commPipe);
}
return outPut;
}

My problem is: each time I want to add an ipfw rule, an administrator
password is requiered, i would like to know how to implemente those
method without requering an password or requiering a password only
once.
Thanks in advance.
Vincent
_______________________________________________
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.

  • Follow-Ups:
    • Re: Authenthicate only once
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Has anyone compared Cocoa and DOTNET?
  • Next by Date: Re: NSWindow with individual background
  • Previous by thread: Re: NSWindow with individual background
  • Next by thread: Re: Authenthicate only once
  • Index(es):
    • Date
    • Thread