From 710bb184045baa85897d589ffbc8af14b0fce629 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sun, 23 Jun 2024 08:21:43 +0200 Subject: vyos.utils: T6504: add interactive op-/configure mode support for get_current_user() --- python/vyos/utils/auth.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'python') diff --git a/python/vyos/utils/auth.py b/python/vyos/utils/auth.py index d014f756f..a0b3e1cae 100644 --- a/python/vyos/utils/auth.py +++ b/python/vyos/utils/auth.py @@ -42,6 +42,10 @@ def split_ssh_public_key(key_string, defaultname=""): def get_current_user() -> str: import os current_user = 'nobody' + # During CLI "owner" script execution we use SUDO_USER if 'SUDO_USER' in os.environ: current_user = os.environ['SUDO_USER'] + # During op-mode or config-mode interactive CLI we use USER + elif 'USER' in os.environ: + current_user = os.environ['USER'] return current_user -- cgit v1.2.3