summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2021-08-21 07:08:30 -0500
committerJohn Estabrook <jestabro@vyos.io>2021-08-21 07:18:38 -0500
commiteccdf2ad5340606b256ce8debe68b965c36e333c (patch)
tree683163845e4e62d478f733d89b21a4b396a9d13a
parentc9cfc599615cdcd54195ee45f71b78d507a8407d (diff)
downloadvyos-1x-eccdf2ad5340606b256ce8debe68b965c36e333c.tar.gz
vyos-1x-eccdf2ad5340606b256ce8debe68b965c36e333c.zip
T1950: fix permissions on component-versions.json file
(cherry picked from commit 6bd780887c0e13dc9272ec499ebc6f01cfaf7ea6)
-rw-r--r--python/vyos/migrator.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/python/vyos/migrator.py b/python/vyos/migrator.py
index 37c4e5902..4574bb6d1 100644
--- a/python/vyos/migrator.py
+++ b/python/vyos/migrator.py
@@ -170,9 +170,15 @@ class Migrator(object):
"""
Write component versions to a json file
"""
+ mask = os.umask(0o113)
version_file = vyos.defaults.component_version_json
- with open(version_file, 'w') as f:
- f.write(json.dumps(component_versions, indent=2, sort_keys=True))
+ try:
+ with open(version_file, 'w') as f:
+ f.write(json.dumps(component_versions, indent=2, sort_keys=True))
+ except OSError:
+ pass
+ finally:
+ os.umask(mask)
def run(self):
"""