summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2008-06-16 07:59:23 +1000
committerDamien Miller <djm@mindrot.org>2008-06-16 07:59:23 +1000
commitd310d51badf6bbd1df56c8a0971d24e2d3e61887 (patch)
treec9be17fd3c127b573f18ef9b1855e87e9f7f45af
parent307c1d10a78218fc2a67c3b285f90e701415004b (diff)
- djm@cvs.openbsd.org 2008/06/15 20:06:26
[channels.c channels.h session.c] don't call isatty() on a pty master, instead pass a flag down to channel_set_fds() indicating that te fds refer to a tty. Fixes a hang on exit on Solaris (bz#1463) in portable but is actually a generic bug; ok dtucker deraadt markus
-rw-r--r--ChangeLog8
-rw-r--r--channels.c23
-rw-r--r--channels.h4
-rw-r--r--session.c15
4 files changed, 23 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a3b3b1a8..77d7739dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,12 @@
21 - dtucker@cvs.openbsd.org 2008/06/15 16:58:40 21 - dtucker@cvs.openbsd.org 2008/06/15 16:58:40
22 [servconf.c sshd_config.5] 22 [servconf.c sshd_config.5]
23 Allow MaxAuthTries within a Match block. ok djm@ 23 Allow MaxAuthTries within a Match block. ok djm@
24 - djm@cvs.openbsd.org 2008/06/15 20:06:26
25 [channels.c channels.h session.c]
26 don't call isatty() on a pty master, instead pass a flag down to
27 channel_set_fds() indicating that te fds refer to a tty. Fixes a
28 hang on exit on Solaris (bz#1463) in portable but is actually
29 a generic bug; ok dtucker deraadt markus
24 30
2520080614 3120080614
26 - (djm) [openbsd-compat/sigact.c] Avoid NULL derefs in ancient sigaction 32 - (djm) [openbsd-compat/sigact.c] Avoid NULL derefs in ancient sigaction
@@ -4393,4 +4399,4 @@
4393 OpenServer 6 and add osr5bigcrypt support so when someone migrates 4399 OpenServer 6 and add osr5bigcrypt support so when someone migrates
4394 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 4400 passwords between UnixWare and OpenServer they will still work. OK dtucker@
4395 4401
4396$Id: ChangeLog,v 1.5018 2008/06/15 21:56:20 djm Exp $ 4402$Id: ChangeLog,v 1.5019 2008/06/15 21:59:23 djm Exp $
diff --git a/channels.c b/channels.c
index 04cd6b0a7..b1e544519 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.280 2008/06/12 15:19:17 djm Exp $ */ 1/* $OpenBSD: channels.c,v 1.281 2008/06/15 20:06:26 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -221,7 +221,7 @@ channel_lookup(int id)
221 */ 221 */
222static void 222static void
223channel_register_fds(Channel *c, int rfd, int wfd, int efd, 223channel_register_fds(Channel *c, int rfd, int wfd, int efd,
224 int extusage, int nonblock) 224 int extusage, int nonblock, int isatty)
225{ 225{
226 /* Update the maximum file descriptor value. */ 226 /* Update the maximum file descriptor value. */
227 channel_max_fd = MAX(channel_max_fd, rfd); 227 channel_max_fd = MAX(channel_max_fd, rfd);
@@ -237,18 +237,9 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd,
237 c->efd = efd; 237 c->efd = efd;
238 c->extended_usage = extusage; 238 c->extended_usage = extusage;
239 239
240 /* XXX ugly hack: nonblock is only set by the server */ 240 if ((c->isatty = isatty) != 0)
241 if (nonblock && isatty(c->rfd)) {
242 debug2("channel %d: rfd %d isatty", c->self, c->rfd); 241 debug2("channel %d: rfd %d isatty", c->self, c->rfd);
243 c->isatty = 1; 242 c->wfd_isatty = isatty || isatty(c->wfd);
244 if (!isatty(c->wfd)) {
245 error("channel %d: wfd %d is not a tty?",
246 c->self, c->wfd);
247 }
248 } else {
249 c->isatty = 0;
250 }
251 c->wfd_isatty = isatty(c->wfd);
252 243
253 /* enable nonblocking mode */ 244 /* enable nonblocking mode */
254 if (nonblock) { 245 if (nonblock) {
@@ -308,7 +299,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
308 c->ostate = CHAN_OUTPUT_OPEN; 299 c->ostate = CHAN_OUTPUT_OPEN;
309 c->istate = CHAN_INPUT_OPEN; 300 c->istate = CHAN_INPUT_OPEN;
310 c->flags = 0; 301 c->flags = 0;
311 channel_register_fds(c, rfd, wfd, efd, extusage, nonblock); 302 channel_register_fds(c, rfd, wfd, efd, extusage, nonblock, 0);
312 c->self = found; 303 c->self = found;
313 c->type = type; 304 c->type = type;
314 c->ctype = ctype; 305 c->ctype = ctype;
@@ -751,13 +742,13 @@ channel_register_filter(int id, channel_infilter_fn *ifn,
751 742
752void 743void
753channel_set_fds(int id, int rfd, int wfd, int efd, 744channel_set_fds(int id, int rfd, int wfd, int efd,
754 int extusage, int nonblock, u_int window_max) 745 int extusage, int nonblock, int isatty, u_int window_max)
755{ 746{
756 Channel *c = channel_lookup(id); 747 Channel *c = channel_lookup(id);
757 748
758 if (c == NULL || c->type != SSH_CHANNEL_LARVAL) 749 if (c == NULL || c->type != SSH_CHANNEL_LARVAL)
759 fatal("channel_activate for non-larval channel %d.", id); 750 fatal("channel_activate for non-larval channel %d.", id);
760 channel_register_fds(c, rfd, wfd, efd, extusage, nonblock); 751 channel_register_fds(c, rfd, wfd, efd, extusage, nonblock, isatty);
761 c->type = SSH_CHANNEL_OPEN; 752 c->type = SSH_CHANNEL_OPEN;
762 c->local_window = c->local_window_max = window_max; 753 c->local_window = c->local_window_max = window_max;
763 packet_start(SSH2_MSG_CHANNEL_WINDOW_ADJUST); 754 packet_start(SSH2_MSG_CHANNEL_WINDOW_ADJUST);
diff --git a/channels.h b/channels.h
index ec8ea1c40..108b36068 100644
--- a/channels.h
+++ b/channels.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.h,v 1.95 2008/06/12 15:19:17 djm Exp $ */ 1/* $OpenBSD: channels.h,v 1.96 2008/06/15 20:06:26 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -188,7 +188,7 @@ struct Channel {
188Channel *channel_by_id(int); 188Channel *channel_by_id(int);
189Channel *channel_lookup(int); 189Channel *channel_lookup(int);
190Channel *channel_new(char *, int, int, int, int, u_int, u_int, int, char *, int); 190Channel *channel_new(char *, int, int, int, int, u_int, u_int, int, char *, int);
191void channel_set_fds(int, int, int, int, int, int, u_int); 191void channel_set_fds(int, int, int, int, int, int, int, u_int);
192void channel_free(Channel *); 192void channel_free(Channel *);
193void channel_free_all(void); 193void channel_free_all(void);
194void channel_stop_listening(void); 194void channel_stop_listening(void);
diff --git a/session.c b/session.c
index 3ea783f63..d692bc709 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.c,v 1.239 2008/06/14 18:33:43 djm Exp $ */ 1/* $OpenBSD: session.c,v 1.240 2008/06/15 20:06:26 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -98,7 +98,7 @@
98/* func */ 98/* func */
99 99
100Session *session_new(void); 100Session *session_new(void);
101void session_set_fds(Session *, int, int, int); 101void session_set_fds(Session *, int, int, int, int);
102void session_pty_cleanup(Session *); 102void session_pty_cleanup(Session *);
103void session_proctitle(Session *); 103void session_proctitle(Session *);
104int session_setup_x11fwd(Session *); 104int session_setup_x11fwd(Session *);
@@ -591,7 +591,7 @@ do_exec_no_pty(Session *s, const char *command)
591 close(perr[0]); 591 close(perr[0]);
592 perr[0] = -1; 592 perr[0] = -1;
593 } 593 }
594 session_set_fds(s, pin[1], pout[0], perr[0]); 594 session_set_fds(s, pin[1], pout[0], perr[0], 0);
595 } else { 595 } else {
596 /* Enter the interactive session. */ 596 /* Enter the interactive session. */
597 server_loop(pid, pin[1], pout[0], perr[0]); 597 server_loop(pid, pin[1], pout[0], perr[0]);
@@ -608,7 +608,7 @@ do_exec_no_pty(Session *s, const char *command)
608 */ 608 */
609 if (compat20) { 609 if (compat20) {
610 session_set_fds(s, inout[1], inout[1], 610 session_set_fds(s, inout[1], inout[1],
611 s->is_subsystem ? -1 : err[1]); 611 s->is_subsystem ? -1 : err[1], 0);
612 if (s->is_subsystem) 612 if (s->is_subsystem)
613 close(err[1]); 613 close(err[1]);
614 } else { 614 } else {
@@ -733,7 +733,7 @@ do_exec_pty(Session *s, const char *command)
733 s->ptymaster = ptymaster; 733 s->ptymaster = ptymaster;
734 packet_set_interactive(1); 734 packet_set_interactive(1);
735 if (compat20) { 735 if (compat20) {
736 session_set_fds(s, ptyfd, fdout, -1); 736 session_set_fds(s, ptyfd, fdout, -1, 1);
737 } else { 737 } else {
738 server_loop(pid, ptyfd, fdout, -1); 738 server_loop(pid, ptyfd, fdout, -1);
739 /* server_loop _has_ closed ptyfd and fdout. */ 739 /* server_loop _has_ closed ptyfd and fdout. */
@@ -2285,7 +2285,7 @@ session_input_channel_req(Channel *c, const char *rtype)
2285} 2285}
2286 2286
2287void 2287void
2288session_set_fds(Session *s, int fdin, int fdout, int fderr) 2288session_set_fds(Session *s, int fdin, int fdout, int fderr, int isatty)
2289{ 2289{
2290 if (!compat20) 2290 if (!compat20)
2291 fatal("session_set_fds: called for proto != 2.0"); 2291 fatal("session_set_fds: called for proto != 2.0");
@@ -2298,8 +2298,7 @@ session_set_fds(Session *s, int fdin, int fdout, int fderr)
2298 channel_set_fds(s->chanid, 2298 channel_set_fds(s->chanid,
2299 fdout, fdin, fderr, 2299 fdout, fdin, fderr,
2300 fderr == -1 ? CHAN_EXTENDED_IGNORE : CHAN_EXTENDED_READ, 2300 fderr == -1 ? CHAN_EXTENDED_IGNORE : CHAN_EXTENDED_READ,
2301 1, 2301 1, isatty, CHAN_SES_WINDOW_DEFAULT);
2302 CHAN_SES_WINDOW_DEFAULT);
2303} 2302}
2304 2303
2305/* 2304/*