"Operation not permitted" - on deleting folders

From Wurst-Wasser.net
Jump to: navigation, search

I was about to delete a Time Machine Backup-Folder, and I got that:

MacBook-Air:.Trashes root# rm -Rf 502
rm: 502/2013-06-27-195031/Grob 109A/Applications/Merlin.app/Contents/Frameworks/CoreDataNet.framework/CoreDataNet: Operation not permitted
rm: 502/2013-06-27-195031/Grob 109A/Applications/Merlin.app/Contents/Frameworks/CoreDataNet.framework/PrivateHeaders: Operation not permitted
[…]
MacBook-Air:.Trashes root#

When Time Machine backups your data, it also applies ACLs:

MacBook-Air:.Trashes root# ls -le 502/2013-06-27-195031/Grob\ 109A/Applications/Merlin.app/Contents/Frameworks/CoreDataNet.framework/CoreDataNet
lrwxrwxrwx+ 1 appleadmin  admin  28 Dec 28  2007 502/2013-06-27-195031/Grob 109A/Applications/Merlin.app/Contents/Frameworks/CoreDataNet.framework/CoreDataNet -> Versions/Current/CoreDataNet
0: group:everyone deny write,delete,append,writeattr,writeextattr,chown
MacBook-Air:.Trashes root#

The solution is deleting the ACLs.

MacBook-Air:.Trashes root# chmod -RN 502
MacBook-Air:.Trashes root#

After that, the deletion works:

MacBook-Air:.Trashes root# rm -Rf 502
MacBook-Air:.Trashes root#