Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/rExec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,14 @@ let start_connection params clients =
Log.debug (fun f -> f "request_id %S without client" request_id);
Lwt.return_unit

let listen t handler =
let noop_handler ~user:_ cmd _flow =
match cmd with
| "QUBESRPC qubes.WaitForSession none" -> Lwt.return 0 (* Always ready! *)
| cmd ->
Log.warn (fun f -> f "Unknown command %S" cmd);
Lwt.return 1

let listen t ?(handler = noop_handler) () =
let rec loop () =
recv t.t >>= function
| `Ok (`Just_exec | `Exec_cmdline as ty, data) ->
Expand Down
7 changes: 4 additions & 3 deletions lib/rExec.mli
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ val connect : domid:int -> unit -> t Lwt.t
Internally, it creates a server endpoint and places the endpoint information
in XenStore, then waits for a client to connect. *)

val listen : t -> handler -> unit Lwt.t
(** [listen t handler] is a thread that reads incoming requests from [t]
val listen : t -> ?handler:handler -> unit -> unit Lwt.t
(** [listen t handler ()] is a thread that reads incoming requests from [t]
and handles each one asynchronously with [handler]. The loop ends if
the client disconnects. *)
the client disconnects. The default [handler] function reply ready for command
"QUBESRPC qubes.WaitForSession none" and nothing else. *)

val qrexec : t -> vm:string -> service:string -> client -> [`Ok | `Closed] Lwt.t
(** [qrexec t ~vm ~service ~client] initiates a qrexec call to [vm]'s service
Expand Down