The issue here is that Finder implements special handling of files restored from Time Machine to preserve all their permissions, which failed for files owned by the current user's account, but not a group he's a member of.
Usually, when copying files using cp
, their attributes aren't retained. This can be changed using the -p
option.
-p Cause cp to preserve the following attributes of each source file in the copy: modification time, access time, file flags, file mode, user ID, and group ID, as allowed by permissions. Access Control Lists (ACLs) and Extended Attributes (EAs), including resource forks, will also be preserved.
In both cases, you either copy all or none or these metadata. cp
is clever enough to restore them only after all contained files have been processed ([source, see near If -p is in effect, set all the attributes
).
If you don't have root permissions, ownership is not retained. The reason for this is that only root can make files owned by users not him and by groups he's not a member of.
To make Time Machine backups viewable but otherwise immutable in Finder, they are protected by Access Control Lists denying all users all modification permissions.
0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown
Since other attributes (other ACLs, extended attributes, file dates and permissions) should be retained when restoring from backup, special handling of these folders is required in Finder. It must remove a specific ACL entry, but retain everything else.
Additionally, Apple apparently wants Finder to retain all ownership information when copying files and directories from backup. This includes the group membership.
If your account is not the owner of the directories in question, Finder requests an administrator password and hands the copying off to its elevated privileges helper program Locum. This does not happen when you are the owner of a file in the backup set.
Now, one of the following cases happens:
- You are not the owner of the file: Finder asks for your password, Locum restores all permissions just as in the backup.
- You are the owner and a member of the file's group: Finder copies the file over and restores the group.
- You are the owner but not a member of the file's group: Finder copies the file over and fails to restore its group.
It's like it's trying to chown username:groupname
the file, and prints an error if it fails — which it does if you're neither root
(sudo
) nor username
and a member of groupname
.
It behaves slightly differently if you're not copying folders, but files: While file ownership is retained, group membership is discarded if you're not a member of the group. This is what you saw when only copying a single file.
The obvious solutions to this problem:
- Prevent file ownerships that cause restoration to fail (i.e. owned by you and a group you're not a member of — most of the time, this isn't useful anyway)
- Make yourself a member of that particular group at least temporarily. Unfortunately I wasn't able to do this using
dscl
from the command line in a way that had an effect without logout or restart. Another side effect is that with wheel
, you might run into problems with permissions depending on your system configuration.
Best Answer
If ~/Downloads/.localized does not exist, try creating it:
When the OS language is not English, there is normally an empty file named .localized inside each directory like ~/Downloads/ that has a localized name, and you can disable using localized names by deleting .localized files.