summaryrefslogtreecommitdiff
path: root/src/system
diff options
context:
space:
mode:
Diffstat (limited to 'src/system')
-rw-r--r--src/system/grub_update.py4
-rwxr-xr-xsrc/system/kea-vrf-helper14
-rwxr-xr-xsrc/system/keepalived-fifo.py6
-rwxr-xr-xsrc/system/normalize-ip2
-rwxr-xr-xsrc/system/on-dhcp-event.sh4
-rwxr-xr-xsrc/system/on-dhcpv6-event.sh2
-rwxr-xr-xsrc/system/standalone_root_pw_reset8
-rwxr-xr-xsrc/system/sync-dhcp-lease-to-hosts.py8
-rw-r--r--src/system/sync-snmp-engine-boots.py84
-rwxr-xr-xsrc/system/uacctd_stop.py68
-rwxr-xr-xsrc/system/vyos-config-cloud-init.py2
-rwxr-xr-xsrc/system/vyos-event-handler.py4
-rwxr-xr-xsrc/system/vyos-system-update-check.py4
13 files changed, 120 insertions, 90 deletions
diff --git a/src/system/grub_update.py b/src/system/grub_update.py
index 5a0534195..0477cfa99 100644
--- a/src/system/grub_update.py
+++ b/src/system/grub_update.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io>
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This file is part of VyOS.
#
@@ -58,7 +58,7 @@ if __name__ == '__main__':
vyos_menuentries = compat.parse_menuentries(grub_cfg_main)
vyos_versions = compat.find_versions(vyos_menuentries)
unparsed_items = compat.filter_unparsed(grub_cfg_main)
- # compatibilty for raid installs
+ # compatibility for raid installs
search_root = compat.get_search_root(unparsed_items)
common_dict = {}
common_dict['search_root'] = search_root
diff --git a/src/system/kea-vrf-helper b/src/system/kea-vrf-helper
new file mode 100755
index 000000000..b4dd6a349
--- /dev/null
+++ b/src/system/kea-vrf-helper
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+VRF=$1
+shift
+
+export KEA_DHCP_DATA_DIR=/config/dhcp
+export KEA_HOOK_SCRIPTS_PATH=/usr/libexec/vyos/system
+export KEA_LOCKFILE_DIR=/run/lock/kea
+
+ip vrf exec $VRF \
+ setpriv --reuid=_kea --regid=_kea --init-groups \
+ --inh-caps +net_bind_service,+net_raw \
+ --ambient-caps +net_bind_service,+net_raw \
+ $@
diff --git a/src/system/keepalived-fifo.py b/src/system/keepalived-fifo.py
index 24733803a..c6c3fa9d0 100755
--- a/src/system/keepalived-fifo.py
+++ b/src/system/keepalived-fifo.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2020-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -55,7 +55,7 @@ class KeepalivedFifo:
self._config_load()
self.pipe_path = cmd_args.PIPE
- # create queue for messages and events for syncronization
+ # create queue for messages and events for synchronization
self.message_queue = Queue(maxsize=100)
self.stopme = threading.Event()
self.message_event = threading.Event()
@@ -111,7 +111,7 @@ class KeepalivedFifo:
# wait for a new message event from pipe_wait
self.message_event.wait()
try:
- # clear mesage event flag
+ # clear message event flag
self.message_event.clear()
# get all messages from queue and try to process them
while self.message_queue.empty() is not True:
diff --git a/src/system/normalize-ip b/src/system/normalize-ip
index 08f922a8e..9ef57e28a 100755
--- a/src/system/normalize-ip
+++ b/src/system/normalize-ip
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2018 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh
index 47c276270..492727b3e 100755
--- a/src/system/on-dhcp-event.sh
+++ b/src/system/on-dhcp-event.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -30,7 +30,7 @@ get_subnet_domain_name () {
from vyos.kea import kea_get_active_config
from vyos.utils.dict import dict_search_args
-config = kea_get_active_config('4')
+config = kea_get_active_config('4', '')
shared_networks = dict_search_args(config, 'arguments', f'Dhcp4', 'shared-networks')
found = False
diff --git a/src/system/on-dhcpv6-event.sh b/src/system/on-dhcpv6-event.sh
index cbb370999..93fd3ce81 100755
--- a/src/system/on-dhcpv6-event.sh
+++ b/src/system/on-dhcpv6-event.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/system/standalone_root_pw_reset b/src/system/standalone_root_pw_reset
index c82cea321..9a7da8e4c 100755
--- a/src/system/standalone_root_pw_reset
+++ b/src/system/standalone_root_pw_reset
@@ -54,7 +54,7 @@ change_password() {
# set the password for the user then store it in the config
# so the user is recreated on the next full system boot.
- local epwd=$(mkpasswd --method=sha-512 "$pwd1")
+ local epwd=$(mkpasswd --method=yescrypt "$pwd1")
# escape any slashes in resulting password
local eepwd=$(sed 's:/:\\/:g' <<< $epwd)
set_encrypted_password $user $eepwd $CF
@@ -64,7 +64,7 @@ change_password() {
dead() {
echo $*
echo
- echo "This tool can only recover missing admininistrator password."
+ echo "This tool can only recover missing administrator password."
echo "It is not a full system restore"
echo
echo -n "Hit return to reboot system: "
@@ -90,7 +90,7 @@ fi
echo -n "Do you wish to reset the admin password? (y or n) "
read -t $TIME_TO_WAIT response
if [ "$?" != "0" ]; then
- echo
+ echo
echo "Response not received in time."
echo "The admin password will not be reset."
echo "Rebooting in 5 seconds..."
@@ -127,7 +127,7 @@ fi
# Leftover from V3.0
if grep -q /opt/vyatta/etc/config /etc/fstab
-then
+then
echo "Mounting the config filesystem..."
mount /opt/vyatta/etc/config/
fi
diff --git a/src/system/sync-dhcp-lease-to-hosts.py b/src/system/sync-dhcp-lease-to-hosts.py
index 5c8b18faf..ea50b98a3 100755
--- a/src/system/sync-dhcp-lease-to-hosts.py
+++ b/src/system/sync-dhcp-lease-to-hosts.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2025 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -33,17 +33,17 @@ logs_handler = logging.StreamHandler()
logger.addHandler(logs_handler)
-def _get_all_server_leases(inet_suffix='4') -> list:
+def _get_all_server_leases(inet_suffix='4', vrf='') -> list:
mappings = []
try:
- active_config = kea_get_active_config(inet_suffix)
+ active_config = kea_get_active_config(inet_suffix, vrf)
except Exception:
raise vyos.opmode.DataUnavailable('Cannot fetch DHCP server configuration')
try:
pools = kea_get_dhcp_pools(active_config, inet_suffix)
mappings = kea_get_server_leases(
- active_config, inet_suffix, pools, state=[], origin=None
+ active_config, inet_suffix, vrf, pools, state=[], origin=None
)
except Exception:
raise vyos.opmode.DataUnavailable('Cannot fetch DHCP server leases')
diff --git a/src/system/sync-snmp-engine-boots.py b/src/system/sync-snmp-engine-boots.py
new file mode 100644
index 000000000..4213325c4
--- /dev/null
+++ b/src/system/sync-snmp-engine-boots.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) VyOS Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Called via systemd ExecStartPost= after snmpd starts.
+# Reads the live engineBoots value from /var/lib/snmp/snmpd.conf and
+# writes it to /config/snmp/engineboots.count only if the value differs.
+# Fixes T8538: ensures the persistent counter is always in sync with
+# what snmpd actually used, so the next restart increments correctly.
+
+import os
+import logging
+import contextlib
+
+import vyos.opmode
+
+from vyos.utils.file import read_file
+from vyos.utils.file import write_file
+
+SNMPD_CONF = '/var/lib/snmp/snmpd.conf'
+PERSIST_FILE = '/config/snmp/engineboots.count'
+
+# Configure logging
+logger = logging.getLogger(__name__)
+logger.addHandler(logging.StreamHandler())
+logger.setLevel(logging.DEBUG)
+
+
+def _read_snmpd_engine_boots() -> int | None:
+ """Return the engineBoots value from snmpd's persistent conf, or None."""
+
+ content = read_file(SNMPD_CONF, defaultonfailure='', sudo=True)
+ for line in content.splitlines():
+ if line.startswith('engineBoots'):
+ parts = line.split()
+ if len(parts) < 2:
+ continue
+ _, value, *_ = parts
+ with contextlib.suppress(ValueError):
+ return int(value)
+
+ return None
+
+
+def _read_persist_engine_boots() -> int | None:
+ """Return the currently saved engineBoots counter, or None."""
+
+ raw = read_file(PERSIST_FILE, defaultonfailure='')
+ with contextlib.suppress(ValueError):
+ return int(raw.strip())
+
+ return None
+
+
+if __name__ == '__main__':
+ snmpd_boots = _read_snmpd_engine_boots()
+ if snmpd_boots is None:
+ raise vyos.opmode.DataUnavailable(
+ f'Could not read engineBoots from {SNMPD_CONF}'
+ )
+
+ logger.debug(f'engineBoots from snmpd: {snmpd_boots}')
+
+ persist_boots = _read_persist_engine_boots()
+ logger.debug(f'engineBoots from persist file: {persist_boots}')
+
+ if persist_boots == snmpd_boots:
+ logger.debug('engineBoots already in sync, nothing to do')
+ else:
+ os.makedirs(os.path.dirname(PERSIST_FILE), exist_ok=True)
+ write_file(PERSIST_FILE, str(snmpd_boots))
+ logger.debug(f'engineBoots updated: {persist_boots} -> {snmpd_boots}')
diff --git a/src/system/uacctd_stop.py b/src/system/uacctd_stop.py
deleted file mode 100755
index a1b57335b..000000000
--- a/src/system/uacctd_stop.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright (C) 2023 VyOS maintainers and contributors
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 or later as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Control pmacct daemons in a tricky way.
-# Pmacct has signal processing in a main loop, together with packet
-# processing. Because of this, while it is waiting for packets, it cannot
-# handle the control signal. We need to start the systemctl command and then
-# send some packets to pmacct to wake it up
-
-from argparse import ArgumentParser
-from socket import socket, AF_INET, SOCK_DGRAM
-from sys import exit
-from time import sleep
-
-from psutil import Process
-
-
-def stop_process(pid: int, timeout: int) -> None:
- """Send a signal to uacctd
- and then send packets to special address predefined in a firewall
- to unlock main loop in uacctd and finish the process properly
-
- Args:
- pid (int): uacctd PID
- timeout (int): seconds to wait for a process end
- """
- # find a process
- uacctd = Process(pid)
- uacctd.terminate()
-
- # create a socket
- trigger = socket(AF_INET, SOCK_DGRAM)
-
- first_cycle: bool = True
- while uacctd.is_running() and timeout:
- print('sending a packet to uacctd...')
- trigger.sendto(b'WAKEUP', ('127.0.254.0', 1))
- # do not sleep during first attempt
- if not first_cycle:
- sleep(1)
- timeout -= 1
- first_cycle = False
-
-
-if __name__ == '__main__':
- parser = ArgumentParser()
- parser.add_argument('process_id',
- type=int,
- help='PID file of uacctd core process')
- parser.add_argument('timeout',
- type=int,
- help='time to wait for process end')
- args = parser.parse_args()
- stop_process(args.process_id, args.timeout)
- exit()
diff --git a/src/system/vyos-config-cloud-init.py b/src/system/vyos-config-cloud-init.py
index 0a6c1f9bc..1fdfb00db 100755
--- a/src/system/vyos-config-cloud-init.py
+++ b/src/system/vyos-config-cloud-init.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2023 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/system/vyos-event-handler.py b/src/system/vyos-event-handler.py
index dd2793046..bb1a42ee9 100755
--- a/src/system/vyos-event-handler.py
+++ b/src/system/vyos-event-handler.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2022-2023 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -134,7 +134,7 @@ if __name__ == '__main__':
)
exit(1)
- # Prepare for proper exitting
+ # Prepare for proper exiting
signal(SIGTERM, handle_signal)
signal(SIGINT, handle_signal)
diff --git a/src/system/vyos-system-update-check.py b/src/system/vyos-system-update-check.py
index c874f1e2c..b7d1fc7c5 100755
--- a/src/system/vyos-system-update-check.py
+++ b/src/system/vyos-system-update-check.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2022 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -60,7 +60,7 @@ if __name__ == '__main__':
remote_version = jmespath.search('[0].version', remote_data)
if local_version != remote_version and remote_version:
call(f'wall -n "Update available: {remote_version} \nUpdate URL: {url}"')
- # MOTD used in /run/motd.d/10-update
+ # MOTD used in /run/motd.d/10-vyos-update
motd_file.parent.mkdir(exist_ok=True)
motd_file.write_text(f'---\n'
f'Current version: {local_version}\n'