Le 14 juin 2012 à 22:39, Jens Alfke a écrit :

> I've managed to never have to deal with Authorization Services so far in my 
> Cocoa career; until today. Basically I have an app that needs to install some 
> helper tools that the user can run from a shell. (This is a lot like the way 
> TextMate installs the 'mate' tool.) I'm giving a choice of install locations, 
> but the typical one is going to be /usr/bin, so the app will need to 
> authorize to do that.
> 
> Reading through the Authorization Services Programming Guide and 
> BetterAuthorizationSample, this all looks really, really complicated. All I 
> need to do is the GUI equivalent of "sudo ditto my_tool /usr/bin" — does this 
> really take pages and pages of code involving AuthorizationRefs and IPC, and 
> either setuid or invoking launchctl?!
> 
> —Jens

You can ask the Finder to do it using Apple Events. I find it convenient as it 
takes care of the authorization for you.

Alternatively, you can use the authopen tool with NSTask to open the file, and 
then perform the copy yourself (see man authopen). It will also take care of 
the authorization for you, and will provide a pipe to write in the file.

-- Jean-Daniel





_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to