summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-12 11:24:45 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-12 11:24:45 +0200
commite10893227a0acb239daaf0e8a7af3a4e650370ae (patch)
tree24375d3cec59246cf45bb04898365059c45a7b9b /python/vyos
parentcb76acad993760b2467667e1aa42d164db590ad8 (diff)
downloadvyos-1x-e10893227a0acb239daaf0e8a7af3a4e650370ae.tar.gz
vyos-1x-e10893227a0acb239daaf0e8a7af3a4e650370ae.zip
vyos.util: openvpn: migrate to chmod_600()
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/util.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 7308dd9b5..000b13025 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -196,6 +196,16 @@ def chown(path, user, group):
gid = getgrnam(group).gr_gid
os.chown(path, uid, gid)
+
+def chmod_600(path):
+ """ make file only read/writable by owner """
+ from stat import S_IRUSR, S_IWUSR
+
+ if os.path.exists(path):
+ bitmask = S_IRUSR | S_IWUSR
+ os.chmod(path, bitmask)
+
+
def chmod_750(path):
""" make file/directory only executable to user and group """
from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP