• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: sudo in NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sudo in NSTask


  • Subject: Re: sudo in NSTask
  • From: Chris Hanson <email@hidden>
  • Date: Thu, 25 Sep 2003 11:57:54 -0500

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.

(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.

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.

  • Follow-Ups:
    • Re: sudo in NSTask
      • From: April Gendill <email@hidden>
References: 
 >sudo in NSTask (From: April Gendill <email@hidden>)

  • Prev by Date: Re: drawRect auto launch
  • Next by Date: Re: loadNibNamed:owner: Who disposes of the loaded objects?
  • Previous by thread: sudo in NSTask
  • Next by thread: Re: sudo in NSTask
  • Index(es):
    • Date
    • Thread