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
This commit is contained in:
parent
879318721c
commit
18b1e5935b
|
@ -217,7 +217,7 @@ function Start-OpenSSHBootstrap
|
||||||
[Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE')
|
[Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE')
|
||||||
}
|
}
|
||||||
|
|
||||||
$VCTargetsPath = "${env:ProgramFiles(x86)}\MSBuild\Microsoft.Cpp\v4.0\V140"
|
$VCTargetsPath = "${env:ProgramFiles(x86)}\MSBuild\Microsoft.Cpp\v4.0\V140\"
|
||||||
if([Environment]::GetEnvironmentVariable('VCTargetsPath', 'MACHINE') -eq $null)
|
if([Environment]::GetEnvironmentVariable('VCTargetsPath', 'MACHINE') -eq $null)
|
||||||
{
|
{
|
||||||
[Environment]::SetEnvironmentVariable('VCTargetsPath', $VCTargetsPath, 'MACHINE')
|
[Environment]::SetEnvironmentVariable('VCTargetsPath', $VCTargetsPath, 'MACHINE')
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
} while(0)
|
} while(0)
|
||||||
#define NULL_DEVICE "/dev/null"
|
#define NULL_DEVICE "/dev/null"
|
||||||
|
|
||||||
|
#define IsWin7OrLess() (!IsWindows8OrGreater())
|
||||||
|
|
||||||
#define IS_INVALID_HANDLE(h) ( ((NULL == h) || (INVALID_HANDLE_VALUE == h)) ? 1 : 0 )
|
#define IS_INVALID_HANDLE(h) ( ((NULL == h) || (INVALID_HANDLE_VALUE == h)) ? 1 : 0 )
|
||||||
|
#define IS_VALID_HANDLE(h) (!IS_INVALID_HANDLE(h))
|
||||||
|
|
||||||
/* removes first '/' for Windows paths that are unix styled. Ex: /c:/ab.cd */
|
/* removes first '/' for Windows paths that are unix styled. Ex: /c:/ab.cd */
|
||||||
char * sanitized_path(const char *);
|
char * sanitized_path(const char *);
|
||||||
|
|
|
@ -106,9 +106,8 @@ ReadThread(_In_ LPVOID lpParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReadFile(WINHANDLE(pio), pio->read_details.buf,
|
if (!ReadFile(WINHANDLE(pio), pio->read_details.buf,
|
||||||
pio->read_details.buf_size, &read_status.transferred, NULL)) {
|
pio->read_details.buf_size, &read_status.transferred, NULL)) {
|
||||||
read_status.error = GetLastError();
|
read_status.error = GetLastError();
|
||||||
debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,13 +126,11 @@ ReadThread(_In_ LPVOID lpParameter)
|
||||||
} else {
|
} else {
|
||||||
if (!ReadFile(WINHANDLE(pio), pio->read_details.buf,
|
if (!ReadFile(WINHANDLE(pio), pio->read_details.buf,
|
||||||
pio->read_details.buf_size, &read_status.transferred, NULL)) {
|
pio->read_details.buf_size, &read_status.transferred, NULL)) {
|
||||||
read_status.error = GetLastError();
|
read_status.error = GetLastError();
|
||||||
debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 == QueueUserAPC(ReadAPCProc, main_thread, (ULONG_PTR)pio)) {
|
if (0 == QueueUserAPC(ReadAPCProc, main_thread, (ULONG_PTR)pio)) {
|
||||||
debug3("TermRead thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio);
|
|
||||||
pio->read_details.pending = FALSE;
|
pio->read_details.pending = FALSE;
|
||||||
pio->read_details.error = GetLastError();
|
pio->read_details.error = GetLastError();
|
||||||
DebugBreak();
|
DebugBreak();
|
||||||
|
@ -256,8 +253,12 @@ syncio_close(struct w32_io* pio)
|
||||||
|
|
||||||
/* If io is pending, let worker threads exit. */
|
/* If io is pending, let worker threads exit. */
|
||||||
if (pio->read_details.pending) {
|
if (pio->read_details.pending) {
|
||||||
/* For console - the read thread is blocked so terminate it. */
|
/*
|
||||||
if (FILETYPE(pio) == FILE_TYPE_CHAR && in_raw_mode)
|
Terminate the read thread at the below situations:
|
||||||
|
1. For console - the read thread is blocked by the while loop on raw mode
|
||||||
|
2. Function ReadFile on Win7 machine dees not return when no content to read in non-interactive mode.
|
||||||
|
*/
|
||||||
|
if (FILETYPE(pio) == FILE_TYPE_CHAR && (IsWin7OrLess() || in_raw_mode))
|
||||||
TerminateThread(pio->read_overlapped.hEvent, 0);
|
TerminateThread(pio->read_overlapped.hEvent, 0);
|
||||||
else
|
else
|
||||||
WaitForSingleObject(pio->read_overlapped.hEvent, INFINITE);
|
WaitForSingleObject(pio->read_overlapped.hEvent, INFINITE);
|
||||||
|
|
|
@ -556,17 +556,17 @@ w32_io_process_fd_flags(struct w32_io* pio, int flags)
|
||||||
|
|
||||||
shi_flags = (flags & FD_CLOEXEC) ? 0 : HANDLE_FLAG_INHERIT;
|
shi_flags = (flags & FD_CLOEXEC) ? 0 : HANDLE_FLAG_INHERIT;
|
||||||
|
|
||||||
if (SetHandleInformation(WINHANDLE(pio), HANDLE_FLAG_INHERIT, shi_flags) == FALSE) {
|
HANDLE h = WINHANDLE(pio);
|
||||||
/*
|
|
||||||
* Ignore if handle is not valid yet. It will not be valid for
|
/*
|
||||||
* UF_UNIX sockets that are not connected yet
|
* Ignore if handle is not valid yet. It will not be valid for
|
||||||
*/
|
* UF_UNIX sockets that are not connected yet
|
||||||
if (GetLastError() != ERROR_INVALID_HANDLE) {
|
*/
|
||||||
debug3("fcntl - SetHandleInformation failed %d, io:%p",
|
if (IS_VALID_HANDLE(h) && (SetHandleInformation(h, HANDLE_FLAG_INHERIT, shi_flags) == FALSE)) {
|
||||||
GetLastError(), pio);
|
debug3("fcntl - SetHandleInformation failed with error:%d, io:%p",
|
||||||
errno = EOTHER;
|
GetLastError(), pio);
|
||||||
return -1;
|
errno = EOTHER;
|
||||||
}
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pio->fd_flags = flags;
|
pio->fd_flags = flags;
|
||||||
|
@ -797,7 +797,6 @@ w32_select(int fds, w32_fd_set* readfds, w32_fd_set* writefds, w32_fd_set* excep
|
||||||
|
|
||||||
debug5("select - returning %d", out_ready_fds);
|
debug5("select - returning %d", out_ready_fds);
|
||||||
return out_ready_fds;
|
return out_ready_fds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -25,7 +25,7 @@ Describe "Tests of sshd_config" -Tags "CI" {
|
||||||
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
|
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
|
||||||
$ContextName = $env:COMPUTERNAME
|
$ContextName = $env:COMPUTERNAME
|
||||||
$ContextType = [System.DirectoryServices.AccountManagement.ContextType]::Machine
|
$ContextType = [System.DirectoryServices.AccountManagement.ContextType]::Machine
|
||||||
$PrincipalContext = [System.DirectoryServices.AccountManagement.PrincipalContext]::new($ContextType, $ContextName)
|
$PrincipalContext = new-object -TypeName System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList @($ContextType, $ContextName)
|
||||||
$IdentityType = [System.DirectoryServices.AccountManagement.IdentityType]::SamAccountName
|
$IdentityType = [System.DirectoryServices.AccountManagement.IdentityType]::SamAccountName
|
||||||
|
|
||||||
function Add-LocalUser
|
function Add-LocalUser
|
||||||
|
@ -35,7 +35,7 @@ Describe "Tests of sshd_config" -Tags "CI" {
|
||||||
if($user -eq $null)
|
if($user -eq $null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::new($PrincipalContext,$UserName,$Password, $true)
|
$user = new-object -TypeName System.DirectoryServices.AccountManagement.UserPrincipal -ArgumentList @($PrincipalContext,$UserName,$Password, $true)
|
||||||
$user.Save()
|
$user.Save()
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -51,7 +51,7 @@ Describe "Tests of sshd_config" -Tags "CI" {
|
||||||
if($group -eq $null)
|
if($group -eq $null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$group = [System.DirectoryServices.AccountManagement.GroupPrincipal]::new($PrincipalContext,$groupName)
|
$group = new-object -TypeName System.DirectoryServices.AccountManagement.GroupPrincipal -ArgumentList @($PrincipalContext,$groupName)
|
||||||
$group.Save()
|
$group.Save()
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
Loading…
Reference in New Issue