Bugzilla – Attachment 967 Details for
Bug 1086
X forwarding won't start when a command is executed in background
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Improved fix
session-x11-detach3.diff (text/plain), 5.94 KB, created by
Damien Miller
on 2005-09-26 21:43:38 AEST
(
hide
)
Description:
Improved fix
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2005-09-26 21:43:38 AEST
Size:
5.94 KB
patch
obsolete
>Index: channels.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/channels.c,v >retrieving revision 1.224 >diff -u -p -r1.224 channels.c >--- channels.c 7 Sep 2005 08:53:53 -0000 1.224 >+++ channels.c 26 Sep 2005 11:40:23 -0000 >@@ -268,6 +268,7 @@ channel_new(char *ctype, int type, int r > c->force_drain = 0; > c->single_connection = 0; > c->detach_user = NULL; >+ c->detach_close = 0; > c->confirm = NULL; > c->confirm_ctx = NULL; > c->input_filter = NULL; >@@ -627,7 +628,7 @@ channel_register_confirm(int id, channel > c->confirm_ctx = ctx; > } > void >-channel_register_cleanup(int id, channel_callback_fn *fn) >+channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) > { > Channel *c = channel_lookup(id); > >@@ -636,6 +637,7 @@ channel_register_cleanup(int id, channel > return; > } > c->detach_user = fn; >+ c->detach_close = do_close; > } > void > channel_cancel_cleanup(int id) >@@ -647,6 +649,7 @@ channel_cancel_cleanup(int id) > return; > } > c->detach_user = NULL; >+ c->detach_close = 0; > } > void > channel_register_filter(int id, channel_filter_fn *fn) >@@ -1660,7 +1676,7 @@ channel_garbage_collect(Channel *c) > if (c == NULL) > return; > if (c->detach_user != NULL) { >- if (!chan_is_dead(c, 0)) >+ if (!chan_is_dead(c, c->detach_close)) > return; > debug2("channel %d: gc: notify user", c->self); > c->detach_user(c->self, NULL); >Index: channels.h >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/channels.h,v >retrieving revision 1.79 >diff -u -p -r1.79 channels.h >--- channels.h 17 Jul 2005 06:49:04 -0000 1.79 >+++ channels.h 26 Sep 2005 11:40:23 -0000 >@@ -105,8 +105,9 @@ struct Channel { > > /* callback */ > channel_callback_fn *confirm; >- channel_callback_fn *detach_user; > void *confirm_ctx; >+ channel_callback_fn *detach_user; >+ int detach_close; > > /* filter */ > channel_filter_fn *input_filter; >@@ -162,7 +163,7 @@ void channel_stop_listening(void); > > void channel_send_open(int); > void channel_request_start(int, char *, int); >-void channel_register_cleanup(int, channel_callback_fn *); >+void channel_register_cleanup(int, channel_callback_fn *, int); > void channel_register_confirm(int, channel_callback_fn *, void *); > void channel_register_filter(int, channel_filter_fn *); > void channel_cancel_cleanup(int); >Index: clientloop.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/clientloop.c,v >retrieving revision 1.142 >diff -u -p -r1.142 clientloop.c >--- clientloop.c 9 Sep 2005 19:18:05 -0000 1.142 >+++ clientloop.c 26 Sep 2005 11:40:25 -0000 >@@ -1379,7 +1379,7 @@ client_loop(int have_pty, int escape_cha > simple_escape_filter); > if (session_ident != -1) > channel_register_cleanup(session_ident, >- client_channel_closed); >+ client_channel_closed, 0); > } else { > /* Check if we should immediately send eof on stdin. */ > client_check_initial_eof_on_stdin(); >Index: serverloop.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/serverloop.c,v >retrieving revision 1.118 >diff -u -p -r1.118 serverloop.c >--- serverloop.c 17 Jul 2005 07:17:55 -0000 1.118 >+++ serverloop.c 26 Sep 2005 11:40:25 -0000 >@@ -898,7 +898,7 @@ server_request_session(void) > channel_free(c); > return NULL; > } >- channel_register_cleanup(c->self, session_close_by_channel); >+ channel_register_cleanup(c->self, session_close_by_channel, 0); > return c; > } > >Index: session.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/session.c,v >retrieving revision 1.186 >diff -u -p -r1.186 session.c >--- session.c 25 Jul 2005 11:59:40 -0000 1.186 >+++ session.c 26 Sep 2005 11:40:27 -0000 >@@ -1792,7 +1792,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", >@@ -1818,7 +1817,15 @@ session_exit_message(Session *s, int sta > > /* 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. >@@ -1827,15 +1834,6 @@ session_exit_message(Session *s, int sta > */ > 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 >@@ -1879,7 +1877,8 @@ session_close_by_pid(pid_t pid, int stat > } > if (s->chanid != -1) > session_exit_message(s, status); >- session_close(s); >+ if (s->ttyfd != -1) >+ session_pty_cleanup(s); > } > > /* >@@ -1890,6 +1889,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); >@@ -1909,6 +1909,15 @@ session_close_by_channel(int id, void *a > } > /* 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); > } >@@ -1994,7 +2003,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. */
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
Flags:
dtucker
:
ok+
Actions:
View
|
Diff
Attachments on
bug 1086
:
964
|
965
| 967