diff --git a/appveyor.yml b/appveyor.yml index fec95f3..2dfcc28 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.0.20.0.{build} +version: 0.0.21.0.{build} image: Visual Studio 2015 branches: diff --git a/contrib/win32/openssh/OpenSSHBuildHelper.psm1 b/contrib/win32/openssh/OpenSSHBuildHelper.psm1 index 2d43390..0e612e0 100644 --- a/contrib/win32/openssh/OpenSSHBuildHelper.psm1 +++ b/contrib/win32/openssh/OpenSSHBuildHelper.psm1 @@ -217,7 +217,7 @@ function Start-OpenSSHBootstrap [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) { [Environment]::SetEnvironmentVariable('VCTargetsPath', $VCTargetsPath, 'MACHINE') diff --git a/contrib/win32/openssh/OpenSSHUtils.psm1 b/contrib/win32/openssh/OpenSSHUtils.psm1 index a2a52d1..0a7ae5f 100644 --- a/contrib/win32/openssh/OpenSSHUtils.psm1 +++ b/contrib/win32/openssh/OpenSSHUtils.psm1 @@ -112,7 +112,7 @@ function Repair-SshdConfigPermission [ValidateNotNullOrEmpty()] [string]$FilePath) - Repair-FilePermission -Owners $systemSid,$adminsSid -ReadAccessNeeded $sshdSid @psBoundParameters + Repair-FilePermission -Owners $systemSid,$adminsSid -FullAccessNeeded $systemSid -ReadAccessNeeded $sshdSid @psBoundParameters } <# @@ -175,7 +175,7 @@ function Repair-AuthorizedKeyPermission if($profileItem) { $userSid = $profileItem.PSChildName - Repair-FilePermission -Owners $userSid,$adminsSid,$systemSid -AnyAccessOK $userSid -ReadAccessNeeded $sshdSid @psBoundParameters + Repair-FilePermission -Owners $userSid,$adminsSid,$systemSid -AnyAccessOK $userSid -FullAccessNeeded $systemSid -ReadAccessNeeded $sshdSid @psBoundParameters } else @@ -332,7 +332,7 @@ function Repair-FilePermissionInternal { { $realReadAccessNeeded = @($everyoneSid) } - #this is orginal list requested by the user, the account will be removed from the list if they already part of the dacl + #this is original list requested by the user, the account will be removed from the list if they already part of the dacl if($realReadAccessNeeded) { $realReadAccessNeeded = $realReadAccessNeeded | ? { ($_ -ne $null) -and ($realFullAccessNeeded -notcontains $_) } diff --git a/contrib/win32/openssh/install-sshd.ps1 b/contrib/win32/openssh/install-sshd.ps1 index 6052bae..142664b 100644 --- a/contrib/win32/openssh/install-sshd.ps1 +++ b/contrib/win32/openssh/install-sshd.ps1 @@ -220,20 +220,20 @@ namespace MyLsaWrapper } } '@ -$references = @() -if(($psversiontable.Containskey("psedition")) -and ($psversiontable.PSEdition -ieq "core")) -{ - $references = "System.Security.Principal.Windows", "Microsoft.Win32.Primitives" -} +$references = @("System.Security.Principal.Windows", "Microsoft.Win32.Primitives") try { $null = [MyLsaWrapper.LsaWrapperCaller] } catch { - $types = Add-Type $definition -ref $references -WarningAction SilentlyContinue -ErrorAction SilentlyContinue + try { + $types = Add-Type $definition -ref $references -WarningAction SilentlyContinue -ErrorAction SilentlyContinue + } + catch { + $types = Add-Type $definition -WarningAction SilentlyContinue -ErrorAction SilentlyContinue + } } - function Add-Privilege { param( diff --git a/contrib/win32/openssh/keygen.vcxproj b/contrib/win32/openssh/keygen.vcxproj index b4544ec..0564f2c 100644 --- a/contrib/win32/openssh/keygen.vcxproj +++ b/contrib/win32/openssh/keygen.vcxproj @@ -106,6 +106,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -126,6 +127,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -147,6 +149,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console @@ -171,6 +174,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console diff --git a/contrib/win32/openssh/libssh.vcxproj b/contrib/win32/openssh/libssh.vcxproj index 98c5e75..1a43e3a 100644 --- a/contrib/win32/openssh/libssh.vcxproj +++ b/contrib/win32/openssh/libssh.vcxproj @@ -102,6 +102,7 @@ MultiThreadedDebug CompileAsC ProgramDatabase + false Windows @@ -120,6 +121,7 @@ MultiThreadedDebug CompileAsC ProgramDatabase + false Windows @@ -137,6 +139,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + false Windows @@ -157,6 +160,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded true + false Windows diff --git a/contrib/win32/openssh/libssh.vcxproj.filters b/contrib/win32/openssh/libssh.vcxproj.filters index 45f43dd..596c958 100644 --- a/contrib/win32/openssh/libssh.vcxproj.filters +++ b/contrib/win32/openssh/libssh.vcxproj.filters @@ -88,6 +88,7 @@ + @@ -129,18 +130,12 @@ Source Files - - Source Files - Source Files Source Files - - Source Files - Source Files @@ -159,9 +154,6 @@ Source Files - - Source Files - Source Files diff --git a/contrib/win32/openssh/openbsd_compat.vcxproj b/contrib/win32/openssh/openbsd_compat.vcxproj index 314042f..fa40f35 100644 --- a/contrib/win32/openssh/openbsd_compat.vcxproj +++ b/contrib/win32/openssh/openbsd_compat.vcxproj @@ -200,6 +200,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)openbsd-compat;$(OpenSSH-Src-Path)libkrb;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Windows @@ -216,6 +217,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)openbsd-compat;$(OpenSSH-Src-Path)libkrb;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Windows @@ -233,6 +235,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)openbsd-compat;$(OpenSSH-Src-Path)libkrb;%(AdditionalIncludeDirectories) MultiThreaded + Guard Windows @@ -253,6 +256,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)openbsd-compat;$(OpenSSH-Src-Path)libkrb;%(AdditionalIncludeDirectories) MultiThreaded true + Guard Windows diff --git a/contrib/win32/openssh/openbsd_compat.vcxproj.filters b/contrib/win32/openssh/openbsd_compat.vcxproj.filters index 9782637..673ff8f 100644 --- a/contrib/win32/openssh/openbsd_compat.vcxproj.filters +++ b/contrib/win32/openssh/openbsd_compat.vcxproj.filters @@ -195,10 +195,16 @@ Source Files - + Source Files - + + Source Files + + + Source Files + + Source Files diff --git a/contrib/win32/openssh/scp.vcxproj b/contrib/win32/openssh/scp.vcxproj index c82f245..7a444ee 100644 --- a/contrib/win32/openssh/scp.vcxproj +++ b/contrib/win32/openssh/scp.vcxproj @@ -113,6 +113,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug + Guard Console @@ -132,6 +133,8 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug + Guard + ProgramDatabase Console @@ -153,6 +156,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console @@ -177,6 +181,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console diff --git a/contrib/win32/openssh/sftp-server.vcxproj b/contrib/win32/openssh/sftp-server.vcxproj index 19262e8..2dcae5c 100644 --- a/contrib/win32/openssh/sftp-server.vcxproj +++ b/contrib/win32/openssh/sftp-server.vcxproj @@ -115,6 +115,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -135,6 +136,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -156,6 +158,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console @@ -180,6 +183,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console diff --git a/contrib/win32/openssh/sftp.vcxproj b/contrib/win32/openssh/sftp.vcxproj index 99414a6..be1ee48 100644 --- a/contrib/win32/openssh/sftp.vcxproj +++ b/contrib/win32/openssh/sftp.vcxproj @@ -118,6 +118,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -138,6 +139,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -159,6 +161,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console @@ -183,6 +186,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console diff --git a/contrib/win32/openssh/ssh-add.vcxproj b/contrib/win32/openssh/ssh-add.vcxproj index 0d5c01c..f8ea4d8 100644 --- a/contrib/win32/openssh/ssh-add.vcxproj +++ b/contrib/win32/openssh/ssh-add.vcxproj @@ -116,6 +116,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -136,6 +137,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -157,6 +159,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console @@ -181,6 +184,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console diff --git a/contrib/win32/openssh/ssh-agent.vcxproj b/contrib/win32/openssh/ssh-agent.vcxproj index 6bb7e46..1d428c9 100644 --- a/contrib/win32/openssh/ssh-agent.vcxproj +++ b/contrib/win32/openssh/ssh-agent.vcxproj @@ -111,6 +111,7 @@ MultiThreadedDebug Sync ProgramDatabase + Guard Console @@ -133,6 +134,7 @@ CompileAsC MultiThreadedDebug ProgramDatabase + Guard Console @@ -155,6 +157,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories);$(OpenSSH-Src-Path)contrib\win32\ssh-pubkey MultiThreaded + Guard Console @@ -181,6 +184,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories);$(OpenSSH-Src-Path)contrib\win32\ssh-pubkey MultiThreaded true + Guard Console diff --git a/contrib/win32/openssh/ssh-keyscan.vcxproj b/contrib/win32/openssh/ssh-keyscan.vcxproj index 430e645..df1a64b 100644 --- a/contrib/win32/openssh/ssh-keyscan.vcxproj +++ b/contrib/win32/openssh/ssh-keyscan.vcxproj @@ -105,6 +105,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -127,6 +128,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -150,6 +152,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console @@ -177,6 +180,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded false + Guard Console diff --git a/contrib/win32/openssh/ssh-shellhost.vcxproj b/contrib/win32/openssh/ssh-shellhost.vcxproj index 25c1d0b..c4d55f4 100644 --- a/contrib/win32/openssh/ssh-shellhost.vcxproj +++ b/contrib/win32/openssh/ssh-shellhost.vcxproj @@ -102,7 +102,7 @@ - Level1 + Level3 Disabled _WIN32_WINNT=0x600;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) false @@ -110,6 +110,7 @@ MultiThreadedDebug ProgramDatabase + Guard Console @@ -130,6 +131,7 @@ MultiThreadedDebug ProgramDatabase + Guard Console @@ -140,7 +142,7 @@ - Level1 + Level3 MaxSpeed @@ -151,6 +153,7 @@ MultiThreaded + Guard Console @@ -175,6 +178,7 @@ MultiThreaded + Guard Console diff --git a/contrib/win32/openssh/ssh.vcxproj b/contrib/win32/openssh/ssh.vcxproj index 144130f..7c96348 100644 --- a/contrib/win32/openssh/ssh.vcxproj +++ b/contrib/win32/openssh/ssh.vcxproj @@ -111,6 +111,7 @@ MultiThreadedDebug Sync ProgramDatabase + Guard Console @@ -134,6 +135,7 @@ CompileAsC MultiThreadedDebug ProgramDatabase + Guard Console @@ -157,6 +159,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console @@ -184,6 +187,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded true + Guard Console diff --git a/contrib/win32/openssh/sshd.vcxproj b/contrib/win32/openssh/sshd.vcxproj index c68b4e1..a55b16c 100644 --- a/contrib/win32/openssh/sshd.vcxproj +++ b/contrib/win32/openssh/sshd.vcxproj @@ -106,6 +106,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -130,6 +131,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase + Guard Console @@ -155,6 +157,7 @@ false $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded + Guard Console @@ -184,6 +187,7 @@ $(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) MultiThreaded false + Guard Console diff --git a/contrib/win32/openssh/version.rc b/contrib/win32/openssh/version.rc index 240081e..bcdc8fb 100644 Binary files a/contrib/win32/openssh/version.rc and b/contrib/win32/openssh/version.rc differ diff --git a/contrib/win32/openssh/win32iocompat.vcxproj b/contrib/win32/openssh/win32iocompat.vcxproj index 15fef53..8e03748 100644 --- a/contrib/win32/openssh/win32iocompat.vcxproj +++ b/contrib/win32/openssh/win32iocompat.vcxproj @@ -98,6 +98,7 @@ ProgramDatabase false false + Guard @@ -112,6 +113,7 @@ Level3 ProgramDatabase false + Guard @@ -124,6 +126,7 @@ Level1 ProgramDatabase false + Guard @@ -139,6 +142,7 @@ Disabled false true + Guard diff --git a/contrib/win32/win32compat/fileio.c b/contrib/win32/win32compat/fileio.c index 03ac241..16b034d 100644 --- a/contrib/win32/win32compat/fileio.c +++ b/contrib/win32/win32compat/fileio.c @@ -666,7 +666,7 @@ fileio_write(struct w32_io* pio, const void *buf, size_t max_bytes) debug3("write - ERROR:%d on prior unblocking write, io:%p", errno, pio); pio->write_details.error = 0; if ((FILETYPE(pio) == FILE_TYPE_PIPE) && (errno == ERROR_BROKEN_PIPE)) { - debug3("write - ERROR:read end of the pipe closed, io:%p", pio); + debug4("write - ERROR:read end of the pipe closed, io:%p", pio); errno = EPIPE; } return -1; diff --git a/contrib/win32/win32compat/misc_internal.h b/contrib/win32/win32compat/misc_internal.h index a2141ac..628a0b7 100644 --- a/contrib/win32/win32compat/misc_internal.h +++ b/contrib/win32/win32compat/misc_internal.h @@ -1,4 +1,6 @@ #pragma once +#include + #define PATH_MAX MAX_PATH #define SSH_ASYNC_STDIN "SSH_ASYNC_STDIN" #define SSH_ASYNC_STDOUT "SSH_ASYNC_STDOUT" @@ -12,7 +14,10 @@ } while(0) #define NULL_DEVICE "/dev/null" +#define IsWin7OrLess() (!IsWindows8OrGreater()) + #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 */ char * sanitized_path(const char *); diff --git a/contrib/win32/win32compat/shell-host.c b/contrib/win32/win32compat/shell-host.c index ab9596b..5a5afbb 100644 --- a/contrib/win32/win32compat/shell-host.c +++ b/contrib/win32/win32compat/shell-host.c @@ -46,6 +46,8 @@ #define MAX_CMD_LEN 8191 // msdn #define WM_APPEXIT WM_USER+1 #define MAX_EXPECTED_BUFFER_SIZE 1024 +/* 4KB is the largest size for which writes are guaranteed to be atomic */ +#define BUFF_SIZE 4096 #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x4 @@ -81,6 +83,19 @@ #define VK_X 0x58 #define VK_Y 0x59 #define VK_Z 0x5A +#define VK_0 0x30 +#define VK_1 0x31 +#define VK_2 0x32 +#define VK_3 0x33 +#define VK_4 0x34 +#define VK_5 0x35 +#define VK_6 0x36 +#define VK_7 0x37 +#define VK_8 0x38 +#define VK_9 0x39 + +const int MAX_CTRL_SEQ_LEN = 7; +const int MIN_CTRL_SEQ_LEN = 6; typedef BOOL(WINAPI *__t_SetCurrentConsoleFontEx)( _In_ HANDLE hConsoleOutput, @@ -115,7 +130,7 @@ typedef struct consoleEvent { } consoleEvent; struct key_translation { - wchar_t in[6]; + wchar_t in[8]; int vk; wchar_t out; int in_key_len; @@ -124,10 +139,10 @@ struct key_translation { /* All the substrings should be in the end, otherwise ProcessIncomingKeys() will not work as expected */ struct key_translation keys[] = { - { L"\r", VK_RETURN, L'\r' , 0 , 0}, - { L"\n", VK_RETURN, L'\r' , 0 , 0 }, - { L"\b", VK_BACK, L'\b' , 0 , 0 }, - { L"\x7f", VK_BACK, L'\b' , 0 , 0 }, + { L"\r", VK_RETURN, L'\r', 0, 0}, + { L"\n", VK_RETURN, L'\r', 0, 0 }, + { L"\b", VK_BACK, L'\b', 0, 0 }, + { L"\x7f", VK_BACK, L'\b', 0 , 0 }, { L"\t", VK_TAB, L'\t' , 0 , 0}, { L"\x1b[A", VK_UP, 0 , 0 , 0}, { L"\x1b[B", VK_DOWN, 0 , 0 , 0}, @@ -189,7 +204,53 @@ struct key_translation keys[] = { { L"\x17", VK_W, L'\x17' , 0 , LEFT_CTRL_PRESSED}, { L"\x18", VK_X, L'\x18' , 0 , LEFT_CTRL_PRESSED}, { L"\x19", VK_Y, L'\x19' , 0 , LEFT_CTRL_PRESSED}, - { L"\x1A", VK_Z, L'\x1A' , 0 , LEFT_CTRL_PRESSED} + { L"\x1A", VK_Z, L'\x1A' , 0 , LEFT_CTRL_PRESSED}, + { L"\033a", VK_A, L'a', 0, LEFT_ALT_PRESSED}, + { L"\033b", VK_B, L'b', 0, LEFT_ALT_PRESSED}, + { L"\033c", VK_C, L'c', 0, LEFT_ALT_PRESSED}, + { L"\033d", VK_D, L'd', 0, LEFT_ALT_PRESSED}, + { L"\033e", VK_E, L'e', 0, LEFT_ALT_PRESSED}, + { L"\033f", VK_F, L'f', 0, LEFT_ALT_PRESSED}, + { L"\033g", VK_G, L'g', 0, LEFT_ALT_PRESSED}, + { L"\033h", VK_H, L'h', 0, LEFT_ALT_PRESSED}, + { L"\033i", VK_I, L'i', 0, LEFT_ALT_PRESSED}, + { L"\033j", VK_J, L'j', 0, LEFT_ALT_PRESSED}, + { L"\033k", VK_K, L'k', 0, LEFT_ALT_PRESSED}, + { L"\033l", VK_L, L'l', 0, LEFT_ALT_PRESSED}, + { L"\033m", VK_M, L'm', 0, LEFT_ALT_PRESSED}, + { L"\033n", VK_N, L'n', 0, LEFT_ALT_PRESSED}, + { L"\033o", VK_O, L'o', 0, LEFT_ALT_PRESSED}, + { L"\033p", VK_P, L'p', 0, LEFT_ALT_PRESSED}, + { L"\033q", VK_Q, L'q', 0, LEFT_ALT_PRESSED}, + { L"\033r", VK_R, L'r', 0, LEFT_ALT_PRESSED}, + { L"\033s", VK_S, L's', 0, LEFT_ALT_PRESSED}, + { L"\033t", VK_T, L't', 0, LEFT_ALT_PRESSED}, + { L"\033u", VK_U, L'u', 0, LEFT_ALT_PRESSED}, + { L"\033v", VK_V, L'v', 0, LEFT_ALT_PRESSED}, + { L"\033w", VK_W, L'w', 0, LEFT_ALT_PRESSED}, + { L"\033x", VK_X, L'x', 0, LEFT_ALT_PRESSED}, + { L"\033y", VK_Y, L'y', 0, LEFT_ALT_PRESSED}, + { L"\033z", VK_Z, L'z', 0, LEFT_ALT_PRESSED}, + { L"\0330", VK_0, L'0', 0, LEFT_ALT_PRESSED}, + { L"\0331", VK_1, L'1', 0, LEFT_ALT_PRESSED}, + { L"\0332", VK_2, L'2', 0, LEFT_ALT_PRESSED}, + { L"\0333", VK_3, L'3', 0, LEFT_ALT_PRESSED}, + { L"\0334", VK_4, L'4', 0, LEFT_ALT_PRESSED}, + { L"\0335", VK_5, L'5', 0, LEFT_ALT_PRESSED}, + { L"\0336", VK_6, L'6', 0, LEFT_ALT_PRESSED}, + { L"\0337", VK_7, L'7', 0, LEFT_ALT_PRESSED}, + { L"\0338", VK_8, L'8', 0, LEFT_ALT_PRESSED}, + { L"\0339", VK_9, L'9', 0, LEFT_ALT_PRESSED}, + { L"\033!", VK_1, L'!', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033@", VK_2, L'@', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033#", VK_3, L'#', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033$", VK_4, L'$', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033%", VK_5, L'%', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033^", VK_6, L'^', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033&", VK_7, L'&', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033*", VK_8, L'*', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033(", VK_9, L'(', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED }, + { L"\033)", VK_0, L')', 0, LEFT_ALT_PRESSED | SHIFT_PRESSED } }; static SHORT lastX = 0; @@ -215,6 +276,7 @@ HANDLE pipe_in = INVALID_HANDLE_VALUE; HANDLE pipe_out = INVALID_HANDLE_VALUE; HANDLE pipe_err = INVALID_HANDLE_VALUE; HANDLE child = INVALID_HANDLE_VALUE; +HANDLE job = NULL; HANDLE hConsoleBuffer = INVALID_HANDLE_VALUE; HANDLE monitor_thread = INVALID_HANDLE_VALUE; HANDLE io_thread = INVALID_HANDLE_VALUE; @@ -334,11 +396,19 @@ initialize_keylen() } int -ProcessCtrlSequence(wchar_t *buf, int buf_len) +ProcessModifierKeySequence(wchar_t *buf, int buf_len) { - int vkey = 0; - /* Decode special keys when pressed CTRL key */ - if (buf[0] == L'\033' && buf[1] == L'[' && buf[buf_len - 3] == L';' && buf[buf_len - 2] == L'5') { + if(buf_len < MIN_CTRL_SEQ_LEN) + return 0; + + int vkey = 0; + int modifier_key = _wtoi((wchar_t *)&buf[buf_len - 2]); + + if ((modifier_key < 2) && (modifier_key > 7)) + return 0; + + /* Decode special keys when pressed ALT/CTRL/SHIFT key */ + if (buf[0] == L'\033' && buf[1] == L'[' && buf[buf_len - 3] == L';') { if (buf[buf_len - 1] == L'~') { /* VK_DELETE, VK_PGDN, VK_PGUP */ if (!vkey && buf_len == 6) @@ -356,18 +426,51 @@ ProcessCtrlSequence(wchar_t *buf, int buf_len) if (!vkey && buf_len == 6 && buf[2] == L'1' && isalpha(buf[5])) vkey = GetVirtualKeyByMask(L'O', &buf[5], 1, 0); } - if (vkey) - SendKeyStroke(child_in, vkey, 0, LEFT_CTRL_PRESSED); + if (vkey) { + switch (modifier_key) + { + case 2: + SendKeyStroke(child_in, vkey, 0, SHIFT_PRESSED); + break; + case 3: + SendKeyStroke(child_in, vkey, 0, LEFT_ALT_PRESSED); + break; + case 4: + SendKeyStroke(child_in, vkey, 0, SHIFT_PRESSED | LEFT_ALT_PRESSED); + break; + case 5: + SendKeyStroke(child_in, vkey, 0, LEFT_CTRL_PRESSED); + break; + case 6: + SendKeyStroke(child_in, vkey, 0, SHIFT_PRESSED | LEFT_CTRL_PRESSED); + break; + case 7: + SendKeyStroke(child_in, vkey, 0, LEFT_CTRL_PRESSED | LEFT_ALT_PRESSED); + break; + } + } + } return vkey; } +int +CheckKeyTranslations(wchar_t *buf, int buf_len, int *index) +{ + for (int j = 0; j < ARRAYSIZE(keys); j++) { + if ((buf_len >= keys[j].in_key_len) && (wcsncmp(buf, keys[j].in, keys[j].in_key_len) == 0)) { + *index = j; + return 1; + } + } + + return 0; +} void ProcessIncomingKeys(char * ansikey) { int buf_len = 0; - const int MAX_CTRL_SEQ_LEN = 7; const wchar_t *ESC_SEQ = L"\x1b"; wchar_t *buf = utf8_to_utf16(ansikey); @@ -378,26 +481,33 @@ ProcessIncomingKeys(char * ansikey) loop: while (buf && ((buf_len=(int)wcslen(buf)) > 0)) { - for (int j = 0; j < ARRAYSIZE(keys); j++) { - if ( (buf_len >= keys[j].in_key_len) && (wcsncmp(buf, keys[j].in, keys[j].in_key_len) == 0) ) { - SendKeyStroke(child_in, keys[j].vk, keys[j].out, keys[j].ctrlState); - buf += keys[j].in_key_len; - goto loop; - } + int j = 0; + if (CheckKeyTranslations(buf, buf_len, &j)) { + SendKeyStroke(child_in, keys[j].vk, keys[j].out, keys[j].ctrlState); + buf += keys[j].in_key_len; + goto loop; } /* Decode special keys when pressed CTRL key. CTRL sequences can be of size 6 or 7. */ - if ((buf_len >= MAX_CTRL_SEQ_LEN) && ProcessCtrlSequence(buf, MAX_CTRL_SEQ_LEN)) { + if ((buf_len >= MAX_CTRL_SEQ_LEN) && ProcessModifierKeySequence(buf, MAX_CTRL_SEQ_LEN)) { buf += MAX_CTRL_SEQ_LEN; goto loop; } - if ((buf_len >= (MAX_CTRL_SEQ_LEN - 1)) && ProcessCtrlSequence(buf, MAX_CTRL_SEQ_LEN - 1)) { + if ((buf_len >= (MAX_CTRL_SEQ_LEN - 1)) && ProcessModifierKeySequence(buf, MAX_CTRL_SEQ_LEN - 1)) { buf += (MAX_CTRL_SEQ_LEN - 1); goto loop; } if(wcsncmp(buf, ESC_SEQ, wcslen(ESC_SEQ)) == 0) { + wchar_t* p = buf + wcslen(ESC_SEQ); + /* Alt sequence */ + if (CheckKeyTranslations(p, buf_len - (int)wcslen(ESC_SEQ), &j) && !(keys[j].ctrlState & LEFT_ALT_PRESSED)) { + SendKeyStroke(child_in, keys[j].vk, keys[j].out, keys[j].ctrlState| LEFT_ALT_PRESSED); + buf += wcslen(ESC_SEQ) +keys[j].in_key_len; + goto loop; + } + SendKeyStroke(child_in, VK_ESCAPE, L'\x1b', 0); buf += wcslen(ESC_SEQ); goto loop; @@ -1110,7 +1220,7 @@ start_with_pty(wchar_t *command) HMODULE hm_kernel32 = NULL, hm_user32 = NULL; wchar_t kernel32_dll_path[PATH_MAX]={0,}, user32_dll_path[PATH_MAX]={0,}; - if(cmd == NULL) { + if (cmd == NULL) { printf_s("ssh-shellhost is out of memory"); exit(255); } @@ -1170,11 +1280,9 @@ start_with_pty(wchar_t *command) GOTO_CLEANUP_ON_FALSE(SetHandleInformation(pipe_in, HANDLE_FLAG_INHERIT, 0)); cmd[0] = L'\0'; - GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, w32_cmd_path())); - + GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, w32_cmd_path())); if (command) { - GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" /c")); - GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" ")); + GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" /c ")); GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, command)); } @@ -1265,18 +1373,17 @@ start_withno_pty(wchar_t *command) { STARTUPINFO si; PROCESS_INFORMATION pi; - wchar_t *cmd = (wchar_t *) malloc(sizeof(wchar_t) * MAX_CMD_LEN); + wchar_t *cmd = (wchar_t *)malloc(sizeof(wchar_t) * MAX_CMD_LEN); SECURITY_ATTRIBUTES sa; BOOL ret, process_input = FALSE, run_under_cmd = FALSE; size_t command_len; - char buf[128]; + char *buf = (char *)malloc(BUFF_SIZE + 1); DWORD rd = 0, wr = 0, i = 0; if (cmd == NULL) { printf_s("ssh-shellhost is out of memory"); exit(255); } - pipe_in = GetStdHandle(STD_INPUT_HANDLE); pipe_out = GetStdHandle(STD_OUTPUT_HANDLE); pipe_err = GetStdHandle(STD_ERROR_HANDLE); @@ -1287,8 +1394,11 @@ start_withno_pty(wchar_t *command) memset(&sa, 0, sizeof(SECURITY_ATTRIBUTES)); sa.bInheritHandle = TRUE; - if (!CreatePipe(&child_pipe_read, &child_pipe_write, &sa, 128)) + /* use the default buffer size, 64K*/ + if (!CreatePipe(&child_pipe_read, &child_pipe_write, &sa, 0)) { + printf_s("ssh-shellhost-can't open no pty session, error: %d", GetLastError()); return -1; + } memset(&si, 0, sizeof(STARTUPINFO)); memset(&pi, 0, sizeof(PROCESS_INFORMATION)); @@ -1320,10 +1430,10 @@ start_withno_pty(wchar_t *command) process_input = TRUE; else { command_len = wcsnlen_s(command, MAX_CMD_LEN); - if ((command_len >= 3 && wcsncmp(command, L"cmd", 4) == 0) || - (command_len >= 7 && wcsncmp(command, L"cmd.exe", 8) == 0) || - (command_len >= 4 && wcsncmp(command, L"cmd ", 4) == 0) || - (command_len >= 8 && wcsncmp(command, L"cmd.exe ", 8) == 0)) + if ((command_len >= 3 && _wcsnicmp(command, L"cmd", 4) == 0) || + (command_len >= 7 && _wcsnicmp(command, L"cmd.exe", 8) == 0) || + (command_len >= 4 && _wcsnicmp(command, L"cmd ", 4) == 0) || + (command_len >= 8 && _wcsnicmp(command, L"cmd.exe ", 8) == 0)) process_input = TRUE; } @@ -1342,12 +1452,11 @@ start_withno_pty(wchar_t *command) run_under_cmd = TRUE; /* if above failed with FILE_NOT_FOUND, try running the provided command under cmd*/ - if (run_under_cmd) { + if (run_under_cmd) { cmd[0] = L'\0'; GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, w32_cmd_path())); if (command) { - GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" /c")); - GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" ")); + GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" /c ")); GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, command)); } @@ -1368,10 +1477,15 @@ start_withno_pty(wchar_t *command) /* disable Ctrl+C hander in this process*/ SetConsoleCtrlHandler(NULL, TRUE); + if (buf == NULL) { + printf_s("ssh-shellhost is out of memory"); + exit(255); + } /* process data from pipe_in and route appropriately */ while (1) { rd = wr = i = 0; - GOTO_CLEANUP_ON_FALSE(ReadFile(pipe_in, buf, sizeof(buf)-1, &rd, NULL)); + buf[0] = L'\0'; + GOTO_CLEANUP_ON_FALSE(ReadFile(pipe_in, buf, BUFF_SIZE, &rd, NULL)); if (process_input == FALSE) { /* write stream directly to child stdin */ @@ -1413,12 +1527,10 @@ start_withno_pty(wchar_t *command) /* For CR and LF */ if ((buf[i] == '\r') || (buf[i] == '\n')) { - /* TODO - do a much accurate mapping */ - GOTO_CLEANUP_ON_FALSE(WriteFile(pipe_out, buf + i, 1, &wr, NULL)); - if ((buf[i] == '\r') && ((i == rd - 1) || (buf[i + 1] != '\n'))) { + /* TODO - do a much accurate mapping */ + if ((buf[i] == '\r') && ((i == rd - 1) || (buf[i + 1] != '\n'))) buf[i] = '\n'; - GOTO_CLEANUP_ON_FALSE(WriteFile(pipe_out, buf + i, 1, &wr, NULL)); - } + GOTO_CLEANUP_ON_FALSE(WriteFile(pipe_out, buf + i, 1, &wr, NULL)); in_cmd[in_cmd_len] = buf[i]; in_cmd_len++; GOTO_CLEANUP_ON_FALSE(WriteFile(child_pipe_write, in_cmd, in_cmd_len, &wr, NULL)); @@ -1449,6 +1561,12 @@ cleanup: } if (!IS_INVALID_HANDLE(child)) TerminateProcess(child, 0); + + if (buf != NULL) + free(buf); + + if (cmd != NULL) + free(cmd); return child_exit_code; } @@ -1554,6 +1672,7 @@ wmain(int ac, wchar_t **av) { int pty_requested = 0; wchar_t *cmd = NULL, *cmd_b64 = NULL; + JOBOBJECT_EXTENDED_LIMIT_INFORMATION job_info; _set_invalid_parameter_handler(my_invalid_parameter_handler); if ((ac == 1) || (ac == 2 && wcscmp(av[1], L"-nopty"))) { @@ -1595,6 +1714,21 @@ wmain(int ac, wchar_t **av) exit(255); } + /* assign to job object */ + if ((job = CreateJobObjectW(NULL, NULL)) == NULL) { + printf_s("cannot create job object, error: %d", GetLastError()); + return -1; + } + + memset(&job_info, 0, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION)); + job_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; + + if (!SetInformationJobObject(job, JobObjectExtendedLimitInformation, &job_info, sizeof(job_info)) || + !AssignProcessToJobObject(job, GetCurrentProcess())) { + printf_s("cannot associate job object: %d", GetLastError()); + return -1; + } + if (pty_requested) return start_with_pty(cmd); else diff --git a/contrib/win32/win32compat/signal_sigchld.c b/contrib/win32/win32compat/signal_sigchld.c index 3351311..4d415ab 100644 --- a/contrib/win32/win32compat/signal_sigchld.c +++ b/contrib/win32/win32compat/signal_sigchld.c @@ -40,7 +40,7 @@ register_child(HANDLE child, DWORD pid) { DWORD first_zombie_index; - debug3("Register child %p pid %d, %d zombies of %d", child, pid, + debug4("Register child %p pid %d, %d zombies of %d", child, pid, children.num_zombies, children.num_children); if (children.num_children == MAX_CHILDREN) { errno = ENOMEM; @@ -67,7 +67,7 @@ int sw_remove_child_at_index(DWORD index) { DWORD last_non_zombie; - debug3("Unregister child at index %d, %d zombies of %d", index, + debug4("Unregister child at index %d, %d zombies of %d", index, children.num_zombies, children.num_children); if ((index >= children.num_children) || (children.num_children == 0)) { @@ -105,7 +105,7 @@ sw_child_to_zombie(DWORD index) DWORD last_non_zombie, zombie_pid; HANDLE zombie_handle; - debug3("zombie'ing child at index %d, %d zombies of %d", index, + debug4("zombie'ing child at index %d, %d zombies of %d", index, children.num_zombies, children.num_children); if (index >= children.num_children) { diff --git a/contrib/win32/win32compat/ssh-agent/agent-main.c b/contrib/win32/win32compat/ssh-agent/agent-main.c index f3fee97..08013d6 100644 --- a/contrib/win32/win32compat/ssh-agent/agent-main.c +++ b/contrib/win32/win32compat/ssh-agent/agent-main.c @@ -32,6 +32,8 @@ #include "agent.h" #include "..\misc_internal.h" +#include "..\Debug.h" +#include #pragma warning(push, 3) @@ -90,16 +92,33 @@ BOOL WINAPI ctrl_c_handler(_In_ DWORD dwCtrlType) { /* for any Ctrl type, shutdown agent*/ - debug3("Ctrl+C received"); + debug4("Ctrl+C received"); agent_shutdown(); return TRUE; } +/*set current working directory to module path*/ +static void +fix_cwd() +{ + wchar_t path[PATH_MAX] = { 0 }; + int i, lastSlashPos = 0; + GetModuleFileNameW(NULL, path, PATH_MAX); + for (i = 0; path[i]; i++) { + if (path[i] == L'/' || path[i] == L'\\') + lastSlashPos = i; + } + + path[lastSlashPos] = 0; + _wchdir(path); +} + int wmain(int argc, wchar_t **argv) { _set_invalid_parameter_handler(invalid_parameter_handler); w32posix_initialize(); + fix_cwd(); /* this exits() on failure*/ load_config(); if (!StartServiceCtrlDispatcherW(dispatch_table)) { diff --git a/contrib/win32/win32compat/ssh-agent/agentconfig.c b/contrib/win32/win32compat/ssh-agent/agentconfig.c index cd45f43..ecea9db 100644 --- a/contrib/win32/win32compat/ssh-agent/agentconfig.c +++ b/contrib/win32/win32compat/ssh-agent/agentconfig.c @@ -53,7 +53,6 @@ Buffer cfg; ServerOptions options; struct passwd *privsep_pw = NULL; -static char *config_file_name = _PATH_SERVER_CONFIG_FILE; int auth_sock = -1; int @@ -96,48 +95,10 @@ kexgex_server(struct ssh * sh) { return -1; } -static int -GetCurrentModulePath(wchar_t *path, int pathSize) -{ - if (GetModuleFileNameW(NULL, path, pathSize)) { - int i; - int lastSlashPos = 0; - - for (i = 0; path[i]; i++) { - if (path[i] == L'/' || path[i] == L'\\') - lastSlashPos = i; - } - - path[lastSlashPos] = 0; - return 0; - } - return -1; -} - int load_config() { - wchar_t basePath[PATH_MAX] = { 0 }; - wchar_t path[PATH_MAX] = { 0 }; - wchar_t* config_file = L"/sshd_config"; + char *config_file_name = "sshd_config"; errno_t r = 0; - - if (GetCurrentModulePath(basePath, PATH_MAX) == -1) - return -1; - - if (wcsnlen_s(basePath, PATH_MAX) + wcslen(config_file) + 1 > PATH_MAX) - fatal("unexpected config file path length"); - - if(( r = wcsncpy_s(path, PATH_MAX, basePath, wcsnlen_s(basePath, PATH_MAX))) != 0) { - debug3("memcpy_s failed with error: %d.", r); - return -1; - } - if (( r = wcsncat_s(path, PATH_MAX, L"/sshd_config", PATH_MAX - wcsnlen_s(basePath, PATH_MAX))) != 0) { - debug3("wcscat_s failed with error: %d.", r); - return -1; - } - - if ((config_file_name = utf16_to_utf8(path)) == NULL) - return -1; buffer_init(&cfg); initialize_server_options(&options); @@ -154,10 +115,10 @@ config_log_level() { } int -pubkey_allowed(struct sshkey* pubkey, HANDLE user_token) { +pubkey_allowed(struct sshkey* pubkey, char* user_utf8) { struct passwd *pw; - if ((pw = w32_getpwtoken(user_token)) == NULL) + if ((pw = w32_getpwnam(user_utf8)) == NULL) return 0; return user_key_allowed(pw, pubkey, 1); diff --git a/contrib/win32/win32compat/ssh-agent/authagent-request.c b/contrib/win32/win32compat/ssh-agent/authagent-request.c index cf681d9..274646d 100644 --- a/contrib/win32/win32compat/ssh-agent/authagent-request.c +++ b/contrib/win32/win32compat/ssh-agent/authagent-request.c @@ -43,7 +43,7 @@ #pragma warning(push, 3) -int pubkey_allowed(struct sshkey* pubkey, HANDLE user_token); +int pubkey_allowed(struct sshkey* pubkey, char* user_utf8); static void InitLsaString(LSA_STRING *lsa_string, const char *str) @@ -287,7 +287,7 @@ int process_pubkeyauth_request(struct sshbuf* request, struct sshbuf* response, } - if (pubkey_allowed(key, token) != 1) { + if (pubkey_allowed(key, user) != 1) { debug("unable to verify public key for user %ls (profile:%ls)", user_utf16, wuser_home); goto done; } diff --git a/contrib/win32/win32compat/termio.c b/contrib/win32/win32compat/termio.c index 5494bef..57b81cd 100644 --- a/contrib/win32/win32compat/termio.c +++ b/contrib/win32/win32compat/termio.c @@ -106,9 +106,9 @@ ReadThread(_In_ LPVOID lpParameter) } 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)) { + debug4("ReadThread - ReadFile failed, error:%d, io:%p", GetLastError(), pio); read_status.error = GetLastError(); - debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio); return -1; } @@ -127,13 +127,12 @@ ReadThread(_In_ LPVOID lpParameter) } else { if (!ReadFile(WINHANDLE(pio), pio->read_details.buf, pio->read_details.buf_size, &read_status.transferred, NULL)) { + debug4("ReadThread - ReadFile failed, error:%d, io:%p", GetLastError(), pio); read_status.error = GetLastError(); - debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio); return -1; } } - if (0 == QueueUserAPC(ReadAPCProc, main_thread, (ULONG_PTR)pio)) { - debug3("TermRead thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio); + if (0 == QueueUserAPC(ReadAPCProc, main_thread, (ULONG_PTR)pio)) { pio->read_details.pending = FALSE; pio->read_details.error = GetLastError(); DebugBreak(); @@ -195,7 +194,7 @@ WriteThread(_In_ LPVOID lpParameter) struct w32_io* pio = (struct w32_io*)lpParameter; char *respbuf = NULL; size_t resplen = 0; - debug5("TermWrite thread, io:%p", pio); + debug5("WriteThread thread, io:%p", pio); if (FILETYPE(pio) == FILE_TYPE_CHAR) { pio->write_details.buf[write_status.to_transfer] = '\0'; @@ -212,13 +211,13 @@ WriteThread(_In_ LPVOID lpParameter) if (!WriteFile(WINHANDLE(pio), pio->write_details.buf, write_status.to_transfer, &write_status.transferred, NULL)) { write_status.error = GetLastError(); - debug("WriteThread - ReadFile WriteFile %d, io:%p", GetLastError(), pio); + debug4("WriteThread - WriteFile %d, io:%p", GetLastError(), pio); } } if (0 == QueueUserAPC(WriteAPCProc, main_thread, (ULONG_PTR)pio)) { - debug3("TermWrite thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio); + debug3("WriteThread thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio); pio->write_details.pending = FALSE; pio->write_details.error = GetLastError(); DebugBreak(); @@ -232,13 +231,13 @@ int syncio_initiate_write(struct w32_io* pio, DWORD num_bytes) { HANDLE write_thread; - debug5("TermWrite initiate io:%p", pio); + debug5("syncio_initiate_write initiate io:%p", pio); memset(&write_status, 0, sizeof(write_status)); write_status.to_transfer = num_bytes; write_thread = CreateThread(NULL, 0, WriteThread, pio, 0, NULL); if (write_thread == NULL) { errno = errno_from_Win32LastError(); - debug3("TermWrite initiate - ERROR CreateThread %d, io:%p", GetLastError(), pio); + debug3("syncio_initiate_write initiate - ERROR CreateThread %d, io:%p", GetLastError(), pio); return -1; } @@ -256,8 +255,12 @@ syncio_close(struct w32_io* pio) /* If io is pending, let worker threads exit. */ 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); else WaitForSingleObject(pio->read_overlapped.hEvent, INFINITE); diff --git a/contrib/win32/win32compat/tncon.c b/contrib/win32/win32compat/tncon.c index 3b3a396..ce0be04 100644 --- a/contrib/win32/win32compat/tncon.c +++ b/contrib/win32/win32compat/tncon.c @@ -50,6 +50,7 @@ extern int ScreenY; extern int ScreenX; extern int ScrollTop; extern int ScrollBottom; +unsigned char tmp_buf[30]; /* terminal global switches*/ TelParams Parameters = { @@ -102,6 +103,27 @@ DataAvailable(HANDLE h) return FALSE; } +int +GetModifierKey(DWORD dwControlKeyState) +{ + int modKey = 0; + if ((dwControlKeyState & LEFT_ALT_PRESSED) || (dwControlKeyState & RIGHT_ALT_PRESSED)) + modKey += 2; + + if (dwControlKeyState & SHIFT_PRESSED) + modKey += 1; + + if ((dwControlKeyState & LEFT_CTRL_PRESSED) || (dwControlKeyState & RIGHT_CTRL_PRESSED)) + modKey += 4; + + if (modKey){ + memset(tmp_buf, 0, sizeof(tmp_buf)); + modKey++; + } + + return modKey; +} + int ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen) { @@ -110,11 +132,12 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen) DWORD dwInput = 0; DWORD dwControlKeyState = 0; DWORD rc = 0; - unsigned char octets[20]; + unsigned char octets[20]; char aChar = 0; INPUT_RECORD InputRecord; BOOL bCapsOn = FALSE; BOOL bShift = FALSE; + int modKey = 0; glob_out = destin; glob_space = destinlen; @@ -138,6 +161,7 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen) bShift = (InputRecord.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED); dwControlKeyState = InputRecord.Event.KeyEvent.dwControlKeyState & ~(CAPSLOCK_ON | ENHANCED_KEY | NUMLOCK_ON | SCROLLLOCK_ON); + modKey = GetModifierKey(dwControlKeyState); if (InputRecord.Event.KeyEvent.bKeyDown) { int n = WideCharToMultiByte( CP_UTF8, @@ -167,34 +191,144 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen) default: switch (InputRecord.Event.KeyEvent.wVirtualKeyCode) { case VK_UP: - NetWriteString2(pParams->Socket, (char *)(gbVTAppMode ? APP_UP_ARROW : UP_ARROW), 3, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)(gbVTAppMode ? APP_UP_ARROW : UP_ARROW), 3, 0); + else { + /* ^[[1;mA */ + char *p = "\033[1;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = 'A'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_DOWN: - NetWriteString2(pParams->Socket, (char *)(gbVTAppMode ? APP_DOWN_ARROW : DOWN_ARROW), 3, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)(gbVTAppMode ? APP_DOWN_ARROW : DOWN_ARROW), 3, 0); + else { + /* ^[[1;mB */ + char *p = "\033[1;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = 'B'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_RIGHT: - NetWriteString2(pParams->Socket, (char *)(gbVTAppMode ? APP_RIGHT_ARROW : RIGHT_ARROW), 3, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)(gbVTAppMode ? APP_RIGHT_ARROW : RIGHT_ARROW), 3, 0); + else { + /* ^[[1;mC */ + char *p = "\033[1;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = 'C'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_LEFT: - NetWriteString2(pParams->Socket, (char *)(gbVTAppMode ? APP_LEFT_ARROW : LEFT_ARROW), 3, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)(gbVTAppMode ? APP_LEFT_ARROW : LEFT_ARROW), 3, 0); + else { + /* ^[[1;mD */ + char *p = "\033[1;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = 'D'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_END: - NetWriteString2(pParams->Socket, (char *)SELECT_KEY, 4, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)SELECT_KEY, 4, 0); + else { + /* ^[[1;mF */ + char *p = "\033[1;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = 'F'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_HOME: - NetWriteString2(pParams->Socket, (char *)FIND_KEY, 4, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)FIND_KEY, 4, 0); + else { + /* ^[[1;mH */ + char *p = "\033[1;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = 'H'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_INSERT: - NetWriteString2(pParams->Socket, (char *)INSERT_KEY, 4, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)INSERT_KEY, 4, 0); + else { + /* ^[[2;m~ */ + char *p = "\033[2;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = '~'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_DELETE: - NetWriteString2(pParams->Socket, (char *)REMOVE_KEY, 4, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)REMOVE_KEY, 4, 0); + else { + /* ^[[3;m~ */ + char *p = "\033[3;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = '~'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_PRIOR: /* page up */ - NetWriteString2(pParams->Socket, (char *)PREV_KEY, 4, 0); + if (!modKey) + NetWriteString2(pParams->Socket, (char *)PREV_KEY, 4, 0); + else { + /* ^[[5;m~ */ + char *p = "\033[5;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = '~'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_NEXT: /* page down */ - NetWriteString2(pParams->Socket, (char *)NEXT_KEY, 4, 0); + if(!modKey) + NetWriteString2(pParams->Socket, (char *)NEXT_KEY, 4, 0); + else { + /* ^[[6;m~ */ + char *p = "\033[6;"; + strcpy_s(tmp_buf, sizeof(tmp_buf), p); + size_t index = strlen(p); + tmp_buf[index++] = modKey + '0'; + tmp_buf[index] = '~'; + + NetWriteString2(pParams->Socket, tmp_buf, index+1, 0); + } break; case VK_BACK: NetWriteString2(pParams->Socket, (char *)BACKSPACE_KEY, 1, 0); @@ -574,7 +708,16 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen) NetWriteString2(pParams->Socket, (char *)SHIFT_CTRL_PF12_KEY, strlen(SHIFT_CTRL_PF12_KEY), 0); break; default: - NetWriteString2(pParams->Socket, (char *)octets, n, 0); + if (strcmp((char *) octets, "")) { + if ((dwControlKeyState & LEFT_ALT_PRESSED) || (dwControlKeyState & RIGHT_ALT_PRESSED)) { + memset(tmp_buf, 0, sizeof(tmp_buf)); + tmp_buf[0] = '\x1b'; + memcpy(tmp_buf + 1, (char *)octets, n); + NetWriteString2(pParams->Socket, tmp_buf, n + 1, 0); + } + else + NetWriteString2(pParams->Socket, (char *)octets, n, 0); + } break; } } diff --git a/contrib/win32/win32compat/tnnet.c b/contrib/win32/win32compat/tnnet.c index 5c53ebe..244e726 100644 --- a/contrib/win32/win32compat/tnnet.c +++ b/contrib/win32/win32compat/tnnet.c @@ -84,8 +84,11 @@ processBuffer(HANDLE handle, char *buf, size_t len, unsigned char **respbuf, siz /* Console has the capability to parse so pass the raw buffer to console directly */ ConRestoreViewRect(); /* Restore the visible window, otherwise WriteConsoleW() gets messy */ wchar_t* t = utf8_to_utf16(buf); - WriteConsoleW(handle, t, (DWORD)wcslen(t), 0, 0); - free(t); + if (t) { + WriteConsoleW(handle, t, (DWORD)wcslen(t), 0, 0); + free(t); + } + ConSaveViewRect(); return; } diff --git a/contrib/win32/win32compat/w32fd.c b/contrib/win32/win32compat/w32fd.c index 3cea3a4..9dab2b0 100644 --- a/contrib/win32/win32compat/w32fd.c +++ b/contrib/win32/win32compat/w32fd.c @@ -254,7 +254,7 @@ w32_socket(int domain, int type, int protocol) } fd_table_set(pio, min_index); - debug3("socket:%d, socktype:%d, io:%p, fd:%d ", pio->sock, type, pio, min_index); + debug4("socket:%d, socktype:%d, io:%p, fd:%d ", pio->sock, type, pio, min_index); return min_index; } @@ -275,7 +275,7 @@ w32_accept(int fd, struct sockaddr* addr, int* addrlen) pio->type = SOCK_FD; fd_table_set(pio, min_index); - debug3("socket:%d, io:%p, fd:%d ", pio->sock, pio, min_index); + debug4("socket:%d, io:%p, fd:%d ", pio->sock, pio, min_index); return min_index; } @@ -404,7 +404,7 @@ w32_pipe(int *pfds) fd_table_set(pio[1], write_index); pfds[0] = read_index; pfds[1] = write_index; - debug3("pipe - r-h:%d,io:%p,fd:%d w-h:%d,io:%p,fd:%d", + debug4("pipe - r-h:%d,io:%p,fd:%d w-h:%d,io:%p,fd:%d", pio[0]->handle, pio[0], read_index, pio[1]->handle, pio[1], write_index); return 0; @@ -434,7 +434,7 @@ w32_open(const char *pathname, int flags, ... /* arg */) pio->type = NONSOCK_FD; fd_table_set(pio, min_index); - debug3("open - handle:%p, io:%p, fd:%d", pio->handle, pio, min_index); + debug4("open - handle:%p, io:%p, fd:%d", pio->handle, pio, min_index); debug5("open - path:%s", pathname); return min_index; } @@ -532,7 +532,7 @@ w32_close(int fd) pio = fd_table.w32_ios[fd]; - debug3("close - io:%p, type:%d, fd:%d, table_index:%d", pio, pio->type, fd, + debug4("close - io:%p, type:%d, fd:%d, table_index:%d", pio, pio->type, fd, pio->table_index); if (pio->type == SOCK_FD) @@ -556,17 +556,17 @@ w32_io_process_fd_flags(struct w32_io* pio, int flags) shi_flags = (flags & FD_CLOEXEC) ? 0 : HANDLE_FLAG_INHERIT; - if (SetHandleInformation(WINHANDLE(pio), HANDLE_FLAG_INHERIT, shi_flags) == FALSE) { - /* - * 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", - GetLastError(), pio); - errno = EOTHER; - return -1; - } + 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 + */ + if (IS_VALID_HANDLE(h) && (SetHandleInformation(h, HANDLE_FLAG_INHERIT, shi_flags) == FALSE)) { + debug3("fcntl - SetHandleInformation failed with error:%d, io:%p", + GetLastError(), pio); + errno = EOTHER; + return -1; } pio->fd_flags = flags; @@ -731,7 +731,7 @@ w32_select(int fds, w32_fd_set* readfds, w32_fd_set* writefds, w32_fd_set* excep if (timeout != NULL) { if (timeout_ms < ticks_spent) { - debug3("select - timing out"); + debug4("select - timing out"); break; } time_rem = timeout_ms - (ticks_spent & 0xffffffff); @@ -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); return out_ready_fds; - } int diff --git a/regress/pesterTests/SSHDConfig.tests.ps1 b/regress/pesterTests/SSHDConfig.tests.ps1 index 858d796..eb1d510 100644 --- a/regress/pesterTests/SSHDConfig.tests.ps1 +++ b/regress/pesterTests/SSHDConfig.tests.ps1 @@ -25,7 +25,7 @@ Describe "Tests of sshd_config" -Tags "CI" { Add-Type -AssemblyName System.DirectoryServices.AccountManagement $ContextName = $env:COMPUTERNAME $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 function Add-LocalUser @@ -35,7 +35,7 @@ Describe "Tests of sshd_config" -Tags "CI" { if($user -eq $null) { 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() } finally { @@ -51,7 +51,7 @@ Describe "Tests of sshd_config" -Tags "CI" { if($group -eq $null) { try { - $group = [System.DirectoryServices.AccountManagement.GroupPrincipal]::new($PrincipalContext,$groupName) + $group = new-object -TypeName System.DirectoryServices.AccountManagement.GroupPrincipal -ArgumentList @($PrincipalContext,$groupName) $group.Save() } finally { diff --git a/ssh-keygen.c b/ssh-keygen.c index 514cacb..3b69398 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c @@ -1788,8 +1788,15 @@ do_ca_sign(struct passwd *pw, int argc, char **argv) if ((fd = open(out, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) fatal("Could not open \"%s\" for writing: %s", out, strerror(errno)); +#ifdef WINDOWS + /* Windows POSIX adpater does not support fdopen() on open(file)*/ + close(fd); + if ((f = fopen(out, "w")) == NULL) + fatal("fopen %s failed: %s", identity_file, strerror(errno)); +#else /* !WINDOWS */ if ((f = fdopen(fd, "w")) == NULL) fatal("%s: fdopen: %s", __func__, strerror(errno)); +#endif /* !WINDOWS */ if ((r = sshkey_write(public, f)) != 0) fatal("Could not write certified key to %s: %s", out, ssh_err(r));