From 1b5533ae1011f7fd240c43f1ad1c506d56f5b358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 31 Oct 2014 03:53:15 +0100 Subject: [PATCH] qrexec: create stdin/out/err as sockets instead of pipes Instead of pipes, stdin/out/err are created as sockets. This allows qrexec-agent/daemon to decide to use some of them bidirectional. This is up to qrexec-agent/daemon, such socket can still be used as unidirectional channel. The main reason for this feature is to use USBIP over qrexec, which require single socket. --- qrexec-lib/exec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qrexec-lib/exec.c b/qrexec-lib/exec.c index f0949bc..b6518f0 100644 --- a/qrexec-lib/exec.c +++ b/qrexec-lib/exec.c @@ -19,6 +19,8 @@ * */ +#include +#include #include #include #include @@ -49,8 +51,10 @@ void do_fork_exec(const char *cmdline, int *pid, int *stdin_fd, int *stdout_fd, { int inpipe[2], outpipe[2], errpipe[2]; - if (pipe(inpipe) || pipe(outpipe) || (stderr_fd && pipe(errpipe))) { - perror("pipe"); + if (socketpair(AF_UNIX, SOCK_STREAM, 0, inpipe) || + socketpair(AF_UNIX, SOCK_STREAM, 0, outpipe) || + (stderr_fd && socketpair(AF_UNIX, SOCK_STREAM, 0, errpipe))) { + perror("socketpair"); exit(1); } switch (*pid = fork()) {