MacOS – Permission denied when accessing backup directory

backupitunesmacospermission

I used iTunes to make a backup of my iPhone. I can see the backup directory using Finder, at /Users/ronaldfischer/Library/Application Support/MobileSync/Backup. Strangely, when doing something like

ls "/Users/ronaldfischer/Library/Application Support/MobileSync"

or

du -ms "/Users/ronaldfischer/Library/Application Support/MobileSync/Backup"

I get an error message i.e. ls: MobileSync: Operation not permitted. But when I do a

ls -ld "/Users/ronaldfischer/Library/Application Support/MobileSync"

I see

drwxr-xr-x@ 3 ronaldfischer  staff  96 Sep 15 14:08 /Users/ronaldfischer/Library/Application Support/MobileSync

Hence I should have suffient permissions, plus Finder too can go into this directory without requiring me to switch to root rights.

Where does the permission problem come from?

UPDATE:

Running xattr on the directory MobileSync showed that it has the attribute com.apple.quarantine being set. This attribute is usually set on (usually an executable) file which is downloaded from somewhere, and ensures that MacOS is asking you "Do you really trust this file?" the first time it is opened. Maybe the attribute has been set because backing up my iPhone in effect means that external programs are downloaded.

However, this is likely not the reason of the strange behaviour, because I also get an operation not permitted, when I try to remove this attribute using xattr -d. Furthermore, @Seamus said in his comment, that he did not have this attribute being set, but also has no permission. Perhaps it is a glitch in this OS version? I'm still running Mojave (10.14.6).

Best Answer

You'll be able to read the directory if you grant Full Disk Access to your terminal program. Apple Menu › System Preferences › Security & Privacy › Privacy › Full Disk Access.