From 9731ffcfb4159f986fc2c9966f59d80a0e460e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 25 Nov 2020 11:29:00 +0100 Subject: [PATCH 1/2] RExec.connect: handle protocol version negotiation --- lib/rExec.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/rExec.ml b/lib/rExec.ml index 66054c5..740e2d5 100644 --- a/lib/rExec.ml +++ b/lib/rExec.ml @@ -376,6 +376,11 @@ let connect ~domid () = QV.server ~domid ~port:vchan_base_port () >>= fun t -> let t = { t; clients = Hashtbl.create 4; counter = 0; } in send_hello t.t >>= fun () -> - recv_hello t.t >>= fun version -> - Log.info (fun f -> f "client connected, using protocol version %ld" version); - return t + recv_hello t.t >>= function + | version when version < 2l -> fail (error "Unsupported qrexec version %ld" version) + | version -> + if version > 2l + then Log.debug (fun f -> f "Other end wants to use newer protocol %lu, \ + continuing with version 2" version); + Log.info (fun f -> f "client connected, using protocol version 2"); + return t From 7bb6c8538129c2a5b31b12ec6a3850c032efaa4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 25 Nov 2020 11:49:58 +0100 Subject: [PATCH 2/2] Unconditionally log protocol version negotiation --- lib/rExec.ml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/rExec.ml b/lib/rExec.ml index 740e2d5..2505bd4 100644 --- a/lib/rExec.ml +++ b/lib/rExec.ml @@ -217,9 +217,9 @@ let with_flow ~ty ~domid ~port fn = recv_hello client >>= function | version when version < 2l -> fail (error "Unsupported qrexec version %ld" version) | version -> - if version > 2l - then Log.debug (fun f -> f "Other end wants to use newer protocol %lu, \ - continuing with version 2" version); + Log.info (fun f -> f "client connected, \ + other end wants to use protocol version %lu, \ + continuing with version 2" version); send_hello client >|= fun () -> Flow.create ~ty client ) @@ -379,8 +379,7 @@ let connect ~domid () = recv_hello t.t >>= function | version when version < 2l -> fail (error "Unsupported qrexec version %ld" version) | version -> - if version > 2l - then Log.debug (fun f -> f "Other end wants to use newer protocol %lu, \ - continuing with version 2" version); - Log.info (fun f -> f "client connected, using protocol version 2"); + Log.info (fun f -> f "client connected, \ + other end wants to use protocol version %lu, \ + continuing with version 2" version); return t