diff --git a/include/telnet.h b/include/telnet.h index 16a3096baf..9e6b968dbf 100644 --- a/include/telnet.h +++ b/include/telnet.h @@ -31,7 +31,10 @@ #define CMD_WONT 252 #define CMD_DO 253 #define CMD_DONT 254 +#define CMD_SB 250 +#define CMD_SE 240 #define OPT_SGA 3 +#define OPT_NAWS 31 int telnet_test_login(ZBX_SOCKET socket_fd); int telnet_login(ZBX_SOCKET socket_fd, const char *username, const char *password, AGENT_RESULT *result); diff --git a/src/libs/zbxcomms/telnet.c b/src/libs/zbxcomms/telnet.c index 76d8f9f98a..5e7bcc1412 100644 --- a/src/libs/zbxcomms/telnet.c +++ b/src/libs/zbxcomms/telnet.c @@ -171,6 +171,20 @@ static ssize_t telnet_read(ZBX_SOCKET socket_fd, char *buf, size_t *buf_left, si zabbix_log(LOG_LEVEL_DEBUG, "%s() c3:%x", __func__, c3); + /* Order 'Do Negotiate About Window Size' */ + if (CMD_DO == c2 && OPT_NAWS == c3) + { + unsigned char will_naws[] = {CMD_IAC, CMD_WILL, OPT_NAWS}; + unsigned char large_ws[] = {CMD_IAC, CMD_SB, OPT_NAWS, + 0x05, 0x00, 0x00, 0x78, /* width = 1280, height = 120 */ + CMD_IAC, CMD_SE}; + telnet_socket_write(socket_fd, will_naws, + sizeof(will_naws)/sizeof(unsigned char)); + telnet_socket_write(socket_fd, large_ws, + sizeof(large_ws)/sizeof(unsigned char)); + break; + } + /* reply to all options with "WONT" or "DONT", */ /* unless it is Suppress Go Ahead (SGA) */