Skip to content

Add support for syncing ownership of files #1329

Closed

Description

@crosbymichael

It would be nice to add support for syncing file ownership with uid and gid. This already supports permissions.


2019 note: this issue was originally titled "...syncing uid:gid of files" and there's initial discussion of that, but that's too constricted hence I've retitled it. //@calmh

Activity

  1. kozec commented on Feb 5, 2015

    @kozec
    Contributor

    Wouldn't that require running Syncthing as root?

  2. jpjp commented on Feb 5, 2015

    @jpjp
    Contributor

    Yep that would require root.

  3. AudriusButkevicius commented on Feb 5, 2015

    @AudriusButkevicius
    Member

    I am pretty sure this is unlikely to happen as uids:gids can make no sense on windows or on a device which doesn't support users (android) or even have them.

  4. AudriusButkevicius commented on Feb 5, 2015

    @AudriusButkevicius
    Member

    You can solve the same problem by running multiple instances though.

  5. facastagnini commented on Feb 5, 2015

    @facastagnini
    Contributor

    I am syncing the /Users directory between two mac, so I run syncthing as
    root. It runs great.

    I run into the annoyance of having uid out of sync a few times.

    As a reference, I use crashplan for backups. They preserve the uid:gid
    metadata and they do their best effort to preserve this attributes if you
    restore on a different platform.

    So adding this values to the syncthing db and trying to apply if the OS is
    homogeneous is doable.

    Unfortunately I am not a programmer, so I can't contribute a patch, but I
    think many people will greatly appreciate this feature.
    On Feb 5, 2015 3:25 AM, "Audrius Butkevicius" [email protected]
    wrote:

    You can solve the same problem by running multiple instances though.

    —
    Reply to this email directly or view it on GitHub
    #1329 (comment)
    .

  6. crosbymichael commented on Feb 5, 2015

    @crosbymichael
    Author

    @AudriusButkevicius I don't think windows or android is a good reason not to support this. This is the same idea as mtime and permissions.

    It would not matter if this is the default or not but a configurable option to support this would go along way for use cases when using this as a deployment and configuration system for servers and not just desktop use.

  7. api984 commented on Feb 5, 2015

    @api984

    if you sync between 2 linux servers or more with SAMBA on top can UID and GID be synched then?
    this would solve my problem because all samba instances would have same UID and GID on all locations for me for an example. if both systems are same linux then file ownership should be synched at least....
    if same but it should note that same UID and GID should be on both sides the same maybe?
    #id testuser
    uid 1000 gid 1000 on both locations....
    one could have 1000 and the other 501 ... which are not same user....

  8. AudriusButkevicius commented on Feb 5, 2015

    @AudriusButkevicius
    Member

    @crosbymichael feel free to make a pull request.
    Given it's implemented sensibly, I am pretty sure @calmh will consider merging it.

    Saying Windows and Android is not a good reason not to support is not true (at least what I believe in).
    Turning the code into an unmanageable mess just for the sake of it working on Unix, is a good enough reason for me. I just sadly cannot comprehend a sensible solution which works across the board.

    By the end of the day, we (or perhaps that is just my personal view) are trying to make a tool which works on multiple platforms, and we try to make sure that all features work on all platforms (more or less).

    I guess you could do uid:gid mapping based on the user account names across Unix and Windows, but then perhaps Unix people would expect it to work based on integers... Atleast that is the sort of behaviour I would expect syncing stuff from Unix to Windows... Not sure... gids don't even make sense on Windows.

  9. crosbymichael commented on Feb 5, 2015

    @crosbymichael
    Author

    @AudriusButkevicius lets try to keep the discussion professional and not suggest that someone's contribution for a feature that they care about would be "Turning the code into an unmanageable mess just for the sake of it working on Unix"

  10. AudriusButkevicius commented on Feb 5, 2015

    @AudriusButkevicius
    Member

    I am not saying that.

    What I am saying, is that the only solution which comes to my mind now, would make an unmanageable mess. I guess I am a bit of an advocate of Windows here, and I don't want Windows to be left out, hence why it would be a mess.

    As I said, given it's done sensibly, I am sure it could become a feature, even if an optional one.

  11. crosbymichael commented on Feb 5, 2015

    @crosbymichael
    Author

    Ok thanks. I opened this issue first instead of a PR so that this could be discussed with the maintainers. I know what it's like to have feature requests implemented in a PR without any discussion.

    I'm more than happy to look for an elegant solution for this. If it turns out to add more complexity than what it would be worth, then I have no problem closing this issue.

  12. AudriusButkevicius commented on Feb 5, 2015

    @AudriusButkevicius
    Member

    The boss is back in a few days, hence you can perhaps propose a potential solution to the problem which then could be discussed.

    There is some history of this available here (which might have some sensible ideas):
    https://discourse.syncthing.net/t/sync-file-ownership-and-permissions/143

    Though I feel you cannot get a way with some sort of optional remapping config

  13. added
    enhancement
    on Feb 5, 2015
  14. calmh commented on Feb 9, 2015

    @calmh
    Member

    Yeah, the relevant discussion is linked above. Solving this as described above (just copy uid+gid) isn't rocket science. Unfortunately it's also a half baked solution, as it doesn't work on non-Unixy systems, and will anyway not solve the other aspects that will pop up if this is implemented (sync by username and not uid, map some uids to others, etc)... As such, it would need to be really neat and unobtrusive to be worth it, in my opinion.

  15. 60 remaining items

  16. darkpixel commented on Jun 16, 2020

    @darkpixel

    Who can I sponsor and how much do they need?

  17. AudriusButkevicius commented on Jun 16, 2020

    @AudriusButkevicius
    Member

    kastelo.net I guess is the official "commercial" body behind syncthing, but I guess you can hire someone who knows a bit of Go and html to do this.

  18. aawsome commented on Jun 17, 2020

    @aawsome

    The reason this is open is because nobody needs this badly enough to work on it.

    Maybe I can tell about my story: I started implementing it (just minor change when syncing just uid and gid 1:1 and also with option to sync/not sync ownership). This however needed a DB schema update and also a rescan of all folders on all devices to update the DB.

    So I tested it and used it on my devices (all linux, all identical uid/gid) - works like a charm!

    Then I thought about the next steps to create a PR:

    • think about mapping
    • owners in Windows -> ugly!
    • how to make a database migration -> ugly!
    • change the Web-UI to let the users enter mappings, etc.
    • what to do if only ownership of a file is changed??

    So, finally I left with just using my patched version which is still working like a charm.. 😉

    Maybe if I find more time, I'll tackle the above mentioned points and prepare a PR.

    Or, if wished, I can simply share my modifications, maybe it is enough to opt in/opt out and someone can tackle the DB migration topic such that we'll only get an optional ownership syncing that only works for linux but doesn't harm anything on Windows.

  19. darkpixel commented on Jun 17, 2020

    @darkpixel

    @aawsome I'd love to get a copy of the patch and buy you a beer or something from an Amazon wishlist... I only need 1:1 uid/gid mapping on Linux since all my NAS boxen have identical IDs through winbind.

    Or if you want to try getting a PR submitted or something, I might be able to do some sort of sponsorship through my company or one of my clients that needs it.

  20. hiveai commented on Aug 29, 2020

    @hiveai

    @aawsome Could I get a copy of your changes please? I have 2 linux boxes I'd like to sync. I would value what you have even if the corner cases you outlined have not been addresses. Cheers!
    @darkpixel Did you ever get a copy of the uid/gid syncing patch? If so, could I get a copy?

  21. Striffly commented on Nov 24, 2020

    @Striffly

    You can find the patch here : https://github.com/aawsome/syncthing/tree/sync-owner
    I will soon test it on a linux multi-device configuration (if I reach the end of a custom build on docker), I will keep you informed!

  22. aawsome commented on Nov 25, 2020

    @aawsome

    Sorry for not answering. This is the patch I'm still using, however it is based on syncthing 1.5.0 and there have been quite some changes in the master code since then.
    I wanted to have a look how to rebase my patch but so far I didn't find the time for it. (and, honestly, after some time forgot about this topic).
    Appreciate any help with rebasing this!

  23. added a commit that references this issue on Jul 26, 2022
    b7862b0
  24. added this to the v1.21.0 milestone on Jul 26, 2022
  25. added a commit that references this issue on Jul 28, 2022
    da3fe7a
  26. added a commit that references this issue on Aug 4, 2022
    93b789c
  27. added
    frozen-due-to-age
    on Jul 26, 2023
  28. locked and limited conversation to collaborators on Jul 26, 2023
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

    enhancementfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions