Re: sudo in NSTask
Re: sudo in NSTask
- Subject: Re: sudo in NSTask
- From: April Gendill <email@hidden>
- Date: Thu, 25 Sep 2003 19:46:11 -0700
On Thursday, September 25, 2003, at 09:57 AM, Chris Hanson wrote:
On Thursday, September 25, 2003, at 10:50 AM, April Gendill wrote:
Is it possible to launch a task using NSTask in super user mode.
obviously make the path: sudo <some commandline app> does not work
since it actually wants a path and not a command line command.
There are two issues here that I'll address separately.
(1) You need to know the path to the tool you want to run to use
NSTask. In this case, you want to run sudo, so you need to know its
path. You also should pass a full path to sudo for the tool *it*
runs. Finally, you'll need to use the -S argument to sudo to have it
read the password from stdin, and use an NSPipe to pass that to sudo.
-S in the argument array. ok easy enough
(2) You should, in general, *not* use this as a way to run tools with
superuser privileges (i.e. as root). There is another, more flexible
and standardized mechanism on Mac OS X called Authorization Services.
When something like Installer.app or System Preferences.app asks you
for your password, it's not using sudo, it's using Authorization
Services. Apple has two samples called AuthSample and MoreAuthSample
that demonstrate exactly how they recommend developers accomplish > this.
The question, since I am using apt-get on the command line, is will
the auth services work? I agree, i an not exactly thrilled with the
idea of doing it via sudo but I did not think that auth services worked
through pipes.
To sum up, (1) says "learn the Unix process and execution model" and
(2) says "don't use it directly to run things with elevated
privileges, use the framework Apple provides for doing so."
-- 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.