From a0a14ea1ee38ce78f7433b3a93f7eea61c8163fc Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 10 Sep 2025 12:50:52 -0500 Subject: 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. --- src/vyconf_cli.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/vyconf_cli.ml') diff --git a/src/vyconf_cli.ml b/src/vyconf_cli.ml index 0d1535e..b2ee630 100644 --- a/src/vyconf_cli.ml +++ b/src/vyconf_cli.ml @@ -39,6 +39,14 @@ let in_cli_config_session () = let get_session () = let pid = Int32.of_int (Unix.getppid()) in + let user = + try Sys.getenv "USER" + with Not_found -> "" + in + let sudo_user = + try Sys.getenv "SUDO_USER" + with Not_found -> "" + in let socket = "/var/run/vyconfd.sock" in let config_format = config_format_of_string "curly" in let out_format = output_format_of_string "plain" in @@ -47,7 +55,7 @@ let get_session () = in let%lwt resp = session_of_pid client pid in match resp with - | Error _ -> setup_session client "vyconf_cli" pid + | Error _ -> setup_session client "vyconf_cli" sudo_user user pid | _ as c -> c |> Lwt.return let close_session () = -- cgit v1.2.3