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)
downloadopenssh-git-39eda6eb6a8364e8df6779e71e0b434eaae3edd5.tar.gz
- 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 2a1a25ac..5e6627cb 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.186 2005/07/25 11:59:40 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.187 2005/10/10 10:23:08 djm Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -2156,7 +2156,6 @@ static void
session_exit_message(Session *s, int status)
{
Channel *c;
- u_int i;
if ((c = channel_lookup(s->chanid)) == NULL)
fatal("session_exit_message: session %d: no channel %d",
@@ -2186,7 +2185,15 @@ session_exit_message(Session *s, int status)
/* disconnect channel */
debug("session_exit_message: release channel %d", s->chanid);
- channel_cancel_cleanup(s->chanid);
+ s->pid = 0;
+
+ /*
+ * Adjust cleanup callback attachment to send close messages when
+ * the channel gets EOF. The session will be then be closed
+ * by session_close_by_channel when the childs close their fds.
+ */
+ channel_register_cleanup(c->self, session_close_by_channel, 1);
+
/*
* emulate a write failure with 'chan_write_failed', nobody will be
* interested in data we write.
@@ -2195,15 +2202,6 @@ session_exit_message(Session *s, int status)
*/
if (c->ostate != CHAN_OUTPUT_CLOSED)
chan_write_failed(c);
- s->chanid = -1;
-
- /* Close any X11 listeners associated with this session */
- if (s->x11_chanids != NULL) {
- for (i = 0; s->x11_chanids[i] != -1; i++) {
- session_close_x11(s->x11_chanids[i]);
- s->x11_chanids[i] = -1;
- }
- }
}
void
@@ -2247,7 +2245,8 @@ session_close_by_pid(pid_t pid, int status)
}
if (s->chanid != -1)
session_exit_message(s, status);
- session_close(s);
+ if (s->ttyfd != -1)
+ session_pty_cleanup(s);
}
/*
@@ -2258,6 +2257,7 @@ void
session_close_by_channel(int id, void *arg)
{
Session *s = session_by_channel(id);
+ u_int i;
if (s == NULL) {
debug("session_close_by_channel: no session for id %d", id);
@@ -2277,6 +2277,15 @@ session_close_by_channel(int id, void *arg)
}
/* detach by removing callback */
channel_cancel_cleanup(s->chanid);
+
+ /* Close any X11 listeners associated with this session */
+ if (s->x11_chanids != NULL) {
+ for (i = 0; s->x11_chanids[i] != -1; i++) {
+ session_close_x11(s->x11_chanids[i]);
+ s->x11_chanids[i] = -1;
+ }
+ }
+
s->chanid = -1;
session_close(s);
}
@@ -2371,7 +2380,7 @@ session_setup_x11fwd(Session *s)
}
for (i = 0; s->x11_chanids[i] != -1; i++) {
channel_register_cleanup(s->x11_chanids[i],
- session_close_single_x11);
+ session_close_single_x11, 0);
}
/* Set up a suitable value for the DISPLAY variable. */