Re: sudo from nstask
Re: sudo from nstask
- Subject: Re: sudo from nstask
- From: Chris Hanson <email@hidden>
- Date: Sat, 27 Sep 2003 20:47:49 -0500
On Saturday, September 27, 2003, at 04:23 PM, April Gendill wrote:
// allocate a task to execute the script
NSTask * removeMRTask = [[NSTask alloc] init];
where do I put in the path to the task.
ok look, I've allocated the task, this is what I am using to launch it:
Read the documentation, and learn a bit about the Unix process and
execution model. (I've said this before.)
It should be very straightforward between the documentation for NSTask
and NSPipe, and knowledge of the Unix process and execution model, to
figure out how to do what it is that you want to do.
I'll give you a hint: "sudo -S /sw/bin/apt-get" is *not* a tool path.
You want to launch "/usr/sbin/sudo" as an NSTask whose stdin is
connected to an NSPipe you create. The arguments to this NTtask should
be:
0: "-S"
1: "/sw/bin/apt-get"
2: "-q1"
3: "-f"
4: "install"
5: wmName
And of course this is *not* how you should run a tool as root.
Instead, you should use the techniques described in Apple's AuthSample
and MoreAuthSample to actually launch the tool as root, by launching a
setuid-root helper tool that you send a set of rights and commands to
via a pipe.
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Mac OS X Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.