version 1.181.2.1, 2005/09/04 18:40:03 |
version 1.181.2.2, 2006/02/03 02:53:45 |
|
|
{ |
{ |
setproctitle("%s", authctxt->pw->pw_name); |
setproctitle("%s", authctxt->pw->pw_name); |
|
|
/* |
|
* Cancel the alarm we set to limit the time taken for |
|
* authentication. |
|
*/ |
|
alarm(0); |
|
if (startup_pipe != -1) { |
|
close(startup_pipe); |
|
startup_pipe = -1; |
|
} |
|
/* setup the channel layer */ |
/* setup the channel layer */ |
if (!no_port_forwarding_flag && options.allow_tcp_forwarding) |
if (!no_port_forwarding_flag && options.allow_tcp_forwarding) |
channel_permit_all_opens(); |
channel_permit_all_opens(); |
|
|
endpwent(); |
endpwent(); |
|
|
/* |
/* |
* Close any extra open file descriptors so that we don\'t have them |
* Close any extra open file descriptors so that we don't have them |
* hanging around in clients. Note that we want to do this after |
* hanging around in clients. Note that we want to do this after |
* initgroups, because at least on Solaris 2.3 it leaves file |
* initgroups, because at least on Solaris 2.3 it leaves file |
* descriptors open. |
* descriptors open. |
|
|
} |
} |
#endif |
#endif |
|
|
/* Change current directory to the user\'s home directory. */ |
/* Change current directory to the user's home directory. */ |
if (chdir(pw->pw_dir) < 0) { |
if (chdir(pw->pw_dir) < 0) { |
fprintf(stderr, "Could not chdir to home directory %s: %s\n", |
fprintf(stderr, "Could not chdir to home directory %s: %s\n", |
pw->pw_dir, strerror(errno)); |
pw->pw_dir, strerror(errno)); |
|
|
|
|
if (s->auth_proto != NULL || s->auth_data != NULL) { |
if (s->auth_proto != NULL || s->auth_data != NULL) { |
error("session_x11_req: session %d: " |
error("session_x11_req: session %d: " |
"x11 fowarding already active", s->self); |
"x11 forwarding already active", s->self); |
return 0; |
return 0; |
} |
} |
s->single_connection = packet_get_char(); |
s->single_connection = packet_get_char(); |
|
|
{ |
{ |
Channel *c; |
Channel *c; |
|
|
if ((c = channel_lookup(id)) == NULL) { |
if ((c = channel_by_id(id)) == NULL) { |
debug("session_close_x11: x11 channel %d missing", id); |
debug("session_close_x11: x11 channel %d missing", id); |
} else { |
} else { |
/* Detach X11 listener */ |
/* Detach X11 listener */ |
|
|
session_exit_message(Session *s, int status) |
session_exit_message(Session *s, int status) |
{ |
{ |
Channel *c; |
Channel *c; |
u_int i; |
|
|
|
if ((c = channel_lookup(s->chanid)) == NULL) |
if ((c = channel_lookup(s->chanid)) == NULL) |
fatal("session_exit_message: session %d: no channel %d", |
fatal("session_exit_message: session %d: no channel %d", |
|
|
|
|
/* disconnect channel */ |
/* disconnect channel */ |
debug("session_exit_message: release channel %d", s->chanid); |
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 |
* emulate a write failure with 'chan_write_failed', nobody will be |
* interested in data we write. |
* interested in data we write. |
* Note that we must not call 'chan_read_failed', since there could |
* Note that we must not call 'chan_read_failed', since there could |
|
|
*/ |
*/ |
if (c->ostate != CHAN_OUTPUT_CLOSED) |
if (c->ostate != CHAN_OUTPUT_CLOSED) |
chan_write_failed(c); |
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 |
void |
|
|
} |
} |
if (s->chanid != -1) |
if (s->chanid != -1) |
session_exit_message(s, status); |
session_exit_message(s, status); |
session_close(s); |
if (s->ttyfd != -1) |
|
session_pty_cleanup(s); |
} |
} |
|
|
/* |
/* |
|
|
session_close_by_channel(int id, void *arg) |
session_close_by_channel(int id, void *arg) |
{ |
{ |
Session *s = session_by_channel(id); |
Session *s = session_by_channel(id); |
|
u_int i; |
|
|
if (s == NULL) { |
if (s == NULL) { |
debug("session_close_by_channel: no session for id %d", id); |
debug("session_close_by_channel: no session for id %d", id); |
|
|
} |
} |
/* detach by removing callback */ |
/* detach by removing callback */ |
channel_cancel_cleanup(s->chanid); |
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; |
s->chanid = -1; |
session_close(s); |
session_close(s); |
} |
} |
|
|
} |
} |
for (i = 0; s->x11_chanids[i] != -1; i++) { |
for (i = 0; s->x11_chanids[i] != -1; i++) { |
channel_register_cleanup(s->x11_chanids[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. */ |
/* Set up a suitable value for the DISPLAY variable. */ |