From e10893227a0acb239daaf0e8a7af3a4e650370ae Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 12 Apr 2020 11:24:45 +0200 Subject: vyos.util: openvpn: migrate to chmod_600() --- python/vyos/util.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'python') 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 -- cgit v1.2.3