Re: NSTask with Root Privs
Re: NSTask with Root Privs
- Subject: Re: NSTask with Root Privs
- From: Stefan Arentz <email@hidden>
- Date: Sun, 27 May 2001 17:41:53 +0200
On Sun, May 27, 2001 at 03:59:15PM +0100, Finlay Dobbie wrote:
>
OK, well I'm doing that, but there's no easy way of getting the PID of
>
the process that is spawned by the AuthorizationExecuteWithPrivileges()
>
function. The only way I can think of doing that is by using a wrapper
>
program which takes the argument of a path, so it does like this:
>
/path/to/theApplicationBundle/Resources/commandwrapper /usr/bin/whoami
>
>
printf("%i",getpid());
>
execv(the argument);
>
>
but that's just PureEvil
>
>
i could also search for a process with the ppid of my cocoa app, but
>
that could break if i've done this for multiple processes all happening
>
at the same time.
Another method is to spawn a 'proxy' application that understands DO. Say
you exec 'myproxy --id=9813928392' using the security framework. Then you
can contact that proxy from your application and using DO you can ask it
to execute another tool. The --id argument is used by the proxy to
register a DO connection so that your application can find it later on ...
Probably less than 100 lines of code ... and *very* reusable :-)
>
GRRR. why doesn't apple just modify the security framework so it can put
>
the result of the fork() it executes into an argument!
>
>
this is a blatant oversight and should really be fixed.
Hm Dunno. Why would you want to know internals of the underlying OS :)
Stefan