Bugzilla – Attachment 1884 Details for
Bug 1750
Sftp hangs if stderr is used.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
/home/djm/sshd-ignore-subsys-stderr.diff
sshd-ignore-subsys-stderr.diff (text/plain), 6.46 KB, created by
Damien Miller
on 2010-06-23 21:51:01 AEST
(
hide
)
Description:
/home/djm/sshd-ignore-subsys-stderr.diff
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2010-06-23 21:51:01 AEST
Size:
6.46 KB
patch
obsolete
>Index: channels.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/channels.c,v >retrieving revision 1.304 >diff -u -p -r1.304 channels.c >--- channels.c 14 May 2010 23:29:23 -0000 1.304 >+++ channels.c 23 Jun 2010 11:50:24 -0000 >@@ -834,8 +834,9 @@ channel_pre_open(Channel *c, fd_set *rea > if (c->extended_usage == CHAN_EXTENDED_WRITE && > buffer_len(&c->extended) > 0) > FD_SET(c->efd, writeset); >- else if (!(c->flags & CHAN_EOF_SENT) && >- c->extended_usage == CHAN_EXTENDED_READ && >+ else if (c->efd != -1 && !(c->flags & CHAN_EOF_SENT) && >+ (c->extended_usage == CHAN_EXTENDED_READ || >+ c->extended_usage == CHAN_EXTENDED_IGNORE) && > buffer_len(&c->extended) < c->remote_window) > FD_SET(c->efd, readset); > } >@@ -1734,7 +1735,9 @@ channel_handle_efd(Channel *c, fd_set *r > buffer_consume(&c->extended, len); > c->local_consumed += len; > } >- } else if (c->extended_usage == CHAN_EXTENDED_READ && >+ } else if (c->efd != -1 && >+ (c->extended_usage == CHAN_EXTENDED_READ || >+ c->extended_usage == CHAN_EXTENDED_IGNORE) && > FD_ISSET(c->efd, readset)) { > len = read(c->efd, buf, sizeof(buf)); > debug2("channel %d: read %d from efd %d", >@@ -1746,7 +1749,11 @@ channel_handle_efd(Channel *c, fd_set *r > c->self, c->efd); > channel_close_fd(&c->efd); > } else { >- buffer_append(&c->extended, buf, len); >+ if (c->extended_usage == CHAN_EXTENDED_IGNORE) { >+ debug3("channel %d: discard efd", >+ c->self); >+ } else >+ buffer_append(&c->extended, buf, len); > } > } > } >Index: session.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/session.c,v >retrieving revision 1.255 >diff -u -p -r1.255 session.c >--- session.c 22 Jun 2010 04:59:12 -0000 1.255 >+++ session.c 23 Jun 2010 11:50:24 -0000 >@@ -97,7 +97,7 @@ > /* func */ > > Session *session_new(void); >-void session_set_fds(Session *, int, int, int, int); >+void session_set_fds(Session *, int, int, int, int, int); > void session_pty_cleanup(Session *); > void session_proctitle(Session *); > int session_setup_x11fwd(Session *); >@@ -431,6 +431,7 @@ int > do_exec_no_pty(Session *s, const char *command) > { > pid_t pid; >+ int ignore_fderr = 0; > #ifdef USE_PIPES > int pin[2], pout[2], perr[2]; > >@@ -448,28 +449,17 @@ do_exec_no_pty(Session *s, const char *c > close(pin[1]); > return -1; > } >- if (s->is_subsystem) { >- if ((perr[1] = open(_PATH_DEVNULL, O_WRONLY)) == -1) { >- error("%s: open(%s): %s", __func__, _PATH_DEVNULL, >- strerror(errno)); >- close(pin[0]); >- close(pin[1]); >- close(pout[0]); >- close(pout[1]); >- return -1; >- } >- perr[0] = -1; >- } else { >- if (pipe(perr) < 0) { >- error("%s: pipe err: %.100s", __func__, >- strerror(errno)); >- close(pin[0]); >- close(pin[1]); >- close(pout[0]); >- close(pout[1]); >- return -1; >- } >+ if (pipe(perr) < 0) { >+ error("%s: pipe err: %.100s", __func__, >+ strerror(errno)); >+ close(pin[0]); >+ close(pin[1]); >+ close(pout[0]); >+ close(pout[1]); >+ return -1; > } >+ if (s->is_subsystem) >+ ignore_fderr = 1; > #else > int inout[2], err[2]; > >@@ -481,24 +471,15 @@ do_exec_no_pty(Session *s, const char *c > error("%s: socketpair #1: %.100s", __func__, strerror(errno)); > return -1; > } >- if (s->is_subsystem) { >- if ((err[0] = open(_PATH_DEVNULL, O_WRONLY)) == -1) { >- error("%s: open(%s): %s", __func__, _PATH_DEVNULL, >- strerror(errno)); >- close(inout[0]); >- close(inout[1]); >- return -1; >- } >- err[1] = -1; >- } else { >- if (socketpair(AF_UNIX, SOCK_STREAM, 0, err) < 0) { >- error("%s: socketpair #2: %.100s", __func__, >- strerror(errno)); >- close(inout[0]); >- close(inout[1]); >- return -1; >- } >+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, err) < 0) { >+ error("%s: socketpair #2: %.100s", __func__, >+ strerror(errno)); >+ close(inout[0]); >+ close(inout[1]); >+ return -1; > } >+ if (s->is_subsystem) >+ ignore_fderr = 1; > #endif > > session_proctitle(s); >@@ -512,15 +493,13 @@ do_exec_no_pty(Session *s, const char *c > close(pin[1]); > close(pout[0]); > close(pout[1]); >- if (perr[0] != -1) >- close(perr[0]); >+ close(perr[0]); > close(perr[1]); > #else > close(inout[0]); > close(inout[1]); > close(err[0]); >- if (err[1] != -1) >- close(err[1]); >+ close(err[1]); > #endif > return -1; > case 0: >@@ -554,8 +533,7 @@ do_exec_no_pty(Session *s, const char *c > close(pout[1]); > > /* Redirect stderr. */ >- if (perr[0] != -1) >- close(perr[0]); >+ close(perr[0]); > if (dup2(perr[1], 2) < 0) > perror("dup2 stderr"); > close(perr[1]); >@@ -566,8 +544,7 @@ do_exec_no_pty(Session *s, const char *c > * seem to depend on it. > */ > close(inout[1]); >- if (err[1] != -1) >- close(err[1]); >+ close(err[1]); > if (dup2(inout[0], 0) < 0) /* stdin */ > perror("dup2 stdin"); > if (dup2(inout[0], 1) < 0) /* stdout (same as stdin) */ >@@ -596,7 +573,7 @@ do_exec_no_pty(Session *s, const char *c > close(perr[1]); > > if (compat20) { >- session_set_fds(s, pin[1], pout[0], perr[0], 0); >+ session_set_fds(s, pin[1], pout[0], perr[0], ignore_fderr, 0); > } else { > /* Enter the interactive session. */ > server_loop(pid, pin[1], pout[0], perr[0]); >@@ -612,7 +589,7 @@ do_exec_no_pty(Session *s, const char *c > * handle the case that fdin and fdout are the same. > */ > if (compat20) { >- session_set_fds(s, inout[1], inout[1], err[1], 0); >+ session_set_fds(s, inout[1], inout[1], err[1], ignore_fderr, 0); > } else { > server_loop(pid, inout[1], inout[1], err[1]); > /* server_loop has closed inout[1] and err[1]. */ >@@ -717,7 +694,7 @@ do_exec_pty(Session *s, const char *comm > s->ptymaster = ptymaster; > packet_set_interactive(1); > if (compat20) { >- session_set_fds(s, ptyfd, fdout, -1, 1); >+ session_set_fds(s, ptyfd, fdout, -1, 1, 1); > } else { > server_loop(pid, ptyfd, fdout, -1); > /* server_loop _has_ closed ptyfd and fdout. */ >@@ -1936,7 +1913,8 @@ session_input_channel_req(Channel *c, co > } > > void >-session_set_fds(Session *s, int fdin, int fdout, int fderr, int is_tty) >+session_set_fds(Session *s, int fdin, int fdout, int fderr, int ignore_fderr, >+ int is_tty) > { > if (!compat20) > fatal("session_set_fds: called for proto != 2.0"); >@@ -1948,7 +1926,7 @@ session_set_fds(Session *s, int fdin, in > fatal("no channel for session %d", s->self); > channel_set_fds(s->chanid, > fdout, fdin, fderr, >- fderr == -1 ? CHAN_EXTENDED_IGNORE : CHAN_EXTENDED_READ, >+ ignore_fderr ? CHAN_EXTENDED_IGNORE : CHAN_EXTENDED_READ, > 1, is_tty, CHAN_SES_WINDOW_DEFAULT); > } >
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 1750
:
1840
|
1884
|
1885