MacOS – Cannot change anything inside a folder, however it’s not Locked and I have all the rights

backuphfs+macospermission

I copied several folders from my TM backup (made in El Capitan) to the current system (Sierra), (I also have different username than on the system where I made the backup if that could matter) and now their contents can be changed only via sudo.

I tried running sudo chown -R <my_name> <folder> — no effect at all.
Also tried running find . -exec sudo chown <my_name> "{}" \; from them — again no luck.
Also tried find . -exec sudo chmod u+rwx "{}" \;, sudo chmod -R u+rwx <folder>. Nothing changed anything.

These folders and all their contents show up in Finder as Read&Write for my user, and they also do not have Locked property set. Somehow this is not true in practice.

What can I do to fix this insanity?

I have found only one thing that actually solves it — copy the whole folder, delete old one with sudo, rename it back. But it's impractical for huge folders because it's slow and hurts SSD life.

Best Answer

UPDATE 2 (now I got it):

The culprit is the ACLs. Apparently Time Machine uses them, and copying via Finder preserves ACLs.

They are easy to remove recursively from folders where you know they are not needed:
sudo chmod -R -N ~/Pictures for example will drop all ACL rules in ~/Pictures and everything inside.

Source/more info: https://backdrift.org/fixing-mac-osx-file-permissions-and-acls-from-the-command-line

older unsuccessful attempts:

After some more desperate searching and brainstorming, I came up with one workaround:

1: Install coreutils from Homebrew (if not already done so)

2: gcp -dRl <broken_folder> <temporary_folder> — this will "copy" it with hardlinks instead of actual copying while not preserving permissions and any other "invisible" things which could be broken, so it's fast and almost zero damage regardless of file sizes

3: Test if permissions in temporary folder are OK "in practice"

4: sudo rm -rf <broken_folder> && mv <temporary_folder> <broken_folder> — remove bad one and put fixed one in its place

based on this answer and GNU cp manual.

UPDATE:

In newer versions of macOS even this doesn't work. Looks like they are actively trying to make me switch to another OS.