From: Todd C. Miller Date: Sun, 6 Jun 2010 15:44:55 +0000 (-0400) Subject: Only use I/O input log file if def_log_input is set and output file X-Git-Tag: SUDO_1_7_3~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b3010b9dcfbad8a6a2e27b35dbc058393d1e21d;p=sudo Only use I/O input log file if def_log_input is set and output file if def_log_output is set. --HG-- branch : 1.7 --- diff --git a/iolog.c b/iolog.c index 5ef3a3eef..ba40393dd 100644 --- a/iolog.c +++ b/iolog.c @@ -242,25 +242,35 @@ io_log_open() if (io_fds[IOFD_TIMING].v == NULL) log_error(USE_ERRNO, "Can't create %s", pathbuf); - io_fds[IOFD_TTYIN].v = open_io_fd(pathbuf, len, "/ttyin", def_compress_io); - if (io_fds[IOFD_TTYIN].v == NULL) - log_error(USE_ERRNO, "Can't create %s", pathbuf); + if (def_log_input) { + io_fds[IOFD_TTYIN].v = open_io_fd(pathbuf, len, "/ttyin", def_compress_io); + if (io_fds[IOFD_TTYIN].v == NULL) + log_error(USE_ERRNO, "Can't create %s", pathbuf); + } - io_fds[IOFD_TTYOUT].v = open_io_fd(pathbuf, len, "/ttyout", def_compress_io); - if (io_fds[IOFD_TTYOUT].v == NULL) - log_error(USE_ERRNO, "Can't create %s", pathbuf); + if (def_log_output) { + io_fds[IOFD_TTYOUT].v = open_io_fd(pathbuf, len, "/ttyout", def_compress_io); + if (io_fds[IOFD_TTYOUT].v == NULL) + log_error(USE_ERRNO, "Can't create %s", pathbuf); + } - io_fds[IOFD_STDIN].v = open_io_fd(pathbuf, len, "/stdin", def_compress_io); - if (io_fds[IOFD_STDIN].v == NULL) - log_error(USE_ERRNO, "Can't create %s", pathbuf); + if (def_log_input) { + io_fds[IOFD_STDIN].v = open_io_fd(pathbuf, len, "/stdin", def_compress_io); + if (io_fds[IOFD_STDIN].v == NULL) + log_error(USE_ERRNO, "Can't create %s", pathbuf); + } - io_fds[IOFD_STDOUT].v = open_io_fd(pathbuf, len, "/stdout", def_compress_io); - if (io_fds[IOFD_STDOUT].v == NULL) - log_error(USE_ERRNO, "Can't create %s", pathbuf); + if (def_log_output) { + io_fds[IOFD_STDOUT].v = open_io_fd(pathbuf, len, "/stdout", def_compress_io); + if (io_fds[IOFD_STDOUT].v == NULL) + log_error(USE_ERRNO, "Can't create %s", pathbuf); + } - io_fds[IOFD_STDERR].v = open_io_fd(pathbuf, len, "/stderr", def_compress_io); - if (io_fds[IOFD_STDERR].v == NULL) - log_error(USE_ERRNO, "Can't create %s", pathbuf); + if (def_log_output) { + io_fds[IOFD_STDERR].v = open_io_fd(pathbuf, len, "/stderr", def_compress_io); + if (io_fds[IOFD_STDERR].v == NULL) + log_error(USE_ERRNO, "Can't create %s", pathbuf); + } /* So we can block tty-generated signals */ sigemptyset(&ttyblock); @@ -341,6 +351,8 @@ log_ttyin(buf, len) const char *buf; unsigned int len; { + if (!io_fds[IOFD_TTYIN].v) + return TRUE; return log_io(buf, len, IOFD_TTYIN); } @@ -349,6 +361,8 @@ log_ttyout(buf, len) const char *buf; unsigned int len; { + if (!io_fds[IOFD_TTYOUT].v) + return TRUE; return log_io(buf, len, IOFD_TTYOUT); } @@ -357,6 +371,8 @@ log_stdin(buf, len) const char *buf; unsigned int len; { + if (!io_fds[IOFD_STDIN].v) + return TRUE; return log_io(buf, len, IOFD_STDIN); } @@ -365,6 +381,8 @@ log_stdout(buf, len) const char *buf; unsigned int len; { + if (!io_fds[IOFD_STDOUT].v) + return TRUE; return log_io(buf, len, IOFD_STDOUT); } @@ -373,5 +391,7 @@ log_stderr(buf, len) const char *buf; unsigned int len; { + if (!io_fds[IOFD_STDOUT].v) + return TRUE; return log_io(buf, len, IOFD_STDERR); }