]> granicus.if.org Git - sudo/commitdiff
In pty_close() there is no need to remove events associated with
authorTodd C. Miller <Todd.Miller@sudo.ws>
Mon, 26 Mar 2018 12:28:23 +0000 (06:28 -0600)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Mon, 26 Mar 2018 12:28:23 +0000 (06:28 -0600)
the pty slave as there are none.  We also don't need to check for
the pty fds being -1 since they are not closed elsewhere and
pty_close() is only called if pty_setup() succeeds.

src/exec_pty.c

index 01466db86e2c8bf9d5653942478970ed8c6942a2..396c3629cf70fb0247ec240f4f59c749b02e05f3 100644 (file)
@@ -748,18 +748,14 @@ io_buf_new(int rfd, int wfd,
 }
 
 static void
-pty_close(struct sudo_event_base *evbase, struct command_status *cstat)
+pty_close(struct command_status *cstat)
 {
     struct io_buffer *iob;
     int n;
     debug_decl(pty_close, SUDO_DEBUG_EXEC);
 
     /* Close the pty slave first so reads from the master don't block. */
-    if (io_fds[SFD_SLAVE] != -1) {
-       ev_free_by_fd(evbase, io_fds[SFD_SLAVE]);
-       close(io_fds[SFD_SLAVE]);
-       io_fds[SFD_SLAVE] = -1;
-    }
+    close(io_fds[SFD_SLAVE]);
 
     /* Flush any remaining output (the plugin already got it). */
     if (io_fds[SFD_USERTTY] != -1) {
@@ -790,8 +786,7 @@ pty_close(struct sudo_event_base *evbase, struct command_status *cstat)
        utmp_logout(slavename, cstat->type == CMD_WSTATUS ? cstat->val : 0);
 
     /* Close pty master. */
-    if (io_fds[SFD_MASTER] != -1)
-       close(io_fds[SFD_MASTER]);
+    close(io_fds[SFD_MASTER]);
 
     debug_return;
 }
@@ -1493,7 +1488,7 @@ exec_pty(struct command_details *details, struct command_status *cstat)
     }
 
     /* Flush any remaining output, free I/O bufs and events, do logout. */
-    pty_close(ec.evbase, cstat);
+    pty_close(cstat);
 
     /* Free things up. */
     free_exec_closure_pty(&ec);