summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-09-05 13:47:10 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-09-08 08:40:32 -0500
commitc1a078e5e4dd5980715985958b494eca08651893 (patch)
treef4a44d494890ba7015a2945a4db496dd7ad4d978
parent667e968568564811a7dc09049f7a1e38cb879e91 (diff)
downloadvyos-1x-c1a078e5e4dd5980715985958b494eca08651893.tar.gz
vyos-1x-c1a078e5e4dd5980715985958b494eca08651893.zip
config-mgmt: T5353: correct update check during boot
(cherry picked from commit 730e744931e4ccc1f214d3e5bff0e6a2e589fd50)
-rw-r--r--python/vyos/config_mgmt.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/python/vyos/config_mgmt.py b/python/vyos/config_mgmt.py
index 996475eb8..9fad000e8 100644
--- a/python/vyos/config_mgmt.py
+++ b/python/vyos/config_mgmt.py
@@ -31,6 +31,7 @@ from vyos.configtree import ConfigTree, ConfigTreeError, show_diff
from vyos.defaults import directories
from vyos.version import get_full_version_data
from vyos.utils.io import ask_yes_no
+from vyos.utils.boot import boot_configuration_complete
from vyos.utils.process import is_systemd_service_active
from vyos.utils.process import rc_cmd
@@ -474,22 +475,26 @@ Proceed ?'''
conf_file.chmod(0o644)
def _archive_active_config(self) -> bool:
+ use_tmp = (boot_configuration_complete() or not
+ os.path.isfile(archive_config_file))
mask = os.umask(0o113)
- ext = os.getpid()
- tmp_save = f'/tmp/config.boot.{ext}'
- save_config(tmp_save)
+ if use_tmp:
+ ext = os.getpid()
+ cmp_saved = f'/tmp/config.boot.{ext}'
+ save_config(cmp_saved)
+ else:
+ cmp_saved = config_file
try:
- if cmp(tmp_save, archive_config_file, shallow=False):
- # this will be the case on boot, as well as certain
- # re-initialiation instances after delete/set
- os.unlink(tmp_save)
+ if cmp(cmp_saved, archive_config_file, shallow=False):
+ if use_tmp: os.unlink(cmp_saved)
+ os.umask(mask)
return False
except FileNotFoundError:
pass
- rc, out = rc_cmd(f'sudo mv {tmp_save} {archive_config_file}')
+ rc, out = rc_cmd(f'sudo mv {cmp_saved} {archive_config_file}')
os.umask(mask)
if rc != 0: