Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sandbox and NSTask

I'm trying to sandbox my app before submitting to the Mac App store and I need to open a dmg file. I tried the following, but I don't know if it's supposed to work with the Apple Sandbox.

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/hdiutil"];
[task setArguments:
 [NSArray arrayWithObjects: @"attach", [NSString stringWithFormat:@"%@/myfile.dmg", documentsDirectory], nil]];
[task launch];
[task waitUntilExit];
if (0 != [task terminationStatus])
    NSLog(@"Mount failed.");
[task release];

If I paste the full path into the terminal it work, if I run from the app I get the following error:

diskimages-helper[11437:303] ERROR: couldn't connect to framework.
diskimages-helper[11437:303] DIHelper: setupConnectionToFrameworkWithUUID: failed
hdiutil: attach failed - No child processes
Mount failed.

Thanks for any help! S.

like image 943
Soch S. Avatar asked Feb 02 '12 20:02

Soch S.


1 Answers

The official word on NSTask and Sandboxing is 'some executables may work.' For me this translates to 'don't count on it'. Although this executable does seem to show the help menu correctly I do see sandboxing errors in Console.app that would make me wary. Screenshot

I would agree with CodaFi on this one that you definitely shouldn't count on this to act how you'd like it to.

like image 74
Keith Smiley Avatar answered Oct 12 '22 23:10

Keith Smiley