Re: Stderr from AuthorizationExecuteWithPrivileges
Re: Stderr from AuthorizationExecuteWithPrivileges
- Subject: Re: Stderr from AuthorizationExecuteWithPrivileges
- From: Bill Bumgarner <email@hidden>
- Date: Tue, 12 Jun 2001 13:51:56 -0400
In short, you cannot directly grab stderr. I ran into the same problem
with Xmanview and ended up writing a shell script to wrap the invocation
of man/rman/apropos such that I could grab the stderr output.
Conveniently, the stderr output only matters if there is no output on
stdout-- your situation may be different.
Xmanview source can be found via:
http://mosxland.sourceforge.net/
If that is the case, you could wrap the external processing in a shell
script or a tool, then format the output spewed on stdout of the shell
script/wrapper such that your application could read from the
communicationsPipe and determine where a particular hunk o' data was
from and what it means.
The exit code could be wrapped in a similar fashion.
Unfortunately, one cannot "promote" a task to having privileges that it
did not have at launch. This rules out the very convenient NSTask, at
this time. However, you could always:
- write a simple Foundation Tool wrapper that uses NSTask to call
out to the external executable
- use DO to communicate between the tool and your app
- authenticate and run the tool via the Authorization framework
The (FILE **) argument is simply so you can pass the FILE * by
reference. That is, pass the address of the FILE * variable (kind of
like a handle from ye old days of Mac OS programming) such that the
method/function you are calling into can set the variable accordingly.
Unfortunately, the Authorization framework does not currently allow you
to grab stderr.
If anyone is wondering why such an obviously useful feature was left
out, it is because it is not as easy as it might first appear. I
believe there was some piece of documentation or header that indicated
that it is on the todo list? In any case, make sure to file it as a
bug/feature-request against bugreport.apple.com!!
b.bum
On Tuesday, June 12, 2001, at 12:59 PM, cocoa-dev-
email@hidden wrote:
Message: 3
Date: Tue, 12 Jun 2001 13:50:05 +0200
From: "Sven A. Schmidt" <email@hidden>
To: "'email@hidden'" <email@hidden>
Subject: Stderr from AuthorizationExecuteWithPrivileges
In my project, I use the Authorization framework to access a cli tool
with root privileges. Reading from stdout and writing to stdin works
fine via the (FILE **)communicationsPipe parameter in
AuthorizationExecuteWithPrivileges(...). But the cli tool (crontab) also
returns stuff via stderr which I'd need to get a hold of.
Is there a way to get a handle to stderr?
What about the return value?
Or, even better, is there a way to promote an NSTask to root privileges?
Is there any special reason for the double star in (FILE
**)communicationsPipe? Is it an "implicit" array with stderr hiding in a
higher offset?
TIA,
Sven