summaryrefslogtreecommitdiff
path: root/python/vyos/util.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-09-08 14:33:14 +0200
committerChristian Poessinger <christian@poessinger.com>2021-09-08 14:33:14 +0200
commit63fbd8c663c8c42ad178d6f0694f20bb98acf01a (patch)
tree46eaca0c3195bd7e4958a14a2c605a2b09d3fb22 /python/vyos/util.py
parent7623e37c918c65418d8dfc521f976bb91f0594c0 (diff)
downloadvyos-1x-63fbd8c663c8c42ad178d6f0694f20bb98acf01a.tar.gz
vyos-1x-63fbd8c663c8c42ad178d6f0694f20bb98acf01a.zip
openvpn: T3805: use vyos.util.write_file() to store certificates
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r--python/vyos/util.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index b41c5b346..849b27d3b 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -197,7 +197,7 @@ def read_file(fname, defaultonfailure=None):
return defaultonfailure
raise e
-def write_file(fname, data, defaultonfailure=None, user=None, group=None):
+def write_file(fname, data, defaultonfailure=None, user=None, group=None, mode=None):
"""
Write content of data to given fname, should defaultonfailure be not None,
it is returned on failure to read.
@@ -215,6 +215,7 @@ def write_file(fname, data, defaultonfailure=None, user=None, group=None):
with open(fname, 'w') as f:
bytes = f.write(data)
chown(fname, user, group)
+ chmod(fname, mode)
return bytes
except Exception as e:
if defaultonfailure is not None:
@@ -295,7 +296,6 @@ def makedir(path, user=None, group=None):
os.makedirs(path, mode=0o755)
chown(path, user, group)
-
def colon_separated_to_dict(data_string, uniquekeys=False):
""" Converts a string containing newline-separated entries
of colon-separated key-value pairs into a dict.