Syncthing on samba and hidden DOS bit issue

Setup

  • A Syncthing server (v1.18.6 “Fermium Flea” (go1.17.6 linux-amd64))on Red Hat Enterprise Linux release 8.5 (Ootpa) server with a shared folder on a mounted samba share.
  • syncthingv1.18.3 (google play) on android syncing to the server

Result

All files have DOS hidden flag en archive flag enabled. Causing them to appear invisible when mounting the same samba share on a windows computer. Manually writing a file on the server to the samba share does not set the hidden flag. To be clear, none of the files are starting with a dot.

Expected

synced files should not have the DOS hidden flag, what is causing this

Related github Syncthing sets hidden DOS bit · Issue #8142 · syncthing/syncthing · GitHub

Echoing myself from the issue, the code we have for setting and unsetting the hidden bit when compiled for a Unixy OS is a no-op.

I think the blame lies elsewhere. What Syncthing does though is create every file as something like .filename.txt.syncthing.tmp and then rename it to filename.txt or whatever. Perhaps something else is interacting oddly with the file being created as a dotfile.

It seems like this may be a Samba feature from just Googling the issue:

OK, so it seems that samba additionally sets the H attribute in the stored DOS attributes when creating a dot file and having set "hide dot files = yes".

([Samba] access denied with "hide dot files = Yes")

If it does that, and forgets to clear it when the file is renamed, that would result in what you see.

I just tested this.

I have the hide dot files = yes enabled on the samba server

On the other server on the mounted samba share I did some tests where I look at the results on a windows with the same share mounted

  1. touch .file3 ( OK hidden DOS flag enabled )
  2. mv -v .file3 file3 ( OK hidden DOS flag disabled )
  3. mv -v file3 .file3 ( OK hidden DOS flag enabled )
  4. mv -v .file3 file3 ( FAIL hidden DOS flag enabled, should be disabled )

Next test

  1. touch .file4.Syncthing.tmp ( OK hidden DOS flag enabled )
  2. mv -v .file4.Syncthing.tmp file4 ( OK hidden DOS flag disabled )
  3. mv -v file4 .file4.Syncthing.tmp ( OK hidden DOS flag enabled )
  4. mv -v .file4.Syncthing.tmp file4 ( FAIL hidden DOS flag enabled, should be disabled )

Notice how the action 2. and 4. are the same, this seems to be a bug in samba then

Thanks for pointing me in the right direction.

1 Like

We do a lot of file operations in quick succession when finishing up a file (writing, closing, syncing, setting permissions, setting modtime, renaming, syncing the parent directory, etc). All quite legal and proper, but I could see how that could tickle some timing or cache related issue somewhere in the chain.

I reported bug here: https://bugzilla.redhat.com/show_bug.cgi?id=2046515

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.