]> granicus.if.org Git - sudo/commitdiff
Don't read from stdin when flushing final buffers in blocking mode.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 24 May 2016 17:16:44 +0000 (11:16 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 24 May 2016 17:16:44 +0000 (11:16 -0600)
Reading from the pipe can block too if the other end is not closed.

NEWS
src/exec_pty.c

diff --git a/NEWS b/NEWS
index 3f243c6be1d9c11087e58d69694435028cb67404..2971fa982f691824e0d02acc5e179b8633be4dc6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,8 +30,8 @@ What's new in Sudo 1.8.17
 
  * SELinux support, which was broken in 1.8.16, has been repaired.
 
- * Fixed a bug when logging I/O where all buffers might not get
-   flushed at exit when reading from standard input.
+ * Fixed a bug when logging I/O where all output buffers might not
+   get flushed at exit.
 
  * Forward slashes are no longer escaped in the JSON output of
    "visudo -x".  This was never required by the standard and not
index 2179ac50fb1a3439365c0f66e1b99a5ff9054d91..3437e27721483a4c37fee80b1d3182c1d05ce7a8 100644 (file)
@@ -1024,9 +1024,9 @@ del_io_events(bool nonblocking)
     (void) sudo_ev_loop(evbase, SUDO_EVLOOP_NONBLOCK);
 
     /*
-     * If not in non-blocking mode, make sure we flush pipes completely.
-     * We don't want to read from the pty since that might block and
-     * the command is no longer running anyway.
+     * If not in non-blocking mode, make sure we flush write buffers.
+     * We don't want to read from the pty or stdin since that might block
+     * and the command is no longer running anyway.
      */
     if (!nonblocking) {
        /* Clear out iobufs from event base. */
@@ -1038,13 +1038,6 @@ del_io_events(bool nonblocking)
        }
 
        SLIST_FOREACH(iob, &iobufs, entries) {
-           /* Only flush from stdin (pipe). */
-           if (iob->revent != NULL && sudo_ev_get_fd(iob->revent) == SFD_STDIN) {
-               if (iob->len != sizeof(iob->buf)) {
-                   if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
-                       sudo_fatal(U_("unable to add event to queue"));
-               }
-           }
            /* Flush any write buffers with data in them. */
            if (iob->wevent != NULL) {
                if (iob->len > iob->off) {
@@ -1055,7 +1048,7 @@ del_io_events(bool nonblocking)
        }
        (void) sudo_ev_loop(evbase, 0);
      
-       /* We should now have flushed all buffers. */
+       /* We should now have flushed all write buffers. */
        SLIST_FOREACH(iob, &iobufs, entries) {
            if (iob->wevent != NULL) {
                if (iob->len > iob->off) {