2 linux systems , permissions are not sync , I put permissions manually to rw-r–r-- on the two sides , but when I modify one side , the modified side stay OK , but the second side becomes rwxrwx— after sync.
Assuming that “Ignore Permissions” isn’t enabled for the Syncthing folder on the receiving side…
Check the umask settings on the receiving side, both for the user running Syncthing and the method used to launch Syncthing.
Here’s a quick example where I modify the umask in a shell session from the system default of 0002
to 0022
then finally to 0077
. Each time I change the umask, I create a new file to show what happens to the permissions:
user@linux:~/tmp$ umask
0002
user@linux:~/tmp$ touch A
user@linux:~/tmp$ ls -l
total 0
-rw-rw-r-- 1 user user 0 Sep 16 14:13 A
user@linux:~/tmp$ umask 0022
user@linux:~/tmp$ touch B
user@linux:~/tmp$ ls -l
total 0
-rw-rw-r-- 1 user user 0 Sep 16 14:13 A
-rw-r--r-- 1 user user 0 Sep 16 14:13 B
user@linux:~/tmp$ umask 0077
user@linux:~/tmp$ touch C
user@linux:~/tmp$ ls -l
total 0
-rw-rw-r-- 1 user user 0 Sep 16 14:13 A
-rw-r--r-- 1 user user 0 Sep 16 14:13 B
-rw------- 1 user user 0 Sep 16 14:14 C
user@linux:~/tmp$
Umask is when you create a new file, here I sync the file,with cp or rsync permissions stays the same , syncthing change the permissions and it is not ok.
Before sync :
Side a : rw-r–r–
Side b : rw-r–r–
Modify side a
Side a : rw-r–r–
After sync :
Side b : rwxrwx— after sync
It’s true that a umask applies to newly created files, but consider the following quote from Syncthing’s Understanding Synchronization page:
Temporary FilesSyncthing never writes directly to a destination file. Instead all changes are made to a temporary copy which is then moved in place over the old version. If an error occurs during the copying or syncing, such as a necessary block not being available, the temporary file is kept around for up to a day. This is to avoid needlessly requesting data over the network.
So from the perspective of the OS, all files copied by Syncthing from one device to another device are newly created files.
cp
only applies to files accessible from the same host, so usually the same umask is in effect.
Try the following test:
touch A ; umask 0777 ; cp A B ; ls -l
File B
will end up with different permissions than file A
.
Same thing happens with rsync
unless the option --perms
or -p
is used.
To visually confirm it, stat
the file on Side b
before and after the file syncs up with a change to Side a
. The inode number will be different – meaning that it’s a different file that happens to have the same pathname as the previous version.
Anyhow, Syncthing copies permissions by default. Show config, maybe what filesystem and mount options that are in use.
to calmh : Ok , the problem is not with syncthing , and I checked more and syncthing copies permissions (I have to check later) to gadget : your answers are ok but are waste of time for you and for me
No problem, hope you find the solution to your permission issue.