Bugzilla – Attachment 590 Details for
Bug 830
Check immediate EOF coming on stdin
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add check EOF comming on stdin at session_setup time for protocol 2
opensshpatch.txt (text/plain), 3.03 KB, created by
Ignasi Roca
on 2004-04-01 19:58:43 AEST
(
hide
)
Description:
Add check EOF comming on stdin at session_setup time for protocol 2
Filename:
MIME Type:
Creator:
Ignasi Roca
Created:
2004-04-01 19:58:43 AEST
Size:
3.03 KB
patch
obsolete
>diff -bur openssh-3.8p1.orig/channels.c openssh-3.8p1/channels.c >--- openssh-3.8p1.orig/channels.c Wed Jan 21 01:02:09 2004 >+++ openssh-3.8p1/channels.c Thu Apr 1 10:51:09 2004 >@@ -134,6 +134,9 @@ > /* helper */ > static void port_open_helper(Channel *c, char *rtype); > >+/* non_blocking switch */ >+static int in_non_blocking_mode = 0; >+ > /* -- channel core */ > > Channel * >@@ -2849,4 +2852,85 @@ > packet_start(SSH_CMSG_AGENT_REQUEST_FORWARDING); > packet_send(); > packet_write_wait(); >+} >+ >+ >+/* Restores stdin to blocking mode. */ >+ >+static void >+leave_non_blocking(void) >+{ >+ if (in_non_blocking_mode) { >+ (void) fcntl(fileno(stdin), F_SETFL, 0); >+ in_non_blocking_mode = 0; >+ } >+} >+ >+/* Puts stdin terminal in non-blocking mode. */ >+ >+static void >+enter_non_blocking(void) >+{ >+ in_non_blocking_mode = 1; >+ (void) fcntl(fileno(stdin), F_SETFL, O_NONBLOCK); } >+ >+/* >+ * This is called when the interactive is entered. This checks if >+there is >+ * an EOF coming on stdin. We must check this explicitly, as select() >+does >+ * not appear to wake up when redirecting from /dev/null. >+ */ >+ >+void >+channel_check_initial_eof_on_stdin(int id) { >+ int len; >+ char buf[1]; >+ >+ Channel *c = channel_lookup(id); >+ >+ if (c == NULL) { >+ logit("channel_check_initial_eof_on_stdin: %d: bad id", id); >+ return; >+ } >+ >+ if ( c->type != SSH_CHANNEL_OPEN ) >+ return; >+ >+ /* >+ * Try to read a single character; it appears >+ * that for some files, such /dev/null, select() never wakes up for >+ * read for this descriptor, which means that we never get EOF. This >+ * way we will get the EOF if stdin comes from /dev/null or similar. >+ */ >+ >+ enter_non_blocking(); >+ >+ /* Check for immediate EOF on stdin. */ >+ len = read(c->rfd, buf, 1); >+ if (len < 0 && (errno == EINTR || errno == EAGAIN)) { >+ leave_non_blocking(); >+ return; >+ } >+ >+ leave_non_blocking(); >+ >+ if (len <= 0) { >+ debug2("channel %d: read<=0 rfd %d len %d", >+ c->self, c->rfd, len); >+ chan_read_failed(c); >+ } else { >+ /* >+ * Got data. We must store the data in the buffer, >+ * and also process it as an escape character if >+ * appropriate. >+ */ >+ if (c->input_filter != NULL) { >+ if (c->input_filter(c, buf, len) == -1) { >+ debug2("channel %d: filter stops", c->self); >+ chan_read_failed(c); >+ } >+ } else { >+ buffer_append(&c->input, buf, 1); >+ } >+ } > } >diff -bur openssh-3.8p1.orig/channels.h openssh-3.8p1/channels.h >--- openssh-3.8p1.orig/channels.h Thu Oct 2 08:17:00 2003 >+++ openssh-3.8p1/channels.h Thu Apr 1 10:26:14 2004 >@@ -165,6 +165,7 @@ > void channel_register_filter(int, channel_filter_fn *); > void channel_cancel_cleanup(int); > int channel_close_fd(int *); >+void channel_check_initial_eof_on_stdin(int); > > /* protocol handler */ > >--- openssh-3.8p1.orig/ssh.c Wed Dec 17 06:33:11 2003 >+++ openssh-3.8p1/ssh.c Thu Apr 1 10:31:57 2004 >@@ -1119,6 +1119,8 @@ > packet_send(); > } > >+ channel_check_initial_eof_on_stdin(id); >+ > packet_set_interactive(interactive); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 830
:
589
| 590