From 6b6065b56287cb7436a079761f6e3ffc6c945d98 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Mon, 4 Mar 2024 17:11:47 +0000 Subject: T6088: Fix saving confiugration and replacing fsync with sync The `fsync` function does not work correctly and if we force reset the system (sysrq-trigger to emulate power cut) or do "power cut" on the baremetal server immediately after saving, we will get the corrupted configuration file `/config/config.boot` Using `sync` fixes this bug --- scripts/vyatta-save-config.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl index 9f1ec5c..2a607f2 100755 --- a/scripts/vyatta-save-config.pl +++ b/scripts/vyatta-save-config.pl @@ -22,7 +22,7 @@ use strict; use lib "/opt/vyatta/share/perl5"; use Vyatta::ConfigOutput; -use File::Sync qw(fsync); +use File::Sync qw(sync); use FileHandle; use IO::Prompt; use Vyatta::Misc qw(get_short_config_path); @@ -118,8 +118,8 @@ close($show_fd); print $version_str; select STDOUT; -fsync $save; close $save; +sync(); if ($mode eq 'url') { system("python3 -c 'from vyos.remote import upload; upload(\"$url_tmp_file\", \"$save_file\")'"); -- cgit v1.2.3