(a) Most of what you're doing can be done in Cocoa without having to spawn new processes.
(b) Most of it doesn't require root privileges.
* Instead of a 'curl' command, use [NSURLConnection sendSynchronousRequest:...]. * Please don't download to /. There is no need to put temporary files at the root of the filesystem! Call NSTemporaryDirectory() to get a path to download to. * Extracting the archive does require root privileges, and running 'gnutar' is probably the best way to do it (there is a system framework that can do this but it's private to Apple.) * Again, deleting the temporary file doesn't need root privileges if you put it in a temporary directory. Use NSFileManager to delete it.
* Some error checking wouldn't hurt.You really, really don't want to call 'rm' as root if you can possibly avoid it ... remember the poor people who had their disks erased by an iTunes installer (in 2002?) that had a buggy 'rm' command in it.
I'm still uncomfortable with this. It would be better if ImageMagick were packaged as an Installer package; then you could just download that and call NSWorkspace to open it, and have Apple's Installer app do the installation. I think most users would feel safer authorizing Installer to do surgery on their OS.
—Jens On 25 Mar '08, at 5:47 AM, Mr. Gecko wrote:
I looked around there and found nothing useful. Here is my code that I am tying to get root privileges with. NSTask* download = [[NSTask alloc] init]; [download setLaunchPath:@"/usr/bin/curl"]; [download setCurrentDirectoryPath:@"/"];[download setArguments: [NSArray arrayWithObjects:@"-O",@"http://www.imagemagick.org/download/binaries/ImageMagick-universal-apple-darwin8.11.0.tar.gz ", nil]];[download launch]; [download waitUntilExit]; NSTask* uncompress = [[NSTask alloc] init]; [uncompress setLaunchPath:@"/usr/bin/gnutar"]; [uncompress setCurrentDirectoryPath:@"/"];[uncompress setArguments: [NSArray arrayWithObjects:@"- xzf",@"ImageMagick-universal-apple-darwin8.11.0.tar.gz", nil]];[uncompress launch]; [uncompress waitUntilExit]; NSTask* delete = [[NSTask alloc] init]; [delete setLaunchPath:@"/bin/rm"]; [delete setCurrentDirectoryPath:@"/"];[delete setArguments: [NSArray arrayWithObjects:@"ImageMagick- universal-apple-darwin8.11.0.tar.gz", nil]];[delete launch]; [delete waitUntilExit];
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]