1

I can't figure out why my calls to NSFileWrapper's addRegularFileWithContents:preferredFileName: is setting the files quarantine bit (as seen when using xattr -l on the file) when in the sandbox only. My app saves files in the document bundle so this I think is the method I need to use but the quarantine bit is driving me crazy.

Maybe this is a feature of some sort but my app also chmod's these files as executable and runs them as shell scripts using NSTask. However with the quarantine bit on I get errors from the bash shell (this has been well documented on stack overflow).

Has anyone else experienced this and do you know if these are bugs or features? The only way to work around it for now is to know the shell of the file in advance and not rely on the interpreter at the top of the file (i.e. #!/usr/bin/php) but this an annoying hack to work around a problem that shouldn't be.

Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125
GenericPtr
  • 677
  • 1
  • 8
  • 18
  • I fixed some formating issues. Please review as I don't know much about Cocoa. That being said, from a "naive" point of view, setting the "quarantine bit" on a file created in a "sand box" sounds ... well ... kind of expected behavior. But as I said, I don't know much in that area. – Sylvain Leroux Jul 23 '14 at 17:54
  • Sounds like an intentional security feature of the Sandbox (preventing apps from executing downloaded data). Can you post the relevant code? – nobody Jul 23 '14 at 18:45
  • The code is in Pascal and difficult to break apart but the design is basically: in fileWrapperOfType:error: of the NSDocument subclass I allocate a new NSFileWrapper and then from an NSTextView I use dataUsingEncoding on the text and write the data to the file from the NSFileWrapper using addRegularFileWithContents:preferredFileName:. The user is aware of the script that they are editing and will be executing so if this is a feature Apple is sabotaging the intents of the user. – GenericPtr Jul 23 '14 at 22:26

0 Answers0