Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions advanced/folder-sync-ownership.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.. _folder-sync-ownership:

syncOwnership
=============

When enabled, Syncthing attempts to also synchronise ownership between
devices. Ownership is divided into two kinds:

- "Unix" ownership, which is the Unix style UID and GID, and
- "Windows" ownership, which the Windows file ownership concept.

The two are not mixed -- that is, ownership information is not synchronised
between POSIX and Windows systems, only POSIX-to-POSIX and
Windows-to-Windows. Nonetheless Syncthing attempts to leave unknown
ownership data intact: POSIX systems will not overwrite Windows ownership
data but pass it on unmodified, and vice versa.

Unix implementation
-------------------

Syncthing records both the numerical UID and GID for a file and the
corresponding user and group names, when they are known. When applying
ownership Syncthing will first attempt to look up a local user or group with
the given name, and if that fails it will fall back to the numerical UID and
GID.

Elevated permissions
~~~~~~~~~~~~~~~~~~~~

Syncthing, when running as a normal user account, doesn't have permission to
alter file ownership. There are several reasonable ways of running Syncthing
with elevated permissions to enable ownership sync:

- As root, in a Docker container, with the synced data mounted as a
volume.
- As a normal user, with extra capabilities granted to the executable.

To grant extra capabilities, the following steps must be taken:

- The executable must be owned by root and not writable by normal users.
- The executable must be granted the CHOWN and FOWNER capabilities. The
CHOWN capability is required to be able to change ownership on the file.
However, once that has been done Syncthing may no longer have permission
to act on the file in other ways while running as anonymous user. The
FOWNER capability ovverrides this.

Example commands of setting Syncthing up in this manner::

% sudo chown root /usr/local/bin/syncthing
% sudo chmod 755 /usr/local/bin/syncthing
% sudo setcap CAP_CHOWN,CAP_FOWNER=pe /usr/local/bin/syncthing

.. note:: Note that automated upgrades cannot be used with Syncthing elevated
in this manner as any automated upgrade would undo the capabilities granted.

Windows implementation
----------------------

Syncthing records the account name of the owner, and whether it is a group
or user. On the receiving side a user or group with the corresponding name
is looked up and set as the owner.
16 changes: 12 additions & 4 deletions users/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ located:
site request forgery).

The database is stored either in the same directory as the config (usually the
default), but may also be located in one of the following directories (Unix-like
default), but may also be located in one of the following directories (Unix-like
platforms only):

* If a database exists in the old default location, that location is
Expand Down Expand Up @@ -110,6 +110,7 @@ The following shows an example of a default configuration file (IDs will differ)
<copyRangeMethod>standard</copyRangeMethod>
<caseSensitiveFS>false</caseSensitiveFS>
<junctionsAsDirs>false</junctionsAsDirs>
<syncOwnership>false</syncOwnership>
</folder>
<device id="S7UKX27-GI7ZTXS-GC6RKUA-7AJGZ44-C6NAYEB-HSKTJQK-KJHU2NO-CWV7EQW" name="syno" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>dynamic</address>
Expand Down Expand Up @@ -213,6 +214,7 @@ The following shows an example of a default configuration file (IDs will differ)
<copyRangeMethod>standard</copyRangeMethod>
<caseSensitiveFS>false</caseSensitiveFS>
<junctionsAsDirs>false</junctionsAsDirs>
<syncOwnership>false</syncOwnership>
</folder>
<device id="" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>dynamic</address>
Expand Down Expand Up @@ -297,6 +299,7 @@ Folder Element
<copyRangeMethod>standard</copyRangeMethod>
<caseSensitiveFS>false</caseSensitiveFS>
<junctionsAsDirs>false</junctionsAsDirs>
<syncOwnership>false</syncOwnership>
</folder>

One or more ``folder`` elements must be present in the file. Each element
Expand Down Expand Up @@ -570,6 +573,11 @@ The following child elements may exist:
NTFS directory junctions are treated as ordinary directories, if this is set
to ``true``.

.. option:: folder.syncOwnership

File and directory ownership is synced when this is set to ``true``. See
:ref:`folder-sync-ownership` for more information.


Device Element
--------------
Expand Down Expand Up @@ -818,7 +826,7 @@ The following child elements may be present:

.. option:: gui.unixSocketPermissions

When ``address`` is set to a UNIX socket location, set this to an octal value
When ``address`` is set to a UNIX socket location, set this to an octal value
to override the default permissions of the socket.

.. option:: gui.user
Expand Down Expand Up @@ -1359,8 +1367,8 @@ be present in the ``defaults`` element:
Listen Addresses
^^^^^^^^^^^^^^^^

The following address types are accepted in sync protocol listen addresses.
If you want Syncthing to listen on multiple addresses, you can either: add
The following address types are accepted in sync protocol listen addresses.
If you want Syncthing to listen on multiple addresses, you can either: add
multiple ``<listenAddress>`` tags in the configuration file or enter several
addresses separated by commas in the GUI.

Expand Down