diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2025-04-23 09:24:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-23 09:24:00 +0300 |
commit | 16ed7fa2074b654fcb4570ebfe6e3e61a7aa7b1f (patch) | |
tree | de7df293310fcebfb2875025cc5ac6d4b2811fb2 | |
parent | a92733f62ff87f5a4609744be729cdc18a9633f4 (diff) | |
parent | b5406516ccd845eeb3b33529b31ca81a319f16d7 (diff) | |
download | vyos-1x-16ed7fa2074b654fcb4570ebfe6e3e61a7aa7b1f.tar.gz vyos-1x-16ed7fa2074b654fcb4570ebfe6e3e61a7aa7b1f.zip |
Merge pull request #4460 from c-po/systemd-syslog
syslog: T7367: ensure rsyslog is registered as default systemd syslog service
-rw-r--r-- | debian/vyos-1x.links | 1 | ||||
-rw-r--r-- | python/vyos/defaults.py | 2 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_system_syslog.py | 6 | ||||
-rwxr-xr-x | src/conf_mode/system_host-name.py | 2 | ||||
-rwxr-xr-x | src/conf_mode/system_syslog.py | 2 | ||||
-rwxr-xr-x | src/init/vyos-router | 8 |
6 files changed, 17 insertions, 4 deletions
diff --git a/debian/vyos-1x.links b/debian/vyos-1x.links index 7e21f294c..402c91306 100644 --- a/debian/vyos-1x.links +++ b/debian/vyos-1x.links @@ -1,3 +1,2 @@ /etc/netplug/linkup.d/vyos-python-helper /etc/netplug/linkdown.d/vyos-python-helper /usr/libexec/vyos/system/standalone_root_pw_reset /opt/vyatta/sbin/standalone_root_pw_reset -/lib/systemd/system/rsyslog.service /etc/systemd/system/syslog.service diff --git a/python/vyos/defaults.py b/python/vyos/defaults.py index 2b08ff68e..7efccded6 100644 --- a/python/vyos/defaults.py +++ b/python/vyos/defaults.py @@ -43,7 +43,7 @@ directories = { } systemd_services = { - 'rsyslog' : 'rsyslog.service', + 'syslog' : 'syslog.service', 'snmpd' : 'snmpd.service', } diff --git a/smoketest/scripts/cli/test_system_syslog.py b/smoketest/scripts/cli/test_system_syslog.py index 6eae3f19d..f3e1f65ea 100755 --- a/smoketest/scripts/cli/test_system_syslog.py +++ b/smoketest/scripts/cli/test_system_syslog.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import os import unittest from base_vyostest_shim import VyOSUnitTestSHIM @@ -59,6 +60,11 @@ class TestRSYSLOGService(VyOSUnitTestSHIM.TestCase): self.cli_delete(base_path) self.cli_commit() + # The default syslog implementation should make syslog.service a + # symlink to itself + self.assertEqual(os.readlink('/etc/systemd/system/syslog.service'), + '/lib/systemd/system/rsyslog.service') + # Check for running process self.assertFalse(process_named_running(PROCESS_NAME)) diff --git a/src/conf_mode/system_host-name.py b/src/conf_mode/system_host-name.py index fef034d1c..de4accda2 100755 --- a/src/conf_mode/system_host-name.py +++ b/src/conf_mode/system_host-name.py @@ -175,7 +175,7 @@ def apply(config): # Restart services that use the hostname if hostname_new != hostname_old: - tmp = systemd_services['rsyslog'] + tmp = systemd_services['syslog'] call(f'systemctl restart {tmp}') # If SNMP is running, restart it too diff --git a/src/conf_mode/system_syslog.py b/src/conf_mode/system_syslog.py index 414bd4b6b..bdab09f3c 100755 --- a/src/conf_mode/system_syslog.py +++ b/src/conf_mode/system_syslog.py @@ -35,7 +35,7 @@ rsyslog_conf = '/run/rsyslog/rsyslog.conf' logrotate_conf = '/etc/logrotate.d/vyos-rsyslog' systemd_socket = 'syslog.socket' -systemd_service = systemd_services['rsyslog'] +systemd_service = systemd_services['syslog'] def get_config(config=None): if config: diff --git a/src/init/vyos-router b/src/init/vyos-router index 081adf214..8584234b3 100755 --- a/src/init/vyos-router +++ b/src/init/vyos-router @@ -460,6 +460,14 @@ start () nfct helper add tns inet6 tcp nft --file /usr/share/vyos/vyos-firewall-init.conf || log_failure_msg "could not initiate firewall rules" + # Ensure rsyslog is the default syslog daemon + SYSTEMD_SYSLOG="/etc/systemd/system/syslog.service" + SYSTEMD_RSYSLOG="/lib/systemd/system/rsyslog.service" + if [ ! -L ${SYSTEMD_SYSLOG} ] || [ "$(readlink -f ${SYSTEMD_SYSLOG})" != "${SYSTEMD_RSYSLOG}" ]; then + ln -sf ${SYSTEMD_RSYSLOG} ${SYSTEMD_SYSLOG} + systemctl daemon-reload + fi + # As VyOS does not execute commands that are not present in the CLI we call # the script by hand to have a single source for the login banner and MOTD ${vyos_conf_scripts_dir}/system_syslog.py || log_failure_msg "could not reset syslog" |