Re: Fun with AuthorizationExecuteWithPrivileges...
Re: Fun with AuthorizationExecuteWithPrivileges...
- Subject: Re: Fun with AuthorizationExecuteWithPrivileges...
- From: Andreas Monitzer <email@hidden>
- Date: Tue, 14 Aug 2001 02:49:23 +0200
On Tuesday, August 14, 2001, at 02:23 , Lloyd Sargent wrote:
On Monday, August 13, 2001, at 07:19 PM, Andreas Monitzer wrote:
On Tuesday, August 14, 2001, at 01:55 , Lloyd Sargent wrote:
Okay, so I'm running this tool. Now I want to kill the tool. NSTask at
least gave me that. However, I don't seem to see a way you can do this
with AuthorizationExecuteWithPrivileges... Am I missing something?
Yes, you and everybody else is missing a good API. The only known way of
doing this is to get the PID of the created process via the pipe (or
some lock-file) and call /bin/kill via the security API (requires
another authorization).
Okay, NOW you have stretched my knowledge of *nix... how does one get the
PID via the pipe?
If the tool is your own, it's not really a problem. When you need
something which you can't change the source, you have to create a wrapper.
Here's some code from my app pptp-gui
(
http://members.blackbox.net/a/programs/pptp/):
Inside the tool, just after launch (in main() for instance):
pid_t processid;
processid=getpid();
fwrite(&processid,sizeof(processid),1,stdout);
fflush(stdout);
In the calling app (this code is based on the stepwise-tutorial):
FILE* iopipe;
pid_t pptp_pid;
// ...
err=AuthorizationExecuteWithPrivileges(authorizationRef,
[pptp_exec
fileSystemRepresentation],
0, args, &iopipe);
fread(&pptp_pid,sizeof(pptp_pid),1,iopipe); // get pid
note that this call blocks until the tool calls fwrite.
andy
--
"He was addicted to life. But we cured him"