diff options
author | Dmytro Aleksandrov <alkersan@gmail.com> | 2019-08-30 18:43:44 +0300 |
---|---|---|
committer | Dmytro Aleksandrov <alkersan@gmail.com> | 2019-08-30 18:43:44 +0300 |
commit | 76f498220c796a39a92ce3bed47c1cc5bac1a99d (patch) | |
tree | 09c0119bc7c6850570fd8f8f101a7c8e4cb7248f /python/vyos | |
parent | 24495a18b2ba39cd0c5b024dbe63f3e7df92e69c (diff) | |
download | vyos-1x-76f498220c796a39a92ce3bed47c1cc5bac1a99d.tar.gz vyos-1x-76f498220c796a39a92ce3bed47c1cc5bac1a99d.zip |
[op-mode] T1621 rewrite misc commands to python/xml syntax
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/util.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index 88bb0c8f4..67a602f7a 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -15,6 +15,7 @@ import os import re +import getpass import grp import time import subprocess @@ -191,3 +192,10 @@ def ask_yes_no(question, default=False) -> bool: return False else: sys.stdout.write("Please respond with yes/y or no/n\n") + + +def is_admin() -> bool: + """Look if current user is in sudo group""" + current_user = getpass.getuser() + (_, _, _, admin_group_members) = grp.getgrnam('sudo') + return current_user in admin_group_members |