summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-11-05 14:52:50 +1100
committerDamien Miller <djm@mindrot.org>2005-11-05 14:52:50 +1100
commit39eda6eb6a8364e8df6779e71e0b434eaae3edd5 (patch)
tree2e7a8fda98f3a3d9b4e14f2b36787fc2168b691a /session.c
parent3f54a9f5b7978e8e7085f86722bc2704f7fab2e2 (diff)
- djm@cvs.openbsd.org 2005/10/10 10:23:08
[channels.c channels.h clientloop.c serverloop.c session.c] fix regression I introduced in 4.2: X11 forwardings initiated after a session has exited (e.g. "(sleep 5; xterm) &") would not start. bz #1086 reported by t8m AT centrum.cz; ok markus@ dtucker@
Diffstat (limited to 'session.c')
-rw-r--r--session.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/session.c b/session.c
index 2a1a25ac4..5e6627cb0 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.186 2005/07/25 11:59:40 markus Exp $"); 36RCSID("$OpenBSD: session.c,v 1.187 2005/10/10 10:23:08 djm Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -2156,7 +2156,6 @@ static void
2156session_exit_message(Session *s, int status) 2156session_exit_message(Session *s, int status)
2157{ 2157{
2158 Channel *c; 2158 Channel *c;
2159 u_int i;
2160 2159
2161 if ((c = channel_lookup(s->chanid)) == NULL) 2160 if ((c = channel_lookup(s->chanid)) == NULL)
2162 fatal("session_exit_message: session %d: no channel %d", 2161 fatal("session_exit_message: session %d: no channel %d",
@@ -2186,7 +2185,15 @@ session_exit_message(Session *s, int status)
2186 2185
2187 /* disconnect channel */ 2186 /* disconnect channel */
2188 debug("session_exit_message: release channel %d", s->chanid); 2187 debug("session_exit_message: release channel %d", s->chanid);
2189 channel_cancel_cleanup(s->chanid); 2188 s->pid = 0;
2189
2190 /*
2191 * Adjust cleanup callback attachment to send close messages when
2192 * the channel gets EOF. The session will be then be closed
2193 * by session_close_by_channel when the childs close their fds.
2194 */
2195 channel_register_cleanup(c->self, session_close_by_channel, 1);
2196
2190 /* 2197 /*
2191 * emulate a write failure with 'chan_write_failed', nobody will be 2198 * emulate a write failure with 'chan_write_failed', nobody will be
2192 * interested in data we write. 2199 * interested in data we write.
@@ -2195,15 +2202,6 @@ session_exit_message(Session *s, int status)
2195 */ 2202 */
2196 if (c->ostate != CHAN_OUTPUT_CLOSED) 2203 if (c->ostate != CHAN_OUTPUT_CLOSED)
2197 chan_write_failed(c); 2204 chan_write_failed(c);
2198 s->chanid = -1;
2199
2200 /* Close any X11 listeners associated with this session */
2201 if (s->x11_chanids != NULL) {
2202 for (i = 0; s->x11_chanids[i] != -1; i++) {
2203 session_close_x11(s->x11_chanids[i]);
2204 s->x11_chanids[i] = -1;
2205 }
2206 }
2207} 2205}
2208 2206
2209void 2207void
@@ -2247,7 +2245,8 @@ session_close_by_pid(pid_t pid, int status)
2247 } 2245 }
2248 if (s->chanid != -1) 2246 if (s->chanid != -1)
2249 session_exit_message(s, status); 2247 session_exit_message(s, status);
2250 session_close(s); 2248 if (s->ttyfd != -1)
2249 session_pty_cleanup(s);
2251} 2250}
2252 2251
2253/* 2252/*
@@ -2258,6 +2257,7 @@ void
2258session_close_by_channel(int id, void *arg) 2257session_close_by_channel(int id, void *arg)
2259{ 2258{
2260 Session *s = session_by_channel(id); 2259 Session *s = session_by_channel(id);
2260 u_int i;
2261 2261
2262 if (s == NULL) { 2262 if (s == NULL) {
2263 debug("session_close_by_channel: no session for id %d", id); 2263 debug("session_close_by_channel: no session for id %d", id);
@@ -2277,6 +2277,15 @@ session_close_by_channel(int id, void *arg)
2277 } 2277 }
2278 /* detach by removing callback */ 2278 /* detach by removing callback */
2279 channel_cancel_cleanup(s->chanid); 2279 channel_cancel_cleanup(s->chanid);
2280
2281 /* Close any X11 listeners associated with this session */
2282 if (s->x11_chanids != NULL) {
2283 for (i = 0; s->x11_chanids[i] != -1; i++) {
2284 session_close_x11(s->x11_chanids[i]);
2285 s->x11_chanids[i] = -1;
2286 }
2287 }
2288
2280 s->chanid = -1; 2289 s->chanid = -1;
2281 session_close(s); 2290 session_close(s);
2282} 2291}
@@ -2371,7 +2380,7 @@ session_setup_x11fwd(Session *s)
2371 } 2380 }
2372 for (i = 0; s->x11_chanids[i] != -1; i++) { 2381 for (i = 0; s->x11_chanids[i] != -1; i++) {
2373 channel_register_cleanup(s->x11_chanids[i], 2382 channel_register_cleanup(s->x11_chanids[i],
2374 session_close_single_x11); 2383 session_close_single_x11, 0);
2375 } 2384 }
2376 2385
2377 /* Set up a suitable value for the DISPLAY variable. */ 2386 /* Set up a suitable value for the DISPLAY variable. */