diff options
author | Christian Breunig <christian@breunig.cc> | 2024-06-23 08:21:43 +0200 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-06-24 17:31:29 +0000 |
commit | 316a50a5c7b2cf8f3853d61dc2e3c0a64d66fb20 (patch) | |
tree | c3ada8738927b6c21532740ae5e09c71b4c739b5 | |
parent | f1aa4c49b52e2be287a838560549689b9357a91d (diff) | |
download | vyos-1x-316a50a5c7b2cf8f3853d61dc2e3c0a64d66fb20.tar.gz vyos-1x-316a50a5c7b2cf8f3853d61dc2e3c0a64d66fb20.zip |
vyos.utils: T6504: add interactive op-/configure mode support for get_current_user()
(cherry picked from commit 710bb184045baa85897d589ffbc8af14b0fce629)
-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 |