version 1.139, 2005/06/17 02:44:32 |
version 1.140, 2005/07/04 00:58:43 |
|
|
struct confirm_ctx { |
struct confirm_ctx { |
int want_tty; |
int want_tty; |
int want_subsys; |
int want_subsys; |
|
int want_x_fwd; |
|
int want_agent_fwd; |
Buffer cmd; |
Buffer cmd; |
char *term; |
char *term; |
struct termios tio; |
struct termios tio; |
|
|
client_extra_session2_setup(int id, void *arg) |
client_extra_session2_setup(int id, void *arg) |
{ |
{ |
struct confirm_ctx *cctx = arg; |
struct confirm_ctx *cctx = arg; |
|
const char *display; |
Channel *c; |
Channel *c; |
int i; |
int i; |
|
|
|
|
if ((c = channel_lookup(id)) == NULL) |
if ((c = channel_lookup(id)) == NULL) |
fatal("%s: no channel for id %d", __func__, id); |
fatal("%s: no channel for id %d", __func__, id); |
|
|
|
display = getenv("DISPLAY"); |
|
if (cctx->want_x_fwd && options.forward_x11 && display != NULL) { |
|
char *proto, *data; |
|
/* Get reasonable local authentication information. */ |
|
client_x11_get_proto(display, options.xauth_location, |
|
options.forward_x11_trusted, &proto, &data); |
|
/* Request forwarding with authentication spoofing. */ |
|
debug("Requesting X11 forwarding with authentication spoofing."); |
|
x11_request_forwarding_with_spoofing(id, display, proto, data); |
|
/* XXX wait for reply */ |
|
} |
|
|
|
if (cctx->want_agent_fwd && options.forward_agent) { |
|
debug("Requesting authentication agent forwarding."); |
|
channel_request_start(id, "auth-agent-req@openssh.com", 0); |
|
packet_send(); |
|
} |
|
|
client_session2_setup(id, cctx->want_tty, cctx->want_subsys, |
client_session2_setup(id, cctx->want_tty, cctx->want_subsys, |
cctx->term, &cctx->tio, c->rfd, &cctx->cmd, cctx->env, |
cctx->term, &cctx->tio, c->rfd, &cctx->cmd, cctx->env, |
client_subsystem_reply); |
client_subsystem_reply); |
|
|
buffer_free(&m); |
buffer_free(&m); |
return; |
return; |
} |
} |
if ((ver = buffer_get_char(&m)) != 1) { |
if ((ver = buffer_get_char(&m)) != SSHMUX_VER) { |
error("%s: wrong client version %d", __func__, ver); |
error("%s: wrong client version %d", __func__, ver); |
buffer_free(&m); |
buffer_free(&m); |
close(client_fd); |
close(client_fd); |
|
|
buffer_clear(&m); |
buffer_clear(&m); |
buffer_put_int(&m, allowed); |
buffer_put_int(&m, allowed); |
buffer_put_int(&m, getpid()); |
buffer_put_int(&m, getpid()); |
if (ssh_msg_send(client_fd, /* version */1, &m) == -1) { |
if (ssh_msg_send(client_fd, SSHMUX_VER, &m) == -1) { |
error("%s: client msg_send failed", __func__); |
error("%s: client msg_send failed", __func__); |
close(client_fd); |
close(client_fd); |
buffer_free(&m); |
buffer_free(&m); |
|
|
buffer_clear(&m); |
buffer_clear(&m); |
buffer_put_int(&m, allowed); |
buffer_put_int(&m, allowed); |
buffer_put_int(&m, getpid()); |
buffer_put_int(&m, getpid()); |
if (ssh_msg_send(client_fd, /* version */1, &m) == -1) { |
if (ssh_msg_send(client_fd, SSHMUX_VER, &m) == -1) { |
error("%s: client msg_send failed", __func__); |
error("%s: client msg_send failed", __func__); |
close(client_fd); |
close(client_fd); |
buffer_free(&m); |
buffer_free(&m); |
|
|
buffer_free(&m); |
buffer_free(&m); |
return; |
return; |
} |
} |
if ((ver = buffer_get_char(&m)) != 1) { |
if ((ver = buffer_get_char(&m)) != SSHMUX_VER) { |
error("%s: wrong client version %d", __func__, ver); |
error("%s: wrong client version %d", __func__, ver); |
buffer_free(&m); |
buffer_free(&m); |
close(client_fd); |
close(client_fd); |
|
|
memset(cctx, 0, sizeof(*cctx)); |
memset(cctx, 0, sizeof(*cctx)); |
cctx->want_tty = (flags & SSHMUX_FLAG_TTY) != 0; |
cctx->want_tty = (flags & SSHMUX_FLAG_TTY) != 0; |
cctx->want_subsys = (flags & SSHMUX_FLAG_SUBSYS) != 0; |
cctx->want_subsys = (flags & SSHMUX_FLAG_SUBSYS) != 0; |
|
cctx->want_x_fwd = (flags & SSHMUX_FLAG_X11_FWD) != 0; |
|
cctx->want_agent_fwd = (flags & SSHMUX_FLAG_AGENT_FWD) != 0; |
cctx->term = buffer_get_string(&m, &len); |
cctx->term = buffer_get_string(&m, &len); |
|
|
cmd = buffer_get_string(&m, &len); |
cmd = buffer_get_string(&m, &len); |
|
|
|
|
/* This roundtrip is just for synchronisation of ttymodes */ |
/* This roundtrip is just for synchronisation of ttymodes */ |
buffer_clear(&m); |
buffer_clear(&m); |
if (ssh_msg_send(client_fd, /* version */1, &m) == -1) { |
if (ssh_msg_send(client_fd, SSHMUX_VER, &m) == -1) { |
error("%s: client msg_send failed", __func__); |
error("%s: client msg_send failed", __func__); |
close(client_fd); |
close(client_fd); |
close(new_fd[0]); |
close(new_fd[0]); |