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.
release3.0 mm_1b5533ae
Marek Marczykowski-Górecki 10 years ago
parent 82b19d3283
commit 1b5533ae10

@ -19,6 +19,8 @@
*
*/
#include <sys/socket.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@ -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()) {

Loading…
Cancel
Save