Skip to content

Commit a7ea6ec

Browse files
committed
1. fix some exception when appverifier is enabled on win7 (PowerShell/Win32-OpenSSH#872)
2. enable sshdconfig tests on win7(PowerShell/Win32-OpenSSH#873) 3. fix for PowerShell/Win32-OpenSSH#874 does not return on win7 when no content in console ) 4. remove loggin to console in Readthread because write hangs here since write thread already closed (PowerShell/Win32-OpenSSH#879) 5. fix VCTargetsPath
1 parent 3b517af commit a7ea6ec

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

contrib/win32/openssh/OpenSSHBuildHelper.psm1

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function Start-OpenSSHBootstrap
217217
[Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE')
218218
}
219219

220-
$VCTargetsPath = "${env:ProgramFiles(x86)}\MSBuild\Microsoft.Cpp\v4.0\V140"
220+
$VCTargetsPath = "${env:ProgramFiles(x86)}\MSBuild\Microsoft.Cpp\v4.0\V140\"
221221
if([Environment]::GetEnvironmentVariable('VCTargetsPath', 'MACHINE') -eq $null)
222222
{
223223
[Environment]::SetEnvironmentVariable('VCTargetsPath', $VCTargetsPath, 'MACHINE')

contrib/win32/win32compat/termio.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,11 @@ ReadThread(_In_ LPVOID lpParameter)
103103

104104
if (!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes))
105105
error("SetConsoleMode on STD_INPUT_HANDLE failed with %d\n", GetLastError());
106-
}
106+
}
107107

108108
if (!ReadFile(WINHANDLE(pio), pio->read_details.buf,
109-
pio->read_details.buf_size, &read_status.transferred, NULL)) {
110-
read_status.error = GetLastError();
111-
debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio);
109+
pio->read_details.buf_size, &read_status.transferred, NULL)) {
110+
read_status.error = GetLastError();
112111
return -1;
113112
}
114113

@@ -127,8 +126,7 @@ ReadThread(_In_ LPVOID lpParameter)
127126
} else {
128127
if (!ReadFile(WINHANDLE(pio), pio->read_details.buf,
129128
pio->read_details.buf_size, &read_status.transferred, NULL)) {
130-
read_status.error = GetLastError();
131-
debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio);
129+
read_status.error = GetLastError();
132130
return -1;
133131
}
134132
}
@@ -257,7 +255,7 @@ syncio_close(struct w32_io* pio)
257255
/* If io is pending, let worker threads exit. */
258256
if (pio->read_details.pending) {
259257
/* For console - the read thread is blocked so terminate it. */
260-
if (FILETYPE(pio) == FILE_TYPE_CHAR && in_raw_mode)
258+
if (FILETYPE(pio) == FILE_TYPE_CHAR)
261259
TerminateThread(pio->read_overlapped.hEvent, 0);
262260
else
263261
WaitForSingleObject(pio->read_overlapped.hEvent, INFINITE);

contrib/win32/win32compat/w32fd.c

+12-11
Original file line numberDiff line numberDiff line change
@@ -556,17 +556,18 @@ w32_io_process_fd_flags(struct w32_io* pio, int flags)
556556

557557
shi_flags = (flags & FD_CLOEXEC) ? 0 : HANDLE_FLAG_INHERIT;
558558

559-
if (SetHandleInformation(WINHANDLE(pio), HANDLE_FLAG_INHERIT, shi_flags) == FALSE) {
560-
/*
561-
* Ignore if handle is not valid yet. It will not be valid for
562-
* UF_UNIX sockets that are not connected yet
563-
*/
564-
if (GetLastError() != ERROR_INVALID_HANDLE) {
565-
debug3("fcntl - SetHandleInformation failed %d, io:%p",
566-
GetLastError(), pio);
567-
errno = EOTHER;
568-
return -1;
569-
}
559+
HANDLE h = WINHANDLE(pio);
560+
if (IS_INVALID_HANDLE(h)) {
561+
/*
562+
* Ignore if handle is not valid yet. It will not be valid for
563+
* UF_UNIX sockets that are not connected yet
564+
*/
565+
}
566+
else if (SetHandleInformation(h, HANDLE_FLAG_INHERIT, shi_flags) == FALSE) {
567+
debug3("fcntl - SetHandleInformation failed %d, io:%p",
568+
GetLastError(), pio);
569+
errno = EOTHER;
570+
return -1;
570571
}
571572

572573
pio->fd_flags = flags;

regress/pesterTests/SSHDConfig.tests.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Describe "Tests of sshd_config" -Tags "CI" {
2525
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
2626
$ContextName = $env:COMPUTERNAME
2727
$ContextType = [System.DirectoryServices.AccountManagement.ContextType]::Machine
28-
$PrincipalContext = [System.DirectoryServices.AccountManagement.PrincipalContext]::new($ContextType, $ContextName)
28+
$PrincipalContext = new-object -TypeName System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList @($ContextType, $ContextName)
2929
$IdentityType = [System.DirectoryServices.AccountManagement.IdentityType]::SamAccountName
3030

3131
function Add-LocalUser
@@ -35,7 +35,7 @@ Describe "Tests of sshd_config" -Tags "CI" {
3535
if($user -eq $null)
3636
{
3737
try {
38-
$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::new($PrincipalContext,$UserName,$Password, $true)
38+
$user = new-object -TypeName System.DirectoryServices.AccountManagement.UserPrincipal -ArgumentList @($PrincipalContext,$UserName,$Password, $true)
3939
$user.Save()
4040
}
4141
finally {
@@ -51,7 +51,7 @@ Describe "Tests of sshd_config" -Tags "CI" {
5151
if($group -eq $null)
5252
{
5353
try {
54-
$group = [System.DirectoryServices.AccountManagement.GroupPrincipal]::new($PrincipalContext,$groupName)
54+
$group = new-object -TypeName System.DirectoryServices.AccountManagement.GroupPrincipal -ArgumentList @($PrincipalContext,$groupName)
5555
$group.Save()
5656
}
5757
finally {

0 commit comments

Comments
 (0)