syncthing: Hide unnecessary security warning

- Hide the warning 'The Syncthing admin interface is configured to allow
remote access without a password. ... '. This warning is unnecessary because
we are using authentication through Apache.

- Hide the usage reporting notification by declining reporting, if the user
has not made a choice yet.

- Call add_user_to_share_group() in setup() before starting syncthing to
avoid another syncthing daemon restart.

- Add a functional test for hidden notification messages.

- Functional tests: Improve the method to check if the javascript
loading process is complete.

Closes #1581

Tests performed:
- The syncthing app is installed successfully on Debian testing
- All syncthing tests pass on Debian stable and testing

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa authored and Sunil Mohan Adapa committed 2021-01-21 16:34:51 -08:00
1 parent f892843ba5
commit 77face68b0
4 files changed
+86 -31

No files matched your search

+55 -7
View File
@@ -10,6 +10,14 @@ import os
import pwd
import shutil
import subprocess
import time
import augeas
from plinth import action_utils
DATA_DIR = '/var/lib/syncthing'
CONF_FILE = DATA_DIR + '/.config/syncthing/config.xml'
def parse_arguments():
@@ -19,14 +27,23 @@ def parse_arguments():
subparsers.add_parser('setup', help='Setup Syncthing')
subparsers.add_parser('setup-config', help='Setup Syncthing configuration')
subparsers.required = True
return parser.parse_args()
def augeas_load():
"""Initialize Augeas."""
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug.add_transform('Xml.lns', CONF_FILE)
aug.load()
return aug
def subcommand_setup(_):
"""Actions to be performed before installing Syncthing"""
data_dir = '/var/lib/syncthing'
# Create syncthing group if needed.
try:
grp.getgrnam('syncthing')
@@ -39,13 +56,44 @@ def subcommand_setup(_):
except KeyError:
subprocess.run([
'adduser', '--system', '--ingroup', 'syncthing', '--home',
'/var/lib/syncthing', '--gecos',
'Syncthing file synchronization server', 'syncthing'
DATA_DIR, '--gecos', 'Syncthing file synchronization server',
'syncthing'
], check=True)
if not os.path.exists(data_dir):
os.makedirs(data_dir, mode=0o750)
shutil.chown(data_dir, user='syncthing', group='syncthing')
if not os.path.exists(DATA_DIR):
os.makedirs(DATA_DIR, mode=0o750)
shutil.chown(DATA_DIR, user='syncthing', group='syncthing')
def subcommand_setup_config(_):
"""Make configuration changes."""
# wait until the configuration file is created by the syncthing daemon
timeout = 300
while timeout > 0:
if os.path.exists(CONF_FILE):
break
timeout = timeout - 1
time.sleep(1)
aug = augeas_load()
# disable authentication missing notification as FreedomBox itself
# provides authentication
auth_conf = ('/configuration/options/unackedNotificationID'
'[#text="authenticationUserAndPassword"]')
conf_changed = bool(aug.remove('/files' + CONF_FILE + auth_conf))
# disable usage reporting notification by declining reporting
# if the user has not made a choice yet
usage_conf = '/configuration/options/urAccepted/#text'
if aug.get('/files' + CONF_FILE + usage_conf) == '0':
aug.set('/files' + CONF_FILE + usage_conf, '-1')
conf_changed = True
aug.save()
if conf_changed:
action_utils.service_try_restart('syncthing@syncthing')
def main():