diff options
Diffstat (limited to 'mux.c')
-rw-r--r-- | mux.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: mux.c,v 1.66 2017/09/12 06:32:07 djm Exp $ */ | 1 | /* $OpenBSD: mux.c,v 1.67 2017/09/12 06:35:32 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -215,7 +215,8 @@ mux_master_session_cleanup_cb(struct ssh *ssh, int cid, void *unused) | |||
215 | fatal("%s: channel %d missing control channel %d", | 215 | fatal("%s: channel %d missing control channel %d", |
216 | __func__, c->self, c->ctl_chan); | 216 | __func__, c->self, c->ctl_chan); |
217 | c->ctl_chan = -1; | 217 | c->ctl_chan = -1; |
218 | cc->remote_id = -1; | 218 | cc->remote_id = 0; |
219 | cc->have_remote_id = 0; | ||
219 | chan_rcvd_oclose(ssh, cc); | 220 | chan_rcvd_oclose(ssh, cc); |
220 | } | 221 | } |
221 | channel_cancel_cleanup(ssh, c->self); | 222 | channel_cancel_cleanup(ssh, c->self); |
@@ -231,11 +232,12 @@ mux_master_control_cleanup_cb(struct ssh *ssh, int cid, void *unused) | |||
231 | debug3("%s: entering for channel %d", __func__, cid); | 232 | debug3("%s: entering for channel %d", __func__, cid); |
232 | if (c == NULL) | 233 | if (c == NULL) |
233 | fatal("%s: channel_by_id(%i) == NULL", __func__, cid); | 234 | fatal("%s: channel_by_id(%i) == NULL", __func__, cid); |
234 | if (c->remote_id != -1) { | 235 | if (c->have_remote_id) { |
235 | if ((sc = channel_by_id(ssh, c->remote_id)) == NULL) | 236 | if ((sc = channel_by_id(ssh, c->remote_id)) == NULL) |
236 | fatal("%s: channel %d missing session channel %d", | 237 | fatal("%s: channel %d missing session channel %u", |
237 | __func__, c->self, c->remote_id); | 238 | __func__, c->self, c->remote_id); |
238 | c->remote_id = -1; | 239 | c->remote_id = 0; |
240 | c->have_remote_id = 0; | ||
239 | sc->ctl_chan = -1; | 241 | sc->ctl_chan = -1; |
240 | if (sc->type != SSH_CHANNEL_OPEN && | 242 | if (sc->type != SSH_CHANNEL_OPEN && |
241 | sc->type != SSH_CHANNEL_OPENING) { | 243 | sc->type != SSH_CHANNEL_OPENING) { |
@@ -413,7 +415,7 @@ process_mux_new_session(struct ssh *ssh, u_int rid, | |||
413 | new_fd[0], new_fd[1], new_fd[2]); | 415 | new_fd[0], new_fd[1], new_fd[2]); |
414 | 416 | ||
415 | /* XXX support multiple child sessions in future */ | 417 | /* XXX support multiple child sessions in future */ |
416 | if (c->remote_id != -1) { | 418 | if (c->have_remote_id) { |
417 | debug2("%s: session already open", __func__); | 419 | debug2("%s: session already open", __func__); |
418 | /* prepare reply */ | 420 | /* prepare reply */ |
419 | buffer_put_int(r, MUX_S_FAILURE); | 421 | buffer_put_int(r, MUX_S_FAILURE); |
@@ -471,6 +473,7 @@ process_mux_new_session(struct ssh *ssh, u_int rid, | |||
471 | 473 | ||
472 | nc->ctl_chan = c->self; /* link session -> control channel */ | 474 | nc->ctl_chan = c->self; /* link session -> control channel */ |
473 | c->remote_id = nc->self; /* link control -> session channel */ | 475 | c->remote_id = nc->self; /* link control -> session channel */ |
476 | c->have_remote_id = 1; | ||
474 | 477 | ||
475 | if (cctx->want_tty && escape_char != 0xffffffff) { | 478 | if (cctx->want_tty && escape_char != 0xffffffff) { |
476 | channel_register_filter(ssh, nc->self, | 479 | channel_register_filter(ssh, nc->self, |
@@ -1007,7 +1010,7 @@ process_mux_stdio_fwd(struct ssh *ssh, u_int rid, | |||
1007 | new_fd[0], new_fd[1]); | 1010 | new_fd[0], new_fd[1]); |
1008 | 1011 | ||
1009 | /* XXX support multiple child sessions in future */ | 1012 | /* XXX support multiple child sessions in future */ |
1010 | if (c->remote_id != -1) { | 1013 | if (c->have_remote_id) { |
1011 | debug2("%s: session already open", __func__); | 1014 | debug2("%s: session already open", __func__); |
1012 | /* prepare reply */ | 1015 | /* prepare reply */ |
1013 | buffer_put_int(r, MUX_S_FAILURE); | 1016 | buffer_put_int(r, MUX_S_FAILURE); |
@@ -1043,6 +1046,7 @@ process_mux_stdio_fwd(struct ssh *ssh, u_int rid, | |||
1043 | 1046 | ||
1044 | nc->ctl_chan = c->self; /* link session -> control channel */ | 1047 | nc->ctl_chan = c->self; /* link session -> control channel */ |
1045 | c->remote_id = nc->self; /* link control -> session channel */ | 1048 | c->remote_id = nc->self; /* link control -> session channel */ |
1049 | c->have_remote_id = 1; | ||
1046 | 1050 | ||
1047 | debug2("%s: channel_new: %d linked to control channel %d", | 1051 | debug2("%s: channel_new: %d linked to control channel %d", |
1048 | __func__, nc->self, nc->ctl_chan); | 1052 | __func__, nc->self, nc->ctl_chan); |