From ac89e98293bfa98465f329bb939f1045757dbc83 Mon Sep 17 00:00:00 2001 From: quamrulmina Date: Mon, 5 Oct 2015 15:46:37 -0500 Subject: [PATCH] add pty support to ssh client pty and tty support was not enabled or working in the code. Without pty support, ssh client was very non functional - e.g. openssh linux server prompt would not come through. Now ssh client works much better in interactive mode ( uses pty). --- clientloop.c | 1 + contrib/win32/win32compat/sfds.c | 6 ++++++ contrib/win32/win32compat/socket.c | 12 ++++++++---- session.c | 3 ++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/clientloop.c b/clientloop.c index eca508e..3d66b9b 100644 --- a/clientloop.c +++ b/clientloop.c @@ -2563,6 +2563,7 @@ 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*/); diff --git a/contrib/win32/win32compat/sfds.c b/contrib/win32/win32compat/sfds.c index e99dc31..f7b2331 100644 --- a/contrib/win32/win32compat/sfds.c +++ b/contrib/win32/win32compat/sfds.c @@ -264,6 +264,12 @@ int sfd_to_fd(int sfd) return sfd_map[sfd].fd; } +// set the sfd type to console. GetFileType() in Windows seem to return wrong type for a console returning PIPE (3) in place of CHARTYPE (2) +void sfd_set_to_console(int sfd) +{ + sfd_map[sfd].type = SFD_TYPE_CONSOLE; +} + /* * For an sfd, get the real handle behind it */ diff --git a/contrib/win32/win32compat/socket.c b/contrib/win32/win32compat/socket.c index 9317a4b..4e0b250 100644 --- a/contrib/win32/win32compat/socket.c +++ b/contrib/win32/win32compat/socket.c @@ -227,11 +227,11 @@ int WSHELPisatty(int sfd) * We can only do this for console fds. */ - if (sfd_is_console(sfd) && sfd > 0) + if (sfd_is_console(sfd) && sfd >= 0) { - ret = _isatty(sfd_to_fd(sfd)); + //ret = _isatty(sfd_to_fd(sfd)); - return ret; + return 1 ; //ret; } /* @@ -2825,7 +2825,11 @@ void allocate_standard_descriptor(int fd) { DBG_MSG("-> allocate_standard_descriptor(fd = %d)...\n", fd); - allocate_sfd(fd); + int asfd = allocate_sfd(fd); + + void sfd_set_to_console(int sfd); + if (asfd >= 0) + sfd_set_to_console(asfd); DBG_MSG("<- allocate_standard_descriptor()..."); } diff --git a/session.c b/session.c index 9830df1..730e253 100644 --- a/session.c +++ b/session.c @@ -1205,7 +1205,8 @@ do_exec_pty(Session *s, const char *command) * Win32 code. */ - return 0; + //return 0; + return do_exec_pty(s, command); #endif }