diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-09-10 12:50:52 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-09-10 14:13:47 -0500 |
| commit | a0a14ea1ee38ce78f7433b3a93f7eea61c8163fc (patch) | |
| tree | 01f9d3e2b76d35ee2b459f14f5e2ffff96e7833f /src/vyconf_client_session.ml | |
| parent | 19d7e20f5cb7786f87e04a334e19415f18af6562 (diff) | |
| download | vyconf-a0a14ea1ee38ce78f7433b3a93f7eea61c8163fc.tar.gz vyconf-a0a14ea1ee38ce78f7433b3a93f7eea61c8163fc.zip | |
T7737: add user and sudo_user fields to session for use in commit
Add optional protobuf fields to convey environment variables USER and
SUDO_USER, as needed for some config_mode scripts. Add non-option fields
to the session record type, defaulting to the empty string.
Diffstat (limited to 'src/vyconf_client_session.ml')
| -rw-r--r-- | src/vyconf_client_session.ml | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/vyconf_client_session.ml b/src/vyconf_client_session.ml index 93068fa..035f191 100644 --- a/src/vyconf_client_session.ml +++ b/src/vyconf_client_session.ml @@ -34,7 +34,17 @@ let call_op ?(out_format="plain") ?(config_format="curly") socket token op path match o with | OpSetupSession -> let pid = Int32.of_int (Unix.getppid ()) in - let%lwt resp = Vyconf_client.setup_session client "vyconf_client_session" pid in + let user = + try Sys.getenv "USER" + with Not_found -> "" + in + let sudo_user = + try Sys.getenv "SUDO_USER" + with Not_found -> "" + in + let%lwt resp = + Vyconf_client.setup_session client "vyconf_client_session" sudo_user user pid + in begin match resp with | Ok c -> Vyconf_client.get_token c |
