Repository navigation
Description
What happened?
I am using Syncthing as a systemd service on a Raspberry Pi with Raspbian. I have set it up so it’s run by a syncthing user, but to keep access to all users in the group I’ve set the UMask parameter to 0002 in the [email protected] and for good measure in the .bash_rc, .bash_pofile and .profile files for that user.
Setting umask in the service file works correctly for synchronization, but Syncthing seems to ignore it when the files are “created” by Syncthing itself and not synchronized. I’ve noticed this happening both in .stfolder and subfiles (when a new synchronization folder is created) and the .stversions and subfolders (only directories, not files).
E.g.: Creating a new, still unshared folder through the web GUI:
pi@raspberrypi:/media/data/Sync $ ls TEST/ -ld
drwxrwsr-x 3 syncthing drive-users 4096 Aug 3 00:10 TEST/
pi@raspberrypi:/media/data/Sync $ ls TEST/ -lAR
TEST/:
total 4
drwxr-sr-x 2 syncthing drive-users 4096 Aug 3 00:10 .stfolder
TEST/.stfolder:
total 4
-rw-r--r-- 1 syncthing drive-users 117 Aug 3 00:10 syncthing-folder-ccaee1.txt
As for .stversions, I use “Simple” file versioning, and when I remove files the .stversions folder and any subfolders are created without group writing permissions, seemingly ignoring the umask. The files keep the writing permission, but without the folder writing permission I can’t delete them.
E.g.: Note that in this folder I have turned on “Ignore Permissions”. Also, in this case .stfolder has group write permission set manually.
pi@raspberrypi:/media/data/Sync/Linux-Documents $ ls -lAR
.:
total 8
drwxrwsr-x 2 syncthing drive-users 4096 Aug 2 23:54 'New Folder'
drwxrwsr-x 2 syncthing drive-users 4096 May 7 22:56 .stfolder
'./New Folder':
total 4
-rw-rw-r-- 1 syncthing drive-users 2 Aug 2 23:54 'Text File.txt'
./.stfolder:
total 0
pi@raspberrypi:/media/data/Sync/Linux-Documents $ ls -lAR
.:
total 8
drwxrwsr-x 2 syncthing drive-users 4096 May 7 22:56 .stfolder
drwxr-sr-x 3 syncthing drive-users 4096 Aug 2 23:55 .stversions
./.stfolder:
total 0
./.stversions:
total 4
drwxr-sr-x 2 syncthing drive-users 4096 Aug 2 23:55 'New Folder'
'./.stversions/New Folder':
total 4
-rw-rw-r-- 1 syncthing drive-users 2 Aug 2 23:54 'Text File~20240802-235507.txt'
pi@raspberrypi:/media/data/Sync/Linux-Documents $ rm .stversions/New\ Folder/Text\ File~20240802-235507.txt
rm: cannot remove '.stversions/New Folder/Text File~20240802-235507.txt': Permission denied
For more information, here is my service file:
$ cat /lib/systemd/system/[email protected]
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=man:syncthing(1)
After=network.target
[Service]
User=%i
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
UMask=0002
# Hardening
ProtectSystem=full
PrivateTmp=true
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
I have brought up this problem on the forum as well, where @calmh identified it as a bug:
You’re right, mkdirs in the versioner code use 0755 as the base permissions, so umask won’t help there (to get group write). Please feel free to file an issue on this, and perhaps a fix :slight_smile:
Probably the real fix would be to grab the permissions from the corresponding directory in the synced folder.
Syncthing version
syncthing v1.27.9 "Gold Grasshopper" (go1.22.4 linux-arm) [email protected] 2024-07-01 03:45:16 UTC [noupgrade]
Platform & operating system
Raspbian GNU/Linux 11 (bullseye)
Browser version
No response
Relevant log output
No response
Activity
thegasta commentedon Apr 5, 2025
Same problem in my debian 12 server.
Syncthing version seems to be indifferent, I'm still facing this issue on
1.29.4.I'm using the default systemd unit file shipped with syncthing.
Default folder settings:

From now on, all actions/commands are done with
syncthinguser.Syncthing data folder permissions and ACL (let's call it
datadir):(reminder: with
getfacl -tcapital letter means 'not effective')When creating a dir from the console (
datadir/test-from-console) or from the GUI (datadir/test-from-gui) everything works, in particular you can see that mask is kept asrwx.When creating the folder from another Syncthing device (
datadir/test-from-other-device, shared by default with the server), the mask is set to---.Same happens with (
datadir/test-from-other-device-no-ignore-perm, shared by default with the server), to do this test I disabledIgnore permissionsin default folder settings.In the same way I tried with files,
from-*.txtfile names indicate from where they were created.Below the details within the problematic folder:
Conclusion:
the problem seems to be related only to folders received (auto-accepted or not).
fix(versioner): fix perms of created folders (fixes syncthing#9626)
fix(versioner): fix perms of created folders (fixes syncthing#9626) (s…
Merge branch 'main' into v2
Merge branch 'v2' into jb/slog
Merge tag 'v1.29.7'