summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-09-10 20:44:52 -0500
committerJohn Estabrook <jestabro@vyos.io>2025-09-18 07:43:20 -0500
commit563b50f5b0ae249e92c33ed4da7756a0805c7125 (patch)
treea57d09fd9f65a0b97ce125bda3409a75f315fddc /python
parenteeef31aecba3ccd1971a02d725569392060ffa7c (diff)
downloadvyos-1x-563b50f5b0ae249e92c33ed4da7756a0805c7125.tar.gz
vyos-1x-563b50f5b0ae249e92c33ed4da7756a0805c7125.zip
T7737: update init data as needed for vyos-commitd environment
Provide env vars of config session for injection into the commitd environment. This information is needed for certain config-mode scripts, namely those that reference the module vyos.utils.auth.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/vyconf_session.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/python/vyos/vyconf_session.py b/python/vyos/vyconf_session.py
index 4b79073ab..1f7f37663 100644
--- a/python/vyos/vyconf_session.py
+++ b/python/vyos/vyconf_session.py
@@ -41,18 +41,24 @@ class VyconfSession:
self, token: str = None, pid: int = None, on_error: Type[Exception] = None
):
self.pid = os.getpid() if pid is None else pid
+ self.sudo_user = os.environ.get('SUDO_USER', None)
+ self.user = os.environ.get('USER', None)
+
if token is None:
# CLI applications with arg pid=getppid() allow coordination
# with the ambient session; other uses (such as ConfigSession)
# may default to self pid
out = vyconf_client.send_request('session_of_pid', client_pid=self.pid)
if out.output is None:
- out = vyconf_client.send_request('setup_session', client_pid=self.pid)
+ out = vyconf_client.send_request(
+ 'setup_session',
+ client_pid=self.pid,
+ client_sudo_user=self.sudo_user,
+ client_user=self.user,
+ )
self.__token = out.output
else:
- out = vyconf_client.send_request(
- 'session_update_pid', token=token, client_pid=self.pid
- )
+ out = vyconf_client.send_request('session_exists', token=token)
if out.status:
raise ValueError(f'No existing session for token: {token}')
self.__token = token