MacOS – Files synced by Synk Pro have wrong owner on both synchronized Macs – how can I fix it

command linedata synchronizationmacospermission

I sync some folders within my Home folder between two Macs (running Lion and Mountain Lion) using Synk Pro, a commercial live file sync application. I have the same account name on both computers.

After syncing, some of my files on both computers are read-only, and they also aren't owned by me, but by the macports account – why?

Capture of the "Sharing & Permissions" section of a "Get Info" window, showing "macports" as the owner

To be able to modify files, I've used Get Info to change permissions of some files to read/write for 'everyone', and I used the app Permissions Reset to reset permissions back to original, but it doesn't change the permissions of sub-folders/files, and I have a huge file tree, so doing this manually is practically impossible. And Disk Utility does nothing to user data.

How can I fix this?


Added info:

As suggested, I ran the commands id -u and id -u macports on both computers. The result is that on the MacBook Pro, my account has uid 501 and macports has uid 502, and on the iMac it's the other way around.

Best Answer

The files appearing read-only to you is probably only because you are currently not their owner.
    What's likely happening is that the synced files retain the numeric owner-id from the source machine, and since that numeric uid in this particular case corresponds to the account macports on the target machine (in both transfer directions), macports has become the owner.

To verify that your account on each computer has the same numeric uid as the macports account has on the other machine, type the commands id -u and id -u macports in the Terminal in your account on both computers.

Fixing the cause of the problem

When information was submitted that the syncing is done using Synk Pro, I had a look at the Synk Pro web site and the app, and in the 'Advanced' settings I noticed the "Ownership:" option, which by default is set to "Copy If Possible".
    Since it looks like Synk Pro transfers files' numeric uid, and there's no option for mapping this uid to another uid/account on the target computer, the way to make synced files be owned by you is to change the "Ownership:" setting to "Ignore".

screen capture of Synk Pro's advanced "Ownership" option set to "Ignore"

Fixing the files

To fix the permission problem for the already synced files, you only need to change the owner of the files to your own account. Since (in this case) all of your synced folders are within your Home folder /Users/youraccount, you can do this with the following command in the Terminal when logged in to an administrator account (you'll have to give sudo the password of the admin account):

sudo chown -R youraccount /Users/youraccount

using the actual account name (also known as short user name) of your own account in place of youraccount. The account name is the same as the name of your account's Home folder in the /Users folder.
    This will change all files and folders within the folder /Users/youraccount to be owned by youraccount (-R is for recursive), which should give you write-access to all of your files.

Since you earlier gave write-permission to 'everyone' for some files to be able to modify them, you may want to remove those permissions. This command:

sudo chmod -R u+w,go-w /Users/youraccount

ensures that the owner of your files, and no-one else, has write permission on them.

Type man chown and man chmod for more info about these commands.


Advice against using Finder to fix a folder's permissions

(I will update the below later)

Note: It is possible to change ownership and permissions of all files and folders in a folder tree using the Finder, by use of the controls at the very bottom of the Sharing & Permissions section of a Get Info window as shown in the picture in the question. One problem with this is that an account's home folder, and the standard subfolders therein, such as Library, Documents, Public and so forth, have special permissions (by use of ACLs) preventing them from being deleted among other things, and you don't want these special permissions to be removed or propagated to other folders and even files, so you should not use this unless you know very well what you are doing.