• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++objective-ccocoa誰得c#linuxgamebathyscaphephp翻訳qtpythonrubycwindowsomegattwitterguiframeworkbtronarduinovb.netdirectxtestゲームエンジンdom計画中(planning stage)previewer

Tera Termの個人的な作業用リポジトリ


Commit MetaInfo

Revision95e3ce091311c40b287555b840337781a078b26e (tree)
Time2018-05-29 21:27:47
AuthorIWAMOTO Kouichi <sue@iwmt...>
CommiterIWAMOTO Kouichi

Log Message

Remoto unix-domain socket to local tcp port の転送テスト

RtoL の転送で、bind address に unix-domain socket のパスを、
remote port に 0 を指定すると unix-domain socket の転送と見做す。

Change Summary

Incremental Difference

--- a/teraterm/common/servicenames.c
+++ b/teraterm/common/servicenames.c
@@ -401,7 +401,7 @@ int PASCAL parse_port_from_buf(char * buf)
401401 }
402402 else if (isdigit(buf[0])) {
403403 int result = atoi(buf);
404- if (result > 0 && result < 65536) {
404+ if (result >= 0 && result < 65536) {
405405 return result;
406406 }
407407 }
--- a/ttssh2/ttxssh/fwdui.c
+++ b/ttssh2/ttxssh/fwdui.c
@@ -935,7 +935,7 @@ static BOOL end_fwd_edit_dlg(PTInstVar pvar, FWDRequestSpec *spec, HWND dlg)
935935 }
936936
937937 new_spec.from_port = parse_port_from_buf(new_spec.from_port_name);
938- if (new_spec.from_port < 0) {
938+ if (new_spec.from_port < 0 || new_spec.from_port == 0 && (type != FWD_REMOTE_TO_LOCAL || new_spec.bind_address[0] != '/')) {
939939 UTIL_get_lang_msg("MSG_INVALID_PORT_ERROR", pvar,
940940 "Port \"%s\" is not a valid port number.\n"
941941 "Either choose a port name from the list, or enter a number between 1 and 65535.");
@@ -947,7 +947,7 @@ static BOOL end_fwd_edit_dlg(PTInstVar pvar, FWDRequestSpec *spec, HWND dlg)
947947
948948 if (type == FWD_LOCAL_TO_REMOTE || type == FWD_REMOTE_TO_LOCAL) {
949949 new_spec.to_port = parse_port_from_buf(new_spec.to_port_name);
950- if (new_spec.to_port < 0) {
950+ if (new_spec.to_port < 1) {
951951 UTIL_get_lang_msg("MSG_INVALID_PORT_ERROR", pvar,
952952 "Port \"%s\" is not a valid port number.\n"
953953 "Either choose a port name from the list, or enter a number between 1 and 65535.");
--- a/ttssh2/ttxssh/ssh.c
+++ b/ttssh2/ttxssh/ssh.c
@@ -3736,12 +3736,21 @@ void SSH_request_forwarding(PTInstVar pvar, char *bind_address, int from_server_
37363736 logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
37373737 return;
37383738 }
3739- req = "tcpip-forward";
3740- buffer_put_string(msg, req, strlen(req)); // ctype
3741- buffer_put_char(msg, 1); // want reply
3742- buffer_put_string(msg, bind_address, strlen(bind_address));
37433739
3744- buffer_put_int(msg, from_server_port); // listening port
3740+ if (bind_address[0] == '/' && from_server_port == 0) {
3741+ req = "streamlocal-forward@openssh.com";
3742+ buffer_put_string(msg, req, strlen(req)); // ctype
3743+ buffer_put_char(msg, 1); // want reply
3744+ buffer_put_string(msg, bind_address, strlen(bind_address));
3745+ }
3746+ else {
3747+ req = "tcpip-forward";
3748+ buffer_put_string(msg, req, strlen(req)); // ctype
3749+ buffer_put_char(msg, 1); // want reply
3750+ buffer_put_string(msg, bind_address, strlen(bind_address));
3751+
3752+ buffer_put_int(msg, from_server_port); // listening port
3753+ }
37453754
37463755 len = buffer_len(msg);
37473756 outmsg = begin_send_packet(pvar, SSH2_MSG_GLOBAL_REQUEST, len);
@@ -9007,6 +9016,41 @@ static BOOL handle_SSH2_channel_open(PTInstVar pvar)
90079016 free(listen_addr);
90089017 free(orig_addr);
90099018
9019+ }
9020+ else if (strcmp(ctype, "forwarded-streamlocal@openssh.com") == 0) {
9021+ char *socket_path, *reserved_str;
9022+
9023+ logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": channel type=%s", ctype);
9024+
9025+ socket_path = buffer_get_string(&data, &buflen);
9026+ reserved_str = buffer_get_string(&data, &buflen);
9027+
9028+ if (socket_path && reserved_str) {
9029+ logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__
9030+ ": %s: socket_path=%s, reserved_str=%s",
9031+ ctype, socket_path, reserved_str);
9032+ FWD_open(pvar, remote_id, socket_path, 0, socket_path, 0, &chan_num);
9033+
9034+ c = ssh2_channel_new(CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, TYPE_PORTFWD, chan_num);
9035+ if (c == NULL) {
9036+ FWD_free_channel(pvar, chan_num);
9037+ UTIL_get_lang_msg("MSG_SSH_NO_FREE_CHANNEL", pvar,
9038+ "Could not open new channel. TTSSH is already opening too many channels.");
9039+ notify_nonfatal_error(pvar, pvar->ts->UIMsg);
9040+ return FALSE;
9041+ }
9042+ c->remote_id = remote_id;
9043+ c->remote_window = remote_window;
9044+ c->remote_maxpacket = remote_maxpacket;
9045+ }
9046+ else {
9047+ logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": %s: buffer_get_string returns NULL. "
9048+ "socket_path=%s, reserved_str=%s",
9049+ ctype, NonNull(socket_path), NonNull(reserved_str));
9050+ }
9051+ free(socket_path);
9052+ free(reserved_str);
9053+
90109054 } else if (strcmp(ctype, "x11") == 0) { // port-forwarding(X11)
90119055 // X applicationをターミナル上で実行すると、SSH2_MSG_CHANNEL_OPEN が送られてくる。
90129056 char *orig_str;