From 32b0c659a1a8d3c0e4bfb3690087afa7521e9e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 16 Feb 2018 04:22:48 +0100 Subject: [PATCH] qrexec: use exec_qubes_rpc_if_requested() from qubes-utils This avoids duplicating service call parsing in multiple places. For dom0 part it was in qrexec-policy tool. Also, add execl() error handling. --- qrexec/qrexec-client.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qrexec/qrexec-client.c b/qrexec/qrexec-client.c index c3d6145..f5c9a6f 100644 --- a/qrexec/qrexec-client.c +++ b/qrexec/qrexec-client.c @@ -47,6 +47,8 @@ pid_t local_pid = 0; int is_service = 0; int child_exited = 0; +extern char **environ; + static int handle_agent_handshake(libvchan_t *vchan, int remote_send_first) { struct msg_header hdr; @@ -164,9 +166,15 @@ static void sigchld_handler(int x __attribute__((__unused__))) } /* called from do_fork_exec */ -void do_exec(const char *prog) +_Noreturn void do_exec(char *prog) { + /* avoid calling qubes-rpc-multiplexer through shell */ + exec_qubes_rpc_if_requested(prog, environ); + + /* if above haven't executed qubes-rpc-multiplexer, pass it to shell */ execl("/bin/bash", "bash", "-c", prog, NULL); + perror("exec bash"); + exit(1); } static void do_exit(int code)