From 563b50f5b0ae249e92c33ed4da7756a0805c7125 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 10 Sep 2025 20:44:52 -0500 Subject: 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. --- python/vyos/vyconf_session.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'python') 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 -- cgit v1.2.3