diff options
| author | Christian Poessinger <christian@poessinger.com> | 2019-09-01 21:10:45 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-01 21:10:45 +0200 | 
| commit | b25d8e9787ee5243feb6b08098bbba958fe22d8c (patch) | |
| tree | cf0821334cd982e6c025ff820edcbcb363871713 /python | |
| parent | 308886a3fc28aa7772c14452185fb06531ba9dfd (diff) | |
| parent | 76f498220c796a39a92ce3bed47c1cc5bac1a99d (diff) | |
| download | vyos-1x-b25d8e9787ee5243feb6b08098bbba958fe22d8c.tar.gz vyos-1x-b25d8e9787ee5243feb6b08098bbba958fe22d8c.zip | |
Merge pull request #119 from alkersan/T1621_misc_rewrites
[op-mode] T1621 rewrite misc commands to python/xml syntax
Diffstat (limited to 'python')
| -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 | 
