diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2024-03-04 17:11:47 +0000 |
---|---|---|
committer | Viacheslav Hletenko <v.gletenko@vyos.io> | 2024-03-04 17:11:47 +0000 |
commit | 6b6065b56287cb7436a079761f6e3ffc6c945d98 (patch) | |
tree | f1c65f7998a2fd8604bc2e91524c1303c72c5b2e | |
parent | 0cadf4e24f077b08e7a429b080d4329c3f9c61e0 (diff) | |
download | vyatta-cfg-6b6065b56287cb7436a079761f6e3ffc6c945d98.tar.gz vyatta-cfg-6b6065b56287cb7436a079761f6e3ffc6c945d98.zip |
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
-rwxr-xr-x | scripts/vyatta-save-config.pl | 4 |
1 files changed, 2 insertions, 2 deletions
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\")'"); |