• 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
AuthorizationExecuteWithPrivileges & Foundation & Termination
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AuthorizationExecuteWithPrivileges & Foundation & Termination


  • Subject: AuthorizationExecuteWithPrivileges & Foundation & Termination
  • From: Kim Foo-Jones <email@hidden>
  • Date: Sat, 8 Sep 2001 04:22:13 +0100

I'm using AuthorizationExecuteWithPrivileges() to run a tool which runs continuously and needs to return data to my app (it captures network packets). The simplest way seems to be to output the packets from the tool via stdout (printf() or something?) and then do an fread() on the FILE* returned by AuthorizationExecuteWithPrivileges()...

However, I would prefer to use Foundation to receive the data - with NSFileHandle, for example. (I just prefer Foundation to the unix stuff from an aesthetic standpoint :) it also seems easier to do slightly more complex stuff - like reading asynchronously). I made a huge guess and tried making an NSFileHandle by using fileno() as follows:

FILE* receivePipe;
NSFileHandle* receivePipeFileHandle;

theError = AuthorizationExecuteWithPrivileges (theAuthorizationRef, capturerPath, 0, capturerArguments, &receivePipe);
receivePipeFileHandle = [[NSFileHandle alloc] initWithFileDescriptor:fileno (receivePipe)];

to my surprise, it seems to be working with a simple test (the tool launched is just the default "Hello World" thing, but it printf()s "Hello World" instead of using NSLog (). It also exits immediately, unlike my tool, which would keep running until told to stop (see below))... Are there any potential problems doing things like this?

Also, how can I stop the task when the user wants to stop capturing? AuthorizationExecuteWithPrivileges() doesn't seem to provide any way of getting any information about the task/process/whatever it spawns...

Thanks,

-Kim Foo-Jones


  • Follow-Ups:
    • Re: AuthorizationExecuteWithPrivileges & Foundation & Termination
      • From: Finlay Dobbie <email@hidden>
  • Prev by Date: Passing along window clicks?
  • Next by Date: Re: cocoa-dev digest, Vol 1 #541 - 16 msgs
  • Previous by thread: Re: Online C++ resources?
  • Next by thread: Re: AuthorizationExecuteWithPrivileges & Foundation & Termination
  • Index(es):
    • Date
    • Thread