diff options
author | Christian Breunig <christian@breunig.cc> | 2024-06-23 08:21:43 +0200 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-06-23 08:21:43 +0200 |
commit | 710bb184045baa85897d589ffbc8af14b0fce629 (patch) | |
tree | 2dd101aa06eb2fafbadccdafe4d761c8c0b04f17 /python/vyos/utils | |
parent | 7016f840f1193399f6ac59fab7faa721049229e8 (diff) | |
download | vyos-1x-710bb184045baa85897d589ffbc8af14b0fce629.tar.gz vyos-1x-710bb184045baa85897d589ffbc8af14b0fce629.zip |
vyos.utils: T6504: add interactive op-/configure mode support for get_current_user()
Diffstat (limited to 'python/vyos/utils')
-rw-r--r-- | python/vyos/utils/auth.py | 4 |
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 |