diff --git a/plinth/modules/syncthing/data/usr/lib/sysusers.d/freedombox-syncthing.conf b/plinth/modules/syncthing/data/usr/lib/sysusers.d/freedombox-syncthing.conf new file mode 100644 index 000000000..a645f23b5 --- /dev/null +++ b/plinth/modules/syncthing/data/usr/lib/sysusers.d/freedombox-syncthing.conf @@ -0,0 +1,6 @@ +# Create system user and group to run syncthing as system daemon (as opposed to +# running in particular user's account). The user is created at boot or when +# 'systemd-sysusers freedombox-syncthing.conf' is run. To override this file as +# system administrator, create a file /etc/sysusers.d/freedombox-syncthing.conf +# or link it to /dev/null. +u! syncthing - "Syncthing file synchronization server" /var/lib/syncthing diff --git a/plinth/modules/syncthing/privileged.py b/plinth/modules/syncthing/privileged.py index 5359a09d6..0fa6bbd67 100644 --- a/plinth/modules/syncthing/privileged.py +++ b/plinth/modules/syncthing/privileged.py @@ -1,9 +1,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later """Configure Syncthing.""" -import grp import os -import pwd import shutil import time @@ -32,21 +30,8 @@ def augeas_load(conf_file): @privileged def setup(): """Perform post-install actions for Syncthing.""" - # Create syncthing group if needed. - try: - grp.getgrnam('syncthing') - except KeyError: - action_utils.run(['addgroup', '--system', 'syncthing'], check=True) - - # Create syncthing user if needed. - try: - pwd.getpwnam('syncthing') - except KeyError: - action_utils.run([ - 'adduser', '--system', '--ingroup', 'syncthing', '--home', - DATA_DIR, '--gecos', 'Syncthing file synchronization server', - 'syncthing' - ], check=True) + # Create a 'syncthing' system user and group, if needed. + action_utils.run(['systemd-sysusers', 'freedombox-syncthing.conf']) if not os.path.exists(DATA_DIR): os.makedirs(DATA_DIR, mode=0o750)