From 2d30312b103bbed4a67a3db2154cb49bc2fc9adf Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 14 Feb 2021 19:35:09 -0800 Subject: [PATCH] config: Disable rsyslog and syslog forwarding Helps: #664. Currently, logs are written to disk twice, once by journald and once by rsyslog. rsyslog may log to multiple locations depending on the type of the log. To reduce disk I/O, disable rsyslog and rely solely on systemd journal. Place the code in config module as there is no better place for it currently without creating a new module. Can be sorted later. The following files under /var/log/ are no longer populated on FreedomBox. They will be rotated away over a few days. Use journalctl instead to view the messages: - syslog - messages* - auth.log* - debug* - daemon.log - kern.log - lpr.log - mail.log - mail.info - mail.warn - mail.err - user.log Tests performed: - On a machine with rsyslog running, run ./setup.py install and start FreedomBox service. This triggers the config app's setup. rsyslog is disabled and masked. systemd-journald is restarted. - Even when rsyslog is unmaked and enabled manually, systemd journald does not forward message to syslog anymore. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/modules/config/__init__.py | 20 +++++++++++++++---- .../systemd/journald.conf.d/freedombox.conf | 12 +++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 plinth/modules/config/data/usr/lib/systemd/journald.conf.d/freedombox.conf diff --git a/plinth/modules/config/__init__.py b/plinth/modules/config/__init__.py index 00d0dffd6..7a55a1c0b 100644 --- a/plinth/modules/config/__init__.py +++ b/plinth/modules/config/__init__.py @@ -12,15 +12,17 @@ from django.utils.translation import ugettext_lazy as _ from plinth import actions from plinth import app as app_module from plinth import frontpage, menu -from plinth.modules.apache import (user_of_uws_url, uws_url_of_user, - get_users_with_website) +from plinth.modules.apache import (get_users_with_website, user_of_uws_url, + uws_url_of_user) from plinth.modules.names.components import DomainType from plinth.signals import domain_added -version = 2 +version = 3 is_essential = True +managed_services = ['systemd-journald', 'rsyslog'] + _description = [ _('Here you can set some general configuration options ' 'like hostname, domain name, webserver home page etc.') @@ -161,7 +163,7 @@ def change_home_page(shortcut_id): """ url = _home_page_scid2url(shortcut_id) if url is None: - url = '/plinth/' # fall back to default url if scid is unknown. + url = '/plinth/' # fall back to default url if scid is unknown. # URL may be a reverse_lazy() proxy actions.superuser_run('config', ['set-home-page', str(url)]) @@ -183,6 +185,16 @@ def setup(helper, old_version=None): """Install and configure the module.""" _migrate_home_page_config() + # systemd-journald is socket activated, it may not be running and it does + # not support reload. + actions.superuser_run('service', ['try-restart', 'systemd-journald']) + # rsyslog when enabled, is activated by syslog.socket (shipped by systemd). + # See: https://www.freedesktop.org/wiki/Software/systemd/syslog/ . + actions.superuser_run('service', ['disable', 'rsyslog']) + # Ensure that rsyslog is not started by something else as it is installed + # by default on Debian systems. + actions.superuser_run('service', ['mask', 'rsyslog']) + def _migrate_home_page_config(): """Move the home page configuration to an external file.""" diff --git a/plinth/modules/config/data/usr/lib/systemd/journald.conf.d/freedombox.conf b/plinth/modules/config/data/usr/lib/systemd/journald.conf.d/freedombox.conf new file mode 100644 index 000000000..f5820257b --- /dev/null +++ b/plinth/modules/config/data/usr/lib/systemd/journald.conf.d/freedombox.conf @@ -0,0 +1,12 @@ +[Journal] +# Upstream systemd project disables forwarding to syslog by default as it is +# only needed by syslog daemons that don't get their feed from systemd journal. +# See: +# https://www.freedesktop.org/software/systemd/man/journald.conf.html#ForwardToSyslog= +# . Debian re-enables this by default due to support lacking in some syslog +# daemons in its repository. See: +# https://salsa.debian.org/systemd-team/systemd/-/blob/c39ab3efdc9c1b69f333c112112a68fb712cee27/debian/patches/debian/Re-enable-journal-forwarding-to-syslog.patch +# . In FreedomBox, rsyslog and other syslog daemons are not necessary and are +# burden on disk I/O. All the necessary log data can be obtained from systemd +# journal. Disable forwarding to syslog. +ForwardToSyslog=no