From fbdf1fb8914a6b0ff3a64f4f359eaf3abd8be031 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 24 Sep 2025 18:27:08 -0500 Subject: T7709: use write_file_sync/atomic in vyos-save-config.py script Config save is provided by the helper script in both CLI and configsession (hence also in the http api). Use utilities write_file_sync and write_file_atomic, in accordance with permissions and location: If the target is in /opt/vyatta/etc/config or /config, use write_file_sync; if, moreover, the caller has permissions, use write_file_atomic. Otherwise, fall back to util write_file. --- python/vyos/component_version.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'python') diff --git a/python/vyos/component_version.py b/python/vyos/component_version.py index 136bd36e8..13fb8333f 100644 --- a/python/vyos/component_version.py +++ b/python/vyos/component_version.py @@ -209,6 +209,16 @@ def version_info_prune_component(x: VersionInfo, y: VersionInfo) -> VersionInfo: x.component = {k: v for k, v in x.component.items() if k in y.component} +def add_system_version_string(config_str: str = None) -> str: + """Wrap config string with system version and return string.""" + version_info = version_info_from_system() + if config_str is not None: + version_info.update_config_body(config_str) + version_info.update_footer() + + return version_info.write_string() + + def add_system_version(config_str: str = None, out_file: str = None): """Wrap config string with system version and write to out_file. -- cgit v1.2.3