summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-06-24 16:02:47 +0200
committerGitHub <noreply@github.com>2024-06-24 16:02:47 +0200
commit4cd052bddcecd0d24c72521564f9844f21ffc4ea (patch)
tree41ad074006937d93a7a7c602fccc6b74e46a58b7 /python
parent819b4a3556481ec516caca2731714ff69a57c2a5 (diff)
parent4c7719efa27d9d2966b70b924c90aa2c90022388 (diff)
downloadvyos-1x-4cd052bddcecd0d24c72521564f9844f21ffc4ea.tar.gz
vyos-1x-4cd052bddcecd0d24c72521564f9844f21ffc4ea.zip
Merge pull request #3701 from jestabro/configd-drop-env-sudo
configd: T6504: send sudo_user on session init and set env variable
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