summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-07-23 11:09:13 +0200
committerDaniil Baturin <daniil@baturin.org>2018-07-23 11:09:55 +0200
commitf70623bd8fbacc2a480acdf616641f0931d0f5e7 (patch)
treee3dccf70003f5e31e2a1c0b6cafbcc6deb22bf70 /python
parentb7d7af33789d5f98ec27f326668a6b16ff228678 (diff)
downloadvyos-1x-f70623bd8fbacc2a480acdf616641f0931d0f5e7.tar.gz
vyos-1x-f70623bd8fbacc2a480acdf616641f0931d0f5e7.zip
Add a convenience function for getting the config owners group GID.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/defaults.py2
-rw-r--r--python/vyos/util.py8
2 files changed, 10 insertions, 0 deletions
diff --git a/python/vyos/defaults.py b/python/vyos/defaults.py
index ac831c176..36185f16a 100644
--- a/python/vyos/defaults.py
+++ b/python/vyos/defaults.py
@@ -17,3 +17,5 @@
directories = {
"data": "/usr/share/vyos/"
}
+
+cfg_group = 'vyattacfg'
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 3c454ed4a..1419e490b 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -14,8 +14,12 @@
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
import re
+import grp
import psutil
+import vyos.defaults
+
+
def read_file(path):
""" Read a file to string """
with open(path, 'r') as f:
@@ -114,3 +118,7 @@ def seconds_to_human(s, separator=""):
result = "{0}{1}{2}s".format(result, separator, seconds)
return result
+
+def get_cfg_group_id():
+ group_data = grp.getgrnam(vyos.defaults.cfg_group)
+ return group_data.gr_gid