Skip to content

Sync from Linux to Mac with ownership - Local additions after rescan #9039

Closed

Description

@sprangen

Syncthing v1.23.6 on Mac (Monterey 12.6.2 and Big Sur 11.7.9) and Linux (Debian GNU/Linux 12 (bookworm))

We have a syncthing folder setup as a “send only” folder on a linux system and sync that with a “receive only” folder on a couple of Macs.
Syncthing on the Macs is started by a user with elevated priviledges.
The synced folder on the Macs is located under /Users/Shared/foldername.
The “sync ownership” option is enabled. Both systems are members of a domain.
The sync completes and all looks good, there are no errors or warnings in the log. Ownership and permissions of user and group get synced totally fine.

But after a rescan ALL Files are marked as local additions. If i disable “sync ownership” all works as expected and we do not have that problem.

Tested that with a new testfolder with only a few files in it and was able to replicate the behaviour.

I excluded the mac-folder from spotilight search and experimented with some settings like setting “modTimeWindowS” but that did not solve it.

I dont see a change in the files, there are no extended attributes set and the timestamp of the files does not change after the sync.

Corresponding Syncthing forum post:
https://forum.syncthing.net/t/sync-from-linux-to-mac-with-ownership-local-additions-after-rescan/20673/1

Activity

  1. added
    bug
    needs-triage
    on Aug 16, 2023
  2. imsodin commented on Dec 19, 2023

    @imsodin
    Member

    This one clearly slipped through the cracks, sorry.

    Could you enable debugging (in the UI actions > advanced > GUI > debugging) and then run syncthing cli debug file <folder-id> <rel-file-path> on an affected file both on the mac and linux, and post the output here.

  3. sven commented on Dec 27, 2023

    @sven
    Contributor

    Sounds like a similar problem I encountered. Syncing from Linux to Linux where one PC is send&receive and the other one is receive-only. Both are using the SyncOwnership folder config.

    Every time I revert the local changes on the receiving PC nearly all files pop up again as local changes.

    Maybe that's because of this logic:

    func unixOwnershipEqual(a, b *UnixData) bool {
    	if a == nil && b == nil {
    		return true
    	}
    	if a == nil || b == nil {
    		return false
    	}
    	return a.UID == b.UID && a.GID == b.GID && a.OwnerName == b.OwnerName && a.GroupName == b.GroupName
    }
    

    In my case the receiver hasn't the same users as it is just a server and it would be sufficient for me if it just stores the UID and the GID.

    The output of syncthing cli debug file SHARE FILEPATH seems to support this:

    Sender:

    "unix": {
        "gid": 1234,
        "groupName": "sven",
        "ownerName": "sven",
        "uid": 1234
    },
    

    Receiver:

    "unix": {
        "gid": 1234,
        "groupName": "",
        "ownerName": "",
        "uid": 1234
    },
    

    Because the ownerName and groupName can't be synchronized the current behavior led to an endless sync loop especially when receive-only is set to send&receive.

    A proposed fix would be:

    return a.UID == b.UID && a.GID == b.GID
    

    Would this be ok?

  4. calmh commented on Dec 27, 2023

    @calmh
    Member

    I think the check should probably be "equal or either side is empty" for the name values...

  5. sven commented on Dec 27, 2023

    @sven
    Contributor

    Wouldn't that fail if the UID or GID is assigned to a different user/group on the target?

    I think there is a use-case for both problems:

    1. The user wants to make sure the username matches on both systems regardless of the UID.
    2. The user wants to make sure the UID matches on both systems because the target system is just used as distributor between machines.

    So the better solution would be having a switch to sync either the UID or the username between the hosts. But that sounds like a future thing :-)

  6. calmh commented on Dec 27, 2023

    @calmh
    Member

    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.

    You can propose another mechanism, but then that's a separate feature issue I think.

  7. sven commented on Dec 28, 2023

    @sven
    Contributor

    @calmh Thanks for your help. I hope I understand your proposal correctly and the PR is done right: #9306

  8. added a commit that references this issue on Dec 28, 2023
    b7452dd
  9. added 2 commits that reference this issue on Jan 4, 2024
    db2c610
    cbead14
  10. added this to the v1.27.3 milestone on Jan 4, 2024
  11. added a commit that references this issue on Jan 14, 2024
    b2ba185
  12. added a commit that references this issue on Jan 28, 2024
    1ce2af1
  13. scarlion1 commented on Jul 6, 2024

    @scarlion1

    Hey I think I'm having similar issues to backup Android /sdcard to Linux backup drive (ext4).

    • Android: 1.27.6 from F-droid, root enabled/granted
      Send Only, Send Ownership, Send Extended Attr's.

    • Linux: 1.27.9 from syncthing repo
      Receive Only, Ignore permissions, Sync Ownership, Sync Extended Attr's
      Running as root systemd service with:
      # /etc/systemd/system/[email protected]/override.conf
      [Service]
      AmbientCapabilities=CAP_CHOWN CAP_FOWNER

    All the data is synced fine but none of the permissions or ownerships are (not sure if Android uses extended attr's).  On the Linux backup, it shows "Local additions" and the "Revert Local Changes" button appears to work but, within a few seconds, goes back to "Local additions".

    This patch would resolve this right? but it's still Unverified/not committed?  Anything I can do to fix my instances?  I found that if I manually use chown/chmod on the Linux backup data, then it becomes synced and number of "Locally Changed Items" decreases.  Thx

  14. added
    frozen-due-to-age
    on Apr 9, 2025
  15. locked and limited conversation to collaborators on Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrozen-due-to-ageneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions