summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-06-23 08:21:43 +0200
committerChristian Breunig <christian@breunig.cc>2024-06-23 08:21:43 +0200
commit710bb184045baa85897d589ffbc8af14b0fce629 (patch)
tree2dd101aa06eb2fafbadccdafe4d761c8c0b04f17
parent7016f840f1193399f6ac59fab7faa721049229e8 (diff)
downloadvyos-1x-710bb184045baa85897d589ffbc8af14b0fce629.tar.gz
vyos-1x-710bb184045baa85897d589ffbc8af14b0fce629.zip
vyos.utils: T6504: add interactive op-/configure mode support for get_current_user()
-rw-r--r--python/vyos/utils/auth.py4
1 files changed, 4 insertions, 0 deletions
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