Commit Graph

26 Commits

Author SHA1 Message Date
Bryan Berns 18884b29fd Addressed Thread Hanging Issue (#374)
- Replaced TerminateThread() call with an interrupt routine to gracefully call _endthreadex(0).
- Resolves https://github.com/PowerShell/Win32-OpenSSH/issues/1338.
2019-05-21 13:56:59 -07:00
Manoj Ampalam bfd4ddf194
Account for dev/null being reported as a terminal handle
https://github.com/PowerShell/Win32-OpenSSH/issues/1330

Issue: open(dev/nul) returns a handle is passes isatty() test (i.e its being treated as a terminal handle by OS). This handle seems to work fine for as a console handle for console APIs, except when NUL is explicitly redirected. 
This works
ssh -n target hostname

but this hangs due to a deadlock from writing a log entry on a console API failure
ssh -n target hostname < NUL

Fix: Ignore console API failures when the handle is being reported as invalid.
2019-05-21 13:25:49 -07:00
Manoj Ampalam 68ad673db4
Workaround for PTY regressions
Changes from #353 enabled closing of previously duplicated Console handles - this is causing TTY rendering issues in ssh.exe.
Added a workaround for now to skip closing Console handles.
2019-01-11 12:19:39 -08:00
Manoj Ampalam 83bff88b24
Fix Console handle leaks (#357)
Issue: Earlier change missed "return" calls that will end up ignoring singleton logic and re-running console handle generation logic multiple times, leaking previously created handles in the process.

Fix: Add the missing "return" calls
2018-11-15 13:33:22 -08:00
Manoj Ampalam cc16f80123
Converge fork and upstream branches
- Removed #ifdef WINDOWS blocks in base code where the feature support can be conveyed by a failed POSIX API call
- Refactored password authentication code
- Other misc changes - Removed DebugBreak on Release Builds
2018-10-30 14:54:13 -07:00
Manoj Ampalam af4e4113b2
Ported bash based E2E tests and integrated security fix for cve-2018-15473(#346)
- Updated code to dynamic load Lsa functions until RS5 SDK includes them
 - Add conpty support in openssh
- Fixed Wierd characters (?25l) are seen, when logged in from ssh client
- Backspace doesn't work in powershell window
- Changes to support ssh-shellhost as an alternative shell
- Added support to have ssh-shellhost work as a standby shell (ssh-shellhost -c "cmdline") simply executes cmdline via CreateProcess
- Added E2E test cases and fixed unittests broken from prior changes
- Added PTY launch interface that supports both conpty and ssh-shellhost pty.
- Implemented PTY control channel in ssh-shellhost that supports Window resize events.
- Fixed regression with starting a PTY session with an explicit command
- modified ssh-shellhost pty argument to ---pty to remove ambiguity in cases when both -p and -c are present in commandline. Ex. ssh-shellhost.exe -c "myprogram -p -c argument"
2018-10-04 14:16:02 -07:00
Bryan Berns ec102dce28 Alternate Thread Creation API To Avoid Memory Leaks (#306)
* Alternate Thread Creation API To Avoid Memory Leaks

- Switched from CreateThread() to _beginthreadex() and ExitThread() to _endthreadex() in order to avoid potential leaks when linking with static CRT library.
- Addressed a variety of warnings that were being detected with static code analysis.

* Addressed Type Cast Warning

- Added explicit cast to the output of _beginthreadex() to avoid a compiler warning.

* Indentation Fix
2018-05-23 16:53:36 -07:00
Bryan Berns bd6408058a Reworked Path Resolution Function
- Reworked resolved_path() into resolved_path_utf16() that combined utf16 conversion and path conditioning into a single function.  This eliminated the previously non-threadsafe resolved_path() function.
- Adjusted functions to use resolved_path_utf16().
- Collapsed copy_file() function that was only used once.
- Corrected compilation errors when debug4() and debug5() are enabled.
2018-04-01 23:41:09 -04:00
Manoj Ampalam fdd54b6334
Implement Unix styled privilege separation in Windows (#258)
OpenSSh privilege separation model - http://www.citi.umich.edu/u/provos/ssh/privsep.html 
Posix_spawn is implemented in POSIX adapter as an alternative to fork() that is heavily used in Privilege separation. 
Additional state info is added to sshd to accommodate distinguishing the various modes (privileged monitor, unprivileged child, authenticated child).
Required service state (like config and host keys) is transmitted over pipes from monitor to child processes.
Changes to installation scripts and tests to accomodate new architectural changes
2018-01-15 13:57:31 -08:00
Manoj Ampalam 4edff78b9d
Fixed issue in POSIX layer that could truncate write streams (#235)
PowerShell/Win32-OpenSSH#908
2017-11-06 21:38:14 -08:00
Manoj Ampalam c546971ca8
Fixed issue with ssh redirected stdin
PowerShell/Win32-OpenSSH#929
Issue: ReadThread prematurely returns on read io error. This results in APC never getting set and hence the corresponding fd is never set on select resulting the hang seen in issue 929.
Also removed the static instances storing sync io status, since there could be multiple sync fds operating at the same time. Moved the sync io status to w32_io object itself.
2017-11-03 13:16:23 -07:00
Manoj Ampalam b327f0c48a Fix to Issue 698 and other misc changes (#208)
Fix to PowerShell/Win32-OpenSSH#698 - Create job object, add ssh-shellhost and ensure all its child process and tied to its lifetime.
Other changes include changes to debug* statements in posix adapter that may cause recursion/stack overflow issues.
2017-09-21 22:00:39 -07:00
Yanbing 18b1e5935b multiple fixes for win7 (#206)
1. fix some exception when appverifier is enabled on win7 (https://gitthub.com/PowerShell/Win32-OpenSSH/issues/872)
2. enable sshdconfig tests on win7(https://github.com/PowerShell/Win32-OpenSSH/issues/873)
3. fix for https://github.com/PowerShell/Win32-OpenSSH/issues/874 ( ReadFile does not return on win7 when no content in console )
4. Remove logging to console in Readthread because write hangs here since write thread already closed (https://github.com/PowerShell/Win32-OpenSSH/issues/879)
5. fix VCTargetsPath
2017-09-15 21:25:42 -07:00
Yanbing 3a092cbb5d Enable Appverifier tests (#191)
1. Enable Appverifier tests and  fix of #839 and #841
2. Enabled Postmortem Debugging
2017-08-07 14:45:43 -07:00
bagajjal 69ede6fef2 Terminal fixes (#182)
Terminal code cleanup and control sequence handling..
PowerShell/Win32-OpenSSH#799
Picking the user32/kernel32 from the systemdirectory.
PowerShell/Win32-OpenSSH#814
Console settings are not restored properly
PowerShell/Win32-OpenSSH#813
Fix the clearscreen issue while connecting to non-windows (UNIX/LINUX) servers.
PowerShell/Win32-OpenSSH#807
vi arrow keys are not working
PowerShell/Win32-OpenSSH#806
Fix the nopty unix ssh session.
PowerShell/Win32-OpenSSH#805
Fix emacs issue
PowerShell/Win32-OpenSSH#802
2017-07-18 12:31:30 -07:00
Manoj Ampalam dd88d8d5d4 Move to LibreSSL, Fixed issues arising from compiling Windows specific code at warling level 3 2017-06-13 10:33:47 -07:00
Manoj Ampalam c3c5c1fa7f Support I/O redirection in all ssh clients (ssh.exe, sftp.exe and scp.exe) (#113)
PowerShell/Win32-OpenSSH#668
2017-04-14 16:15:32 -07:00
Yanbing 0d1b232d3b Terminal escape sequence handling in a non-TTY stream for Windows (#94)
To prevent screwing up terminal settings on windows when printing to the terminal, turn off the virtual termial before print out to console. The file call these funtions are from scp.c,  sftp.c and sshconnect(calls smprintf). The virtual termial are not enabled in scp and sftp. turn off it in vfmprintf is enough for now.
2017-03-29 12:52:51 -07:00
Yanbing 425bc4033f latestw + Test Infra upgrades
Includes
- CR changes for upstream PR
- Fix in spawn_child logic
- Test Infra upgrades
2017-03-24 12:35:52 -07:00
bagajjal 8addc04e87 Terminalissues (#89)
#576 - fix the EVENT_CONSOLE_CARET issue.. Wrongly read the X, Y coordinates
#575 - when backspace key is pressed then screen is not refreshed correctly
#574 - when delete key is pressed then screen is not refreshed correctly (the last character is repeated in the end)
#573 - while using up/down arrows, screen is not refreshed correctly (there are some left over characters of bigger command)
#572 - clear screen is not clearing the whole console
#571 - Move the cursor to top of visible window so that nothing will be erased on the console.
#570 - code cleanup for console related logic
#569 - wrong implementation of TIOCGWINSZ. This is causing lot of issues when windows open ssh client is connecting to linux ssh server.
#568 - Scrolling issue when the cursor is at the last line of the visible window.
#567 - Logic to pass the raw buffer to console is wrong.
2017-03-13 14:53:58 -07:00
bagajjal 73180c876d Cleaned up shell-host and terminal related code 2017-02-07 12:21:01 -08:00
bagajjal 35ea56a9a7 Cleaned up shell-host.c, termio.c, tncon.c, tnnet.c 2017-02-04 00:37:08 -08:00
bagajjal 073eadfc98 Bug fixes (#58)
PowerShell/Win32-OpenSSH#458
PowerShell/Win32-OpenSSH#497
 a) Deleted the unwanted file (conio.c)
 b) Added more debug logs to get_passwd()
 c) Removed ReadThread() in termio.c
2017-01-28 11:52:02 -08:00
Manoj Ampalam c6b57c018c Got rid of w32posix.h and defs.h (https://github.com/PowerShell/Win32-OpenSSH/issues/498) 2017-01-25 14:43:55 -08:00
bagajjal e4da8db4d2 Multiple Fixes
https://github.com/PowerShell/Win32-OpenSSH/issues/496
https://github.com/PowerShell/Win32-OpenSSH/issues/488
https://github.com/PowerShell/Win32-OpenSSH/issues/495
2017-01-24 10:18:42 -08:00
Manoj Ampalam 5ad8a2c358 Sources Merged from Win32 Fork 2016-12-19 14:46:28 -08:00