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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With