Commit Graph

653 Commits

Author SHA1 Message Date
Yanbing 48e0cdbd5f
Grant Built-in-Users to log event to channels (#339)
Fix of PowerShell/Win32-OpenSSH#1174 to grant non-admin permission to log events
Change the file type to text so it will show the diff in the future
2018-08-11 00:45:48 -07:00
bingbing8 38fc68a21b Grant built-in-user TRACE_LOG_EVENT permission
change the file to text type to show the diff
2018-08-11 00:12:50 -07:00
Yanbing 4ac87b4991
Upload unit test as artifacts (#337)
Update vsts scripts to upload unit tests as artifacts
2018-08-06 12:57:47 -07:00
bagajjal 92f363bef1 Remove console resize (#336)
remove the window resize logic in ssh-shellhost.exe
2018-08-03 13:29:43 -07:00
Yanbing 0f9808f190
Cranked version 7.7.2.0 (#334)
Cranked version 7.7.2.0
2018-07-26 11:03:08 -07:00
Manoj Ampalam 84e87be8ae
ConPTY changes and support for auto-updating known_hosts;
- Logic to support conpty (currently disabled until validation is complete)
- fdopen() and fchmod() support for file handles
- support for auto updating known_hosts via ssh and ssh-keygen
- Support for dynamic Windows-size changes with PTY
- Changes to support OneCore SDK
- Test cases
2018-07-25 15:15:05 -07:00
Bryan Berns 366964344f Use Implicit User Principal Name If Explicit Does Not Exist (#332)
Modified user principal name lookup to default to the implicit form (SamAccountName@DnsDomainName) if no explicit user principal name attribute is found on the account.

https://github.com/PowerShell/Win32-OpenSSH/issues/1213
2018-07-20 10:29:49 -07:00
cbookg ce3db0ee61 Fix descriptor leaks in win32 fstat implementation (#329)
Fix descriptor leaks in win32 fstat implementation
PowerShell/Win32-OpenSSH#1209

According to the docs for _open_osfhandle, _close will close the underlying handle:
"To close a file opened with , call _close. The underlying handle is also closed by a call to _close, so it is not necessary to call the Win32 function CloseHandle on the original handle"
2018-07-13 10:43:36 -07:00
Manoj Ampalam 8bb672aa4d
Optimized group membership resolution (#327)
Current group membership resolution though very effective, is very slow. In a typical domain joined enterprise machine, adding a simple entry like the following in sshd_config
AllowGroups administrators
will incur a long delay in remote session establishment as sshd tried to pull all groups associated with the domain user.

Changes in this PR optimize the general case scenarios where no wild cards are in use. Specifically rules like this are processed promptly:

AllowGroups group1, group2, group3 //with no wild cards
Match Group group1 //single group with no negation and wild cards

Optimization is done by resolve the groupname in rule immediately to SID and checking its membership against user token. Enumerating the entire group membership is done on a lazy on-demand basis.

Beyond the optimization, there are 2 functional changes

- removed domain prefix for builtin groups
- removed domain prefix'ed versions of local groups since we are strictly following the convention that local principals shouldn't have any domain qualification.
2018-07-03 10:15:07 -07:00
Bryan Berns 856078b7fd Cleanup SeServiceLogonRight For Restricted User Account (#328)
After creating a user token, the SeServiceLogonRight is now removed from the account so it does not create an orphaned reference in the local security policy.
Other small code changes for code style consistency within the file.

PowerShell/Win32-OpenSSH#1202
2018-07-03 09:43:32 -07:00
Yanbing ed70a1a7f8
Add debug msg, replace API call incompatible with onecore , add build script (#324)
Add debug msg, replace API call incompatible with onecore , add build script
2018-06-18 22:39:31 -07:00
Bryan Berns 4be3dd9647 Added / Fixed Debug Messages (#323)
Fixed debug messages in user token utilities.
2018-06-12 10:18:41 -07:00
Manoj Ampalam 9369d870ad
upped version to 7.7.1.0 and fixed some issues with session path resolution (#320)
upped version to 7.7.1.0 and fixed some issues with session path resolution
2018-06-04 21:15:18 -07:00
Bryan Berns 3b450d5072 Updated SSHD Password Generation (#317)
Updated SSHD user password generation routine to be longer and more complex. This should satisfy systems with password filters that require more character types or very long passwords.
Updated routine to now securely zero memory for the SSHD account password.
Corrected attempt to write to NULL pointer by localtime_s() in localtime_r() and made function return NULL on error per specification.
Addressed various compiler / code analysis warnings.
2018-06-04 21:10:46 -07:00
Manoj Ampalam 1e0c864707
session process path changes (#319)
Added utility to build session process command line - this accounts for restrictions from various shells. With these changes, scp and sftp-server are expected to be machine wide PATH if a custom shell (other than cmd.exe) is defined. Added comprehensive test cases.
Fixed issue with USERNAME env variable containing domain prefix too.

PowerShell/Win32-OpenSSH#1165
PowerShell/Win32-OpenSSH#1165
PowerShell/Win32-OpenSSH#1171
2018-06-04 12:16:13 -07:00
Bryan Berns 710050b186 Remove None/Domain Users Group Filter (#316)
- Removed logic that was excluding the group membership SID that matched 'None' on workgroup computers or 'Domain Users' on domain systems.
- Removed test that was checking that AllowGroups failure if user was not in any group at all.  This is no longer testable since user will always be a member of at least one group.

https://github.com/PowerShell/Win32-OpenSSH/issues/1167
2018-06-03 08:23:30 -07:00
bagajjal 8013f1377b implement freezero(), use localtime_s() instead of localtime() (#300)
PowerShell/Win32-OpenSSH#1121
2018-05-29 19:00:56 -07:00
Manoj Ampalam 8c9c6a0e17
fixed product version (#315) 2018-05-29 10:55:32 -07:00
Manoj Ampalam 9ff97f6106
Fixed issue with virtual token generation (#314)
On certain machines, virtual tokens were not getting generated due to lack of required privileges. Fixed it by assigning them before doing LogonUserExExW. Consolidated runtime dll loading logic. 

PowerShell/Win32-OpenSSH#1162
2018-05-28 22:03:33 -07:00
Bryan Berns 471b76dbd5 Updates To Address OneCore Linking (#311)
* Updates To Address OneCore Linking

- Modified generate_s4u_user_token() and sys_auth_passwd() to dynamically load TranslateNameW() to avoid OneCore static library linking.
- Modified getusergroups() to avoid Lsa* calls that are not present in OneCore libraries.

* Updates To Address OneCore Linking - Revisions

- Corrected failure detection logic when TranslateNameW() cannot be located.
2018-05-23 16:55:55 -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
Manoj Ampalam 236b04b335
Tentative changes to support sshd in interactive mode (#313)
Added support to run sshd as non-system. In this mode, sshd can authenticate only the user that sshd is running as, and only via public key authentication.

PowerShell/Win32-OpenSSH#1153
2018-05-22 22:24:23 -07:00
Manoj Ampalam 3fb0c252c3
Refactor session logic (default shell, non PTY, child spawning) (#312)
Changes include:
- Removing sid from pwd structure to comply with Unix structure
- Integrating default shell logic within pwd
- pwd placeholder to allow logins using usernames not associated with Windows account (possible via custom LSA authentication)
- Moving all nonPTY logic from shellhost to session.c. 
- ssh-shellhost is now exclusively for implementing PTY
- Spawning all session processes from within a shell
- Validation checks in safely_chroot
2018-05-22 21:49:58 -07:00
Yanbing a479737cd5
Buffer overflow in Scp (#310)
1. Fix buffer overflow in scp
2. Update setup tests to take into account the windows inbox service startup type
2018-05-20 19:06:36 -07:00
Manoj Ampalam 7b28a316eb
Enable SFTP chroot support (#308)
- Added chroot implementation that simply stores the path in internal state and sets an environment variable
- Spawned processes pickup chroot from environment variable
- Core change in realpath and resolved_path_utf16 now take into account chroot path.
- Unit tests
- Other miscellaneous changes to account for chroot enabled logic in core code

PowerShell/Win32-OpenSSH#190
PowerShell/Win32-OpenSSH#292
2018-05-11 14:45:20 -07:00
Dominic Watley 936b89ac0d Add GCM Cipher Support (#309)
Enabled GCM Cipher related macros in config header for Windows
PowerShell/Win32-OpenSSH#1075
2018-05-10 21:20:55 -07:00
Bryan Berns fe422e5c15 Enhanced Group Discovery / Normalized Names (#286)
Modified getusergroups() to use s4u tokens to discover nested groups and return them in NetBiosName\GroupName format.
Modified get_passwd() to internally normalize names to NetBiosName\SamAccountName format and changed functions that use it to translate to UPN where necessary.
Removed unnecessary support functions used by previous version of getusergroups().
Various refactoring and function consolidation / simplification.
Addressed several buffer over-read issues.

PowerShell/Win32-OpenSSH#553
2018-05-01 23:20:42 -07:00
Manoj Ampalam 77999d2f4d
Merge pull request #303 from NoMoreFood/path_fixes
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 that used a static buffer. Changed some functions to use unicode to eliminate use of previous resolve_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.
Removed debug statements that were interfering with APC wakeup due to the way that logging works in atomicio6().
Filled in a missing parameter in a debug statement.
Changed test helper so test name is displayed when running release build.
Corrected permissions check for whether to run symbolic links in test cases.
Removed TEST_RESOURCES() in unit tests calls due to inconsistent ability to sample handles in Windows 8.1 / Server 2012 R2.
2018-04-25 22:03:52 -07:00
Yanbing ec3eb7a088
Fix issue install-sshd.ps1 failed on Nano, update it to match inbox manifest, and add setup and uninstall tests (#305)
1. Fix issue install-sshd.ps1 failed on Nano
2. Update settings of services in install-sshd.ps1 to match windows inbox
3. added setup tests and update the test helper scripts to run setup tests before changing configurations on the machine
4. added uninstallation tests
2018-04-24 11:50:44 -07:00
Bryan Berns 808a4ac5ce
Merge branch 'latestw_all' into path_fixes 2018-04-24 05:11:43 -04:00
Bryan Berns 3cb15761a9 Use Path Resolution Function For Hard Links
- Changed link() to use resolved_path_utf16().
2018-04-24 05:04:56 -04:00
Manoj Ampalam c24cf7945e Added support for hard links over sftp
https://github.com/PowerShell/Win32-OpenSSH/issues/1119
Added link() support using the CreateHardLink() function.
Made readlink() and link() declarations consistent with other functions.
2018-04-24 05:00:23 -04:00
Bryan Berns 8c86f30a0f Reworked Path Resolution Function - Review Changes
- Changes based on review comments.
2018-04-24 04:47:09 -04:00
Yanbing 41e4e89376
Add support to take key files with CRLF new line ending on windows (#301)
1. Add support to take key files with windows new line ending (PowerShell/Win32-OpenSSH#1130)
2. add test cases for CRLF
3. Update test helper script to catch the exitcode of unittest and report the failure
4. Enable uni test unittest-sshkey and unittest-sshkey
5. Disable resource check for signal tests due to some API issue to follow.
6. Remove workaround for windows new line ending in test scripts
7. Add test validation for ACL of registry entries when perform ssh-add
2018-04-12 14:24:38 -07:00
Manoj Ampalam 1616b21ecb
Added support for hard links over sftp
https://github.com/PowerShell/Win32-OpenSSH/issues/1119
Added link() support using the CreateHardLink() function.
Made readlink() and link() declarations consistent with other functions.
2018-04-05 09:57:41 -07:00
Bryan Berns 14ba410250 Removed Problematic Debug Statements
- Removed debug statements that were interfering with APC wakeup due to the way that logging works in atomicio6().
- Filled in a missing parameter in a debug statement.
2018-04-03 23:17:44 -04:00
Manoj Ampalam 32a7aec453 Ported upstream changes (7.7) 2018-04-02 22:30:15 -07:00
Manoj Ampalam 2474b9130b Merge branch 'master' of https://github.com/openssh/openssh-portable into up_merge 2018-04-02 13:13:47 -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
Bryan Berns 296c6934bc Added link() Support
- Added link() support using the CreateHardLink() function.
- Made readlink() and link() declarations consistent with other functions.
2018-03-31 07:52:58 -04:00
Manoj Ampalam c1aaa5d5a3 updates to uninstall-sshd.ps1, cranked version to 7.6.1.0 (#295) 2018-03-30 19:45:11 -07:00
Yanbing f291d2438f
Added config files to enabled VSTS build, compliance tests, Code signing. (#296)
Added config files to enabled VSTS build, compliance tests, Code signing.
2018-03-30 19:44:07 -07:00
Daniel Sweet 11726e3c8e Follow POSIX write/append semantics in fileio_open (#276)
fileio_open previously treated all O_CREAT flags as CREATE_* flags in
CreateFile; CREATE_* always truncates files but O_CREAT only truncates
files when O_TRUNC is also set on POSIX platforms. This becomes
noticeable under SFTP sessions where remote files are opened with
O_APPEND: the file is instead truncated as in O_CREAT | O_TRUNC.

https://github.com/PowerShell/Win32-OpenSSH/issues/1078
2018-03-30 12:37:07 -07:00
revngnr f607a0be96 Bandwidth limits don't work correctly for sftp client (#278)
Fixes following issues:
- gettimeofday : Incorrect converting 100ns intervals (from GetSystemTimeAsFileTime) to timeval.
(us % RATE_DIFF) means number of microseconds but it may be great than 10**6
- nanosleep : SetWaitableTimer works with 100ns intervals but get nanoseconnds (only part of timespec) Missed CloseHandle call in WaitForSingleObject error case.


https://github.com/PowerShell/Win32-OpenSSH/issues/1094
2018-03-30 09:45:44 -07:00
Bryan Berns 993cce0798 Added symlink() Implementation; Revised readlink() (#289)
- Added implementation of symlink() using native CreateSymbolicLink() function.
- Added unit tests for symlink behavior in readlink(), lstat, stat(), and symlink().
- Reworked readlink() to be more inline with POSIX readlink() behavior.
- Reworked symlink handling in stat/lstat due to revised readlink().
- Added additional error handling to readlink().
- Added symlink() Implementation - Memory Leak Fix
- Modified fileio_readlink() to properly free a temporary buffer it creates.
2018-03-29 10:54:38 -07:00
bagajjal 00b869dbd8 Use libre ssl official release binaries (#294)
- Use LibreSSL release binaries. Update paths.target
- Update paths.targets to remove onecore specific changes
- Minor changes
2018-03-29 10:23:05 -07:00
bagajjal be0a2ff29d Fix shellhost infiniteloop issue (ssh.exe -t user@ip dir) (#292)
Fix for PowerShell/Win32-OpenSSH#892
Fixed warning messages in latest code.
2018-03-26 21:32:30 -07:00
Yanbing 952650633d
Update compiler and link options (#293)
* add additionaloptions for ClCompiler and linker for APIscan compliance test
2018-03-26 16:21:56 -07:00
Bryan Berns 59971b42ee Updated Signal Handler (#287)
https://github.com/PowerShell/Win32-OpenSSH/issues/1096
https://github.com/PowerShell/Win32-OpenSSH/issues/191

- Updated wait_for_multiple_objects_enhanced() to handle a no-event request while alterable.
- Simplified wait_for_any_event() to by taking advantage of no-event alterable request in wait_for_multiple_objects_enhanced().
- Updated wait_for_any_event() to use MAX_CHILDREN limit instead of MAXIMUM_WAIT_OBJECTS limit.
- Removed unnecessary ZeroMemory() call.
- Created distinct definition MAXIMUM_WAIT_OBJECTS_ENHANCED
 and modified functions to use it.
- Upped w32_select() event limit.
- Modified wait_for_multiple_objects_enhanced() to allow for 0 millisecond wait.
2018-03-20 09:49:09 -07:00
Bryan Berns 966d8c4129 Unit Test Updates / Small Bug Fixes (#288)
- Updated socketio_WSARecv() to prevent attempted buffer overrun.
- Updated w32_rename() to handle error when input parameters are null.
- Updated file verify success on dup() test.
2018-03-16 09:32:26 -07:00