summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-08 22:30:21 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-08 22:30:23 +0200
commitd16348285127f638ae94aa91fdc94d6509d45af1 (patch)
treedba148aa54b7719c9ecae503a3cffe3abceebb55 /python
parent9123a03824f083035f130477bb7b030e559cc9ec (diff)
downloadvyos-1x-d16348285127f638ae94aa91fdc94d6509d45af1.tar.gz
vyos-1x-d16348285127f638ae94aa91fdc94d6509d45af1.zip
vyos.util: introduce chmod_750() for files/directories
Diffstat (limited to 'python')
-rw-r--r--python/vyos/util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index f1fb5ce27..385dc73df 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -103,6 +103,14 @@ def chown(path, user, group):
gid = getgrnam(group).gr_gid
os.chown(path, uid, gid)
+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
+
+ if os.path.exists(path):
+ bitmask = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP
+ os.chmod(path, bitmask)
+
def chmod_x(path):
""" make file executable """