summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-06-24 19:34:05 +0200
committerGitHub <noreply@github.com>2024-06-24 19:34:05 +0200
commit0259c4337c80264d5818193a7023e5bd652b36af (patch)
tree7e8a8f89e20d89a67556a6140f24b474b3ad19ee /python
parent340e44c59663d2b94e7b1fddb05c49a3ad737938 (diff)
parent99c81fbe8fa0d6dd257c00a8e7fe1c5e1a15ca72 (diff)
downloadvyos-1x-0259c4337c80264d5818193a7023e5bd652b36af.tar.gz
vyos-1x-0259c4337c80264d5818193a7023e5bd652b36af.zip
Merge pull request #3719 from vyos/mergify/bp/circinus/pr-3701
configd: T6504: send sudo_user on session init and set env variable (backport #3701)
Diffstat (limited to 'python')
-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