ssh.exe client sends current window size and TERM value when pty-req is made

This was not coded before for Win32 port. Remote sshd server is now
aware of our client's screen size and VT/ANSI TERM emulation.
This commit is contained in:
quamrulmina 2015-10-20 18:24:52 -05:00
parent f1d8b2e72d
commit de4ae13f76
4 changed files with 67 additions and 10 deletions

View File

@ -3913,10 +3913,11 @@ channel_connect_to_path(const char *path, char *ctype, char *rname)
return connect_to(path, PORT_STREAMLOCAL, ctype, rname);
}
#ifndef WIN32_FIXME
void
channel_send_window_changes(void)
{
#ifndef WIN32_FIXME
u_int i;
struct winsize ws;
@ -3933,9 +3934,30 @@ channel_send_window_changes(void)
packet_put_int((u_int)ws.ws_ypixel);
packet_send();
}
#endif
}
#else // WIN32_FIXME
void
channel_send_window_changes(int col, int row, int xpixel, int ypixel)
{
u_int i;
struct winsize ws;
for (i = 0; i < channels_alloc; i++) {
if (channels[i] == NULL || !channels[i]->client_tty ||
channels[i]->type != SSH_CHANNEL_OPEN)
continue;
channel_request_start(i, "window-change", 0);
packet_put_int((u_int)col);
packet_put_int((u_int)row);
packet_put_int((u_int)xpixel);
packet_put_int((u_int)ypixel);
packet_send();
}
}
#endif
/* -- X11 forwarding */
/*

View File

@ -226,7 +226,12 @@ void channel_register_status_confirm(int, channel_confirm_cb *,
channel_confirm_abandon_cb *, void *);
void channel_cancel_cleanup(int);
int channel_close_fd(int *);
#ifndef WIN32_FIXME
void channel_send_window_changes(void);
#else
void channel_send_window_changes(int, int, int, int);
#endif
/* protocol handler */

View File

@ -119,6 +119,12 @@
#include <sys/stat.h>
#define isatty(a) WSHELPisatty(a)
// Windows Console screen size change related
extern int ScreenX;
extern int ScrollBottom;
int win_received_window_change_signal = 1;
#endif
/* import options */
@ -563,6 +569,25 @@ client_check_window_change(void)
packet_put_int((u_int)ws.ws_ypixel);
packet_send();
}
#else
if (! win_received_window_change_signal)
return;
/** XXX race */
win_received_window_change_signal = 0;
debug2("client_check_window_change: changed");
if (compat20) {
channel_send_window_changes(ScreenX, ScrollBottom, 640, 480);
} else {
packet_start(SSH_CMSG_WINDOW_SIZE);
packet_put_int((u_int)ScreenX);
packet_put_int((u_int)ScrollBottom);
packet_put_int((u_int)640);
packet_put_int((u_int)480);
packet_send();
}
#endif /* !WIN32_FIXME */
}
@ -2571,11 +2596,11 @@ client_session2_setup(int id, int want_tty, int want_subsystem,
tty_make_modes(-1, tiop);
#else
packet_put_cstring(term != NULL ? term : "");
packet_put_int((u_int) 80 /*ws.ws_col*/);
packet_put_int((u_int) 25 /*ws.ws_row*/);
packet_put_int((u_int) 640 /*ws.ws_xpixel*/);
packet_put_int((u_int) 480 /*ws.ws_ypixel*/);
packet_put_cstring(term != NULL ? term : "vt220");
packet_put_int((u_int) ScreenX);
packet_put_int((u_int) ScrollBottom);
packet_put_int((u_int) 640);
packet_put_int((u_int) 480);
tty_make_modes(-1, NULL);
#endif /* else !WIN32_FIXME */
packet_send();

11
ssh.c
View File

@ -580,6 +580,7 @@ set_addrinfo_port(struct addrinfo *addrs, int port)
/*
* Main program for the ssh client.
*/
int
main(int ac, char **av)
{
@ -606,9 +607,6 @@ main(int ac, char **av)
* parent server is stopped.
*/
AllocConsole();
ConInit( STD_OUTPUT_HANDLE, TRUE );
SetConsoleCtrlHandler(CtrlHandlerRoutine, TRUE);
/*
@ -1502,6 +1500,13 @@ main(int ac, char **av)
}
}
#ifdef WIN32_FIXME
if (tty_flag) {
//AllocConsole();
ConInit( STD_OUTPUT_HANDLE, TRUE );
}
#endif
exit_status = compat20 ? ssh_session2() : ssh_session();
packet_close();