From 38138e7d139a7fdb3b81add4deedafd0003fd712 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 6 Jun 2010 11:54:46 -0400 Subject: [PATCH] Only use I/O input log file if def_log_input is set and output file if def_log_output is set. --- plugins/sudoers/iolog.c | 50 ++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index 6f076d301..ad1d976e7 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -77,6 +77,7 @@ struct script_buf { static struct timeval last_time; static union io_fd io_fds[IOFD_MAX]; +extern struct io_plugin sudoers_io; void io_nextid(void) @@ -247,25 +248,38 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, 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); - - 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); - - 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_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_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); + } else { + /* No input logging. */ + sudoers_io.log_ttyin = NULL; + sudoers_io.log_stdin = NULL; + } - 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_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_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); + } else { + /* No output logging. */ + sudoers_io.log_ttyout = NULL; + sudoers_io.log_stdout = NULL; + sudoers_io.log_stderr = NULL; + } gettimeofday(&last_time, NULL); -- 2.40.0