Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop my app from setting the "quarantine" bit?

Ever since OS X 10.7.3, my text editor is setting the "quarantine" bit on any file it touches.

My text editor is designed for working with shell scripts, and if the quarantine bit is set then a shell script cannot be executed from the command line, until you double click it in Finder and go through a "This application was downloaded from the internet" alert (or remove the quarantine bit with xattr).

For example, I just created a "hello world" script in my app, it has been quarantined, and cannot be executed:

$ xattr -l foo
com.apple.quarantine: 0006;4f51dd2f;Dux;
$ chmod +x foo
$ ./foo
-bash: ./foo: Operation not permitted

If I remove the quarantine bit, the script works:

$ xattr -d com.apple.quarantine foo
$ ./foo
hello world


According to some forum posts, TextEdit also sets the quarantine bit on any shell script it creates.

I'm using a simple NSDocument subclass to create the file:

- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
  return [self.textStorage.string dataUsingEncoding:self.stringEncoding];
}


How can I remove the quarantine bit from files created in my app? Other text editors, such a TextWrangler, do not set the quarantine bit.

UPDATE

A little more info, this only occurs when creating a "script application" file, which is anything from perl scripts to html.

And it only occurs when my app is sandboxed. Disabling sandboxing fixes the problem, but that's not a long term solution.

I've filed a bug with Radar, it looks like there might be nothing to do but wait/hope that avenue gets it fixed.

like image 615
Abhi Beckert Avatar asked Mar 03 '12 09:03

Abhi Beckert


1 Answers

Try ensuring that the LSFileQuarantineEnabled in your Info.plist is set to false (which should be the default). If the attribute is still being set, then I'd suggest filing a bug report and removing it programmatically with removexattr(2)/fremovexattr(2)

like image 130
一二三 Avatar answered Oct 08 '22 04:10

一二三