| 1463 |
&& grab_payload(pvar, originator_len = |
&& grab_payload(pvar, originator_len = |
| 1464 |
get_payload_uint32(pvar, 4))) { |
get_payload_uint32(pvar, 4))) { |
| 1465 |
FWD_X11_open(pvar, get_payload_uint32(pvar, 0), |
FWD_X11_open(pvar, get_payload_uint32(pvar, 0), |
| 1466 |
pvar->ssh_state.payload + 8, originator_len); |
pvar->ssh_state.payload + 8, originator_len, NULL); |
| 1467 |
} |
} |
| 1468 |
} else { |
} else { |
| 1469 |
if (grab_payload(pvar, 4)) { |
if (grab_payload(pvar, 4)) { |
| 1470 |
FWD_X11_open(pvar, get_payload_uint32(pvar, 0), NULL, 0); |
FWD_X11_open(pvar, get_payload_uint32(pvar, 0), NULL, 0, NULL); |
| 1471 |
} |
} |
| 1472 |
} |
} |
| 1473 |
|
|
| 2761 |
unsigned char FAR * auth_data, |
unsigned char FAR * auth_data, |
| 2762 |
int auth_data_len, int screen_num) |
int auth_data_len, int screen_num) |
| 2763 |
{ |
{ |
| 2764 |
int protocol_len = strlen(auth_protocol); |
if (SSHv1(pvar)) { |
| 2765 |
int data_len = auth_data_len * 2; |
int protocol_len = strlen(auth_protocol); |
| 2766 |
unsigned char FAR *outmsg = |
int data_len = auth_data_len * 2; |
| 2767 |
begin_send_packet(pvar, SSH_CMSG_X11_REQUEST_FORWARDING, |
unsigned char FAR *outmsg = |
| 2768 |
12 + protocol_len + data_len); |
begin_send_packet(pvar, SSH_CMSG_X11_REQUEST_FORWARDING, |
| 2769 |
int i; |
12 + protocol_len + data_len); |
| 2770 |
char FAR *auth_data_ptr; |
int i; |
| 2771 |
|
char FAR *auth_data_ptr; |
| 2772 |
|
|
| 2773 |
|
set_uint32(outmsg, protocol_len); |
| 2774 |
|
memcpy(outmsg + 4, auth_protocol, protocol_len); |
| 2775 |
|
set_uint32(outmsg + 4 + protocol_len, data_len); |
| 2776 |
|
auth_data_ptr = outmsg + 8 + protocol_len; |
| 2777 |
|
for (i = 0; i < auth_data_len; i++) { |
| 2778 |
|
sprintf(auth_data_ptr + i * 2, "%.2x", auth_data[i]); |
| 2779 |
|
} |
| 2780 |
|
set_uint32(outmsg + 8 + protocol_len + data_len, screen_num); |
| 2781 |
|
|
| 2782 |
set_uint32(outmsg, protocol_len); |
finish_send_packet(pvar); |
|
memcpy(outmsg + 4, auth_protocol, protocol_len); |
|
|
set_uint32(outmsg + 4 + protocol_len, data_len); |
|
|
auth_data_ptr = outmsg + 8 + protocol_len; |
|
|
for (i = 0; i < auth_data_len; i++) { |
|
|
sprintf(auth_data_ptr + i * 2, "%.2x", auth_data[i]); |
|
|
} |
|
|
set_uint32(outmsg + 8 + protocol_len + data_len, screen_num); |
|
| 2783 |
|
|
| 2784 |
finish_send_packet(pvar); |
enque_forwarding_request_handlers(pvar); |
| 2785 |
|
|
| 2786 |
|
} else { |
| 2787 |
|
// SSH2: X11 port-forwarding (2005.7.2 yutaka) |
| 2788 |
|
buffer_t *msg; |
| 2789 |
|
char *s; |
| 2790 |
|
unsigned char *outmsg; |
| 2791 |
|
int len; |
| 2792 |
|
Channel_t *c; |
| 2793 |
|
int newlen; |
| 2794 |
|
char *newdata; |
| 2795 |
|
int i; |
| 2796 |
|
|
| 2797 |
|
msg = buffer_init(); |
| 2798 |
|
if (msg == NULL) { |
| 2799 |
|
// TODO: error check |
| 2800 |
|
return; |
| 2801 |
|
} |
| 2802 |
|
|
| 2803 |
|
c = ssh2_channel_lookup(pvar->shell_id); |
| 2804 |
|
if (c == NULL) |
| 2805 |
|
return; |
| 2806 |
|
|
| 2807 |
|
// making the fake data |
| 2808 |
|
newlen = 2 * auth_data_len + 1; |
| 2809 |
|
newdata = malloc(newlen); |
| 2810 |
|
if (newdata == NULL) |
| 2811 |
|
return; |
| 2812 |
|
for (i = 0 ; i < auth_data_len ; i++) { |
| 2813 |
|
_snprintf(newdata + i*2, newlen - i*2, "%02x", auth_data[i]); |
| 2814 |
|
} |
| 2815 |
|
newdata[newlen - 1] = '\0'; |
| 2816 |
|
|
| 2817 |
|
buffer_put_int(msg, c->remote_id); |
| 2818 |
|
s = "x11-req"; |
| 2819 |
|
buffer_put_string(msg, s, strlen(s)); // service name |
| 2820 |
|
buffer_put_char(msg, 0); // want confirm (false) |
| 2821 |
|
buffer_put_char(msg, 0); // XXX bool single connection |
| 2822 |
|
|
| 2823 |
|
s = auth_protocol; // MIT-MAGIC-COOKIE-1 |
| 2824 |
|
buffer_put_string(msg, s, strlen(s)); |
| 2825 |
|
s = newdata; |
| 2826 |
|
buffer_put_string(msg, s, strlen(s)); |
| 2827 |
|
|
| 2828 |
|
buffer_put_int(msg, screen_num); |
| 2829 |
|
|
| 2830 |
|
len = buffer_len(msg); |
| 2831 |
|
outmsg = begin_send_packet(pvar, SSH2_MSG_CHANNEL_REQUEST, len); |
| 2832 |
|
memcpy(outmsg, buffer_ptr(msg), len); |
| 2833 |
|
finish_send_packet(pvar); |
| 2834 |
|
buffer_free(msg); |
| 2835 |
|
|
| 2836 |
|
free(newdata); |
| 2837 |
|
} |
| 2838 |
|
|
|
enque_forwarding_request_handlers(pvar); |
|
| 2839 |
} |
} |
| 2840 |
|
|
| 2841 |
void SSH_open_channel(PTInstVar pvar, uint32 local_channel_num, |
void SSH_open_channel(PTInstVar pvar, uint32 local_channel_num, |
| 5370 |
// 認証OK |
// 認証OK |
| 5371 |
pvar->userauth_success = 1; |
pvar->userauth_success = 1; |
| 5372 |
|
|
|
// ポートフォワーディングの準備 (2005.2.26, 2005.6.21 yutaka) |
|
|
FWD_prep_forwarding(pvar); |
|
|
FWD_enter_interactive_mode(pvar); |
|
|
|
|
|
// ディスパッチルーチンの再設定 |
|
|
do_SSH2_dispatch_setup_for_transfer(pvar); |
|
|
|
|
|
|
|
| 5373 |
// チャネル設定 |
// チャネル設定 |
| 5374 |
|
// FWD_prep_forwarding()でshell IDを使うので、先に設定を持ってくる。(2005.7.3 yutaka) |
| 5375 |
c = ssh2_channel_new(CHAN_SES_WINDOW_DEFAULT, CHAN_SES_PACKET_DEFAULT, TYPE_SHELL, -1); |
c = ssh2_channel_new(CHAN_SES_WINDOW_DEFAULT, CHAN_SES_PACKET_DEFAULT, TYPE_SHELL, -1); |
| 5376 |
if (c == NULL) { |
if (c == NULL) { |
| 5377 |
// TODO: error check |
// TODO: error check |
| 5378 |
return FALSE; |
return FALSE; |
| 5379 |
} |
} |
|
|
|
| 5380 |
// シェルのIDを取っておく |
// シェルのIDを取っておく |
| 5381 |
pvar->shell_id = c->self_id; |
pvar->shell_id = c->self_id; |
| 5382 |
|
|
| 5383 |
|
// ディスパッチルーチンの再設定 |
| 5384 |
|
do_SSH2_dispatch_setup_for_transfer(pvar); |
| 5385 |
|
|
| 5386 |
// シェルオープン |
// シェルオープン |
| 5387 |
msg = buffer_init(); |
msg = buffer_init(); |
| 5388 |
if (msg == NULL) { |
if (msg == NULL) { |
| 5594 |
c->remote_maxpacket = get_uint32_MSBfirst(data); |
c->remote_maxpacket = get_uint32_MSBfirst(data); |
| 5595 |
data += 4; |
data += 4; |
| 5596 |
|
|
| 5597 |
|
// ポートフォワーディングの準備 (2005.2.26, 2005.6.21 yutaka) |
| 5598 |
|
// シェルオープンしたあとに X11 の要求を出さなくてはならない。(2005.7.3 yutaka) |
| 5599 |
|
FWD_prep_forwarding(pvar); |
| 5600 |
|
FWD_enter_interactive_mode(pvar); |
| 5601 |
|
|
| 5602 |
if (c->type == TYPE_PORTFWD) { |
if (c->type == TYPE_PORTFWD) { |
| 5603 |
// port-forwadingの"direct-tcpip"が成功。 |
// port-forwadingの"direct-tcpip"が成功。 |
| 5604 |
FWD_confirmed_open(pvar, c->local_num, -1); |
FWD_confirmed_open(pvar, c->local_num, -1); |
| 5964 |
c->remote_maxpacket = remote_maxpacket; |
c->remote_maxpacket = remote_maxpacket; |
| 5965 |
|
|
| 5966 |
} else if (strcmp(ctype, "x11") == 0) { // port-forwarding(X11) |
} else if (strcmp(ctype, "x11") == 0) { // port-forwarding(X11) |
| 5967 |
|
// X applicationをターミナル上で実行すると、SSH2_MSG_CHANNEL_OPEN が送られてくる。 |
| 5968 |
|
char *orig_str; |
| 5969 |
|
int orig_port; |
| 5970 |
|
|
| 5971 |
|
orig_str = buffer_get_string(&data, NULL); // "127.0.0.1" |
| 5972 |
|
orig_port = get_uint32_MSBfirst(data); |
| 5973 |
|
data += 4; |
| 5974 |
|
free(orig_str); |
| 5975 |
|
|
| 5976 |
|
// X server(port 6000)へ接続する。接続に失敗するとTeraTerm自身が切断される。 |
| 5977 |
|
// TODO: 将来、切断されないようにしたい。(2005.7.3 yutaka) |
| 5978 |
|
FWD_X11_open(pvar, remote_id, NULL, 0, &chan_num); |
| 5979 |
|
|
| 5980 |
|
// channelをアロケートし、必要な情報(remote window size)をここで取っておく。 |
| 5981 |
|
c = ssh2_channel_new(CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, TYPE_PORTFWD, chan_num); |
| 5982 |
|
c->remote_id = remote_id; |
| 5983 |
|
c->remote_window = remote_window; |
| 5984 |
|
c->remote_maxpacket = remote_maxpacket; |
| 5985 |
|
|
| 5986 |
} else { |
} else { |
| 5987 |
// unknown type(unsupported) |
// unknown type(unsupported) |
| 6190 |
|
|
| 6191 |
/* |
/* |
| 6192 |
* $Log: not supported by cvs2svn $ |
* $Log: not supported by cvs2svn $ |
| 6193 |
|
* Revision 1.31 2005/07/02 08:43:32 yutakakn |
| 6194 |
|
* SSH2_MSG_CHANNEL_OPEN_FAILURE ハンドラを追加した。 |
| 6195 |
|
* |
| 6196 |
* Revision 1.30 2005/07/02 07:56:13 yutakakn |
* Revision 1.30 2005/07/02 07:56:13 yutakakn |
| 6197 |
* update SSH2 port-forwading(remote to local) |
* update SSH2 port-forwading(remote to local) |
| 6198 |
* |
* |