From 82079136e38d28d009358f9bf141f70244a79609 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 19 Mar 2008 14:33:07 +0100 Subject: [PATCH] Sandbox: Added redirection of stderr on request. --- src/box.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/box.c b/src/box.c index 585eba0..c3598b4 100644 --- a/src/box.c +++ b/src/box.c @@ -36,7 +36,7 @@ static int pass_environ; static int file_access; static int verbose; static int memory_limit; -static char *redir_stdin, *redir_stdout; +static char *redir_stdin, *redir_stdout, *redir_stderr; static char *set_cwd; static pid_t box_pid; @@ -814,7 +814,14 @@ box_inside(int argc, char **argv) if (open(redir_stdout, O_WRONLY | O_CREAT | O_TRUNC, 0666) != 1) die("open(\"%s\"): %m", redir_stdout); } - dup2(1, 2); + if (redir_stderr) + { + close(2); + if (open(redir_stderr, O_WRONLY | O_CREAT | O_TRUNC, 0666) != 2) + die("open(\"%s\"): %m", redir_stderr); + } + else + dup2(1, 2); setpgrp(); if (memory_limit) { @@ -856,6 +863,7 @@ Options:\n\ -o \tRedirect stdout to \n\ -p \tPermit access to the specified path (or subtree if it ends with a `/')\n\ -p =\tDefine action for the specified path (=yes/no)\n\ +-r \tRedirect stderr to \n\ -s \tPermit the specified syscall (be careful)\n\ -s =\tDefine action for the specified syscall (=yes/no/file)\n\ -t