From f70623bd8fbacc2a480acdf616641f0931d0f5e7 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 23 Jul 2018 11:09:13 +0200 Subject: Add a convenience function for getting the config owners group GID. --- python/vyos/defaults.py | 2 ++ python/vyos/util.py | 8 ++++++++ 2 files changed, 10 insertions(+) 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 . 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 -- cgit v1.2.3