From cbc3ef64ceaf95ec1d0d1535211ce3a6945407e1 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 24 Sep 2018 11:51:14 +0200 Subject: [PATCH] process: allow reading from stdout/stderr sockets Allow reading from stdio streams that are conventionally associated with process output, since this is only convention. This involves disabling the oddness around closing stdio streams. Its purpose is to prevent the file descriptors 0 through 2 from being closed, since doing so can lead to information leaks when new file descriptors are being opened; instead, not doing anything seems like a more reasonable choice. Fixes: https://github.com/nodejs/node/issues/21203 PR-URL: https://github.com/nodejs/node/pull/23053 Reviewed-By: James M Snell --- doc/api/errors.md | 43 +++++++++++++------ doc/api/process.md | 6 +-- lib/internal/errors.js | 2 - lib/internal/process/stdio.js | 18 +++----- ...out-cannot-be-closed-child-process-pipe.js | 4 +- test/pseudo-tty/test-stdout-read.in | 1 + test/pseudo-tty/test-stdout-read.js | 3 ++ test/pseudo-tty/test-stdout-read.out | 1 + 8 files changed, 45 insertions(+), 33 deletions(-) create mode 100644 test/pseudo-tty/test-stdout-read.in create mode 100644 test/pseudo-tty/test-stdout-read.js create mode 100644 test/pseudo-tty/test-stdout-read.out diff --git a/doc/api/errors.md b/doc/api/errors.md index 1cdd1d0f20aa73..75146c24c359f1 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1545,18 +1545,6 @@ An attempt was made to operate on an already closed socket. A call was made and the UDP subsystem was not running. - -### ERR_STDERR_CLOSE - -An attempt was made to close the `process.stderr` stream. By design, Node.js -does not allow `stdout` or `stderr` streams to be closed by user code. - - -### ERR_STDOUT_CLOSE - -An attempt was made to close the `process.stdout` stream. By design, Node.js -does not allow `stdout` or `stderr` streams to be closed by user code. - ### ERR_STREAM_CANNOT_PIPE @@ -1955,6 +1943,37 @@ removed: v10.0.0 The `repl` module was unable to parse data from the REPL history file. + + +### ERR_STDERR_CLOSE + + +An attempt was made to close the `process.stderr` stream. By design, Node.js +does not allow `stdout` or `stderr` streams to be closed by user code. + + +### ERR_STDOUT_CLOSE + + +An attempt was made to close the `process.stdout` stream. By design, Node.js +does not allow `stdout` or `stderr` streams to be closed by user code. + ### ERR_STREAM_READ_NOT_IMPLEMENTED