AuthorizationExecuteWithPrivileges & Foundation & Termination
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