diff options
author | Mike Frysinger <vapier@gentoo.org> | 2013-02-24 23:57:17 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2013-02-24 23:57:17 -0500 |
commit | d6af3ad271c3893419962059092eea29ffb4f507 (patch) | |
tree | 4a9529cc29071908d7650037d495922ba39b01e4 /src | |
parent | libsandbox: fix early var init (diff) | |
download | sandbox-d6af3ad271c3893419962059092eea29ffb4f507.tar.gz sandbox-d6af3ad271c3893419962059092eea29ffb4f507.tar.bz2 sandbox-d6af3ad271c3893419962059092eea29ffb4f507.zip |
sandbox: do not resolve target of stderr
The recent e12fee192ac8b0343a468e5a8f7811a7b029ff9a commit does not
handle things when stderr is connected to a real file (e.g. a pipe
or a socket or fifo or ...). It also does not play well to have
multiple things writing to the same file through different fds.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/sandbox.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/sandbox.c b/src/sandbox.c index 51f2d95..3783bca 100644 --- a/src/sandbox.c +++ b/src/sandbox.c @@ -82,15 +82,18 @@ static int setup_sandbox(struct sandbox_info_t *sandbox_info, bool interactive) } /* Generate sandbox message path -- this process's stderr */ - char path[SB_PATH_MAX]; - sprintf(path, "%s/2", sb_get_fd_dir()); - if (realpath(path, sandbox_info->sandbox_message_path) == NULL) { - sb_pwarn("could not read stderr path: %s", path); + const char *fdpath = sb_get_fd_dir(); + if (realpath(fdpath, sandbox_info->sandbox_message_path) == NULL) { + sb_pwarn("could not read fd path: %s", fdpath); if (realpath(sbio_fallback_path, sandbox_info->sandbox_message_path)) { sb_pwarn("could not read stderr path: %s", sbio_fallback_path); /* fuck it */ strcpy(sandbox_info->sandbox_message_path, sbio_fallback_path); } + } else { + /* Do not resolve the target of stderr because it could be something + * that doesn't exist on the fs. Like a pipe (`tee` and such). */ + strcat(sandbox_info->sandbox_message_path, "/2"); } return 0; |