From ecf1e3d499d8a825bb675e11c07bbc7b0981c431 Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Sun, 5 Apr 2020 22:10:09 +0100 Subject: util: T2226: rewrite util to use cmd --- python/vyos/util.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/vyos/util.py b/python/vyos/util.py index f63ed057e..e0030d1bd 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -261,12 +261,11 @@ def commit_in_progress(): # Since this will be used in scripts that modify the config outside of the CLI # framework, those knowingly have root permissions. # For everything else, we add a safeguard. - from subprocess import check_output from psutil import process_iter, NoSuchProcess from vyos.defaults import commit_lock - id = check_output(['/usr/bin/id', '-u']).decode().strip() - if id != '0': + idu = cmd('/usr/bin/id -u') + if idu != '0': raise OSError("This functions needs root permissions to return correct results") for proc in process_iter(): -- cgit v1.2.3