Scenario
I have a mix of Windows and Linux machines on my home network. What I want to do is sync both user’s personal files (just the XFG_DATA_DIRS type content, no dotfiles) and a set of shared directories between them.
I originally tried to set this up using Syncthing several years ago, but ran aground on the perennial problem of Windows and Linux’s incompatible notions of file ownership and permissions.
With the advent of the copyOwnershipFromParent
advanced option for Syncthing I had hopes of being able to get this working. It is (“kinda”), but i’m not sure if what I am seeing is the expected behaviour.
Directory Structure
On Linux the setup is as shown below
Directory Owner Group
--------- ----- -----
/personal root admin
├── alpha alpha alpha
├── beta beta beta
├── gamma gamma gamma
└── delta delta delta
/shared alpha admin
├── music alpha admin
├── photo alpha admin
└── video alpha admin
On Windows there is a disk mounted as D:
with Personal
and Shared
as top-level subfolders.
Syncthing is running as a service on both machines. On the Linux box I have enabled AmbientCapabilities=CAP_CHOWN CAP_FOWNER
in the service configuraion and checked that the running service has those capabilities.
The synchronised folders have the Copy Ownership From Parent
option set on the Linux side (i’m not sure yet whether this is the best option for the Windows side).
The top level directories were pre-populated on each machine, with the appropriate ownerships and permissions (on Linux, 2770 for dirs and 660 for files)
The Question
The way I read the description of the copyOwnershipFromParent
option, both in the copyOwnershipFromParent online docs, and the original description of the solution I should be able to share the Personal
folder (that is /personal
on Linux, D:\Personal
on Windows). The user-level subfolders, such as /personal/alpha
are not being changed, only files below those folders are being modified.
Therefore, even with just a single shared root folder being synced, files written under (say) /personal/beta/Documents
should inherit the owner beta
, as should everything else belonging to beta
.
In practice, when i tried this setup the ownership search went right up to the top of the sync root (/personal) and I ended up with the equivalent of a chown -R root /personal
being run, changing the ownership of over 20,000 files.
I ended up working around the problem (after re-correcting all the file ownerships) by setting up separate sync relationships at the user level, i.e. /personal/alpha
, /personal/beta
etc.
So my question is, was my original understanding incorrect, and a Copy Ownership From Parent
relationship will ALWAYS copy the permissions and ownership recursively down from the root of the sync?
Or was my understanding correct, so a pre-populated root structure should only ever see permissions and ownership copied downwards in the folder structure, but existing top level dirs should not have their permissions changed?
If it’s the latter, then something strange is going on and i need to investigate further.