MacOS – Denied file read access on file I own and have full r/w permissions on

macospermission

I received an email with a plain text attachment (named 'noname') via Gmail and downloaded it using Chrome from gmail.com. It's a recurring automated report. Everyday I get the file , download it, open it, read it, and enjoy my life. Some days like today I get the file, download it and TextEdit on OS X won't let me open it.

TextEdit reports "The document "noname.txt" could not be opened. You don't have permissions."

A Get Info in Finder shows permissions:

ram (Me) Read & Write
Staff Read only
Everyone Read only

From a terminal I can do whatever I want to it (read, write, rename…). An ls -l shows:
-rw-r–r–@ 1 ram staff

An ls -le shows the same (i.e, no ACLs shown).

What gives?

Best Answer

From debugging a different problem (which showed up as deny file-read-data in the Console, see the other answer), it seems that sandboxd prevents sandboxed applications from reading quarantined data, so I think you'd need to remove the attribute with: xattr -d com.apple.quarantine /path/to/file (see for instance https://superuser.com/a/28394/46794). You'd need to prefix the command with sudo if the file didn't belong to your user, but according to your info it does.

The other user reported that using a non-sandboxed application fixed the problem, and this would confirm that sandboxing is at fault.

An aside: When ls reports extended attributes with @ next to the permission field, you don't need ls -le file, but instead ls -l@ file.