Source snapshot from Powershell/openssh-portable:latestw_all

This commit is contained in:
Yanbing Wang 2017-10-02 17:56:31 -07:00
parent 25a4ae6a3c
commit 727329abd4
33 changed files with 489 additions and 164 deletions

View File

@ -1,4 +1,4 @@
version: 0.0.20.0.{build}
version: 0.0.21.0.{build}
image: Visual Studio 2015
branches:

View File

@ -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')

View File

@ -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 $_) }

View File

@ -220,19 +220,19 @@ 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 {
try {
$types = Add-Type $definition -ref $references -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
}
catch {
$types = Add-Type $definition -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
}
}
function Add-Privilege
{

View File

@ -106,6 +106,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -126,6 +127,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -147,6 +149,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -171,6 +174,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -102,6 +102,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CompileAs>CompileAsC</CompileAs>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>false</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -120,6 +121,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CompileAs>CompileAsC</CompileAs>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>false</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -137,6 +139,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>false</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -157,6 +160,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
<ControlFlowGuard>false</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -88,6 +88,7 @@
<ClCompile Include="$(OpenSSH-Src-Path)uuencode.c" />
<ClCompile Include="$(OpenSSH-Src-Path)verify.c" />
<ClCompile Include="$(OpenSSH-Src-Path)xmalloc.c" />
<ClCompile Include="$(OpenSSH-Src-Path)kexgexs.c" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(OpenSSH-Src-Path)addrmatch.c">
@ -129,18 +130,12 @@
<ClCompile Include="$(OpenSSH-Src-Path)channels.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)cipher-3des1.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)cipher-aes.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)cipher-aesctr.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)cipher-bf1.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)cipher-chachapoly.c">
<Filter>Source Files</Filter>
</ClCompile>
@ -159,9 +154,6 @@
<ClCompile Include="$(OpenSSH-Src-Path)crc32.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)deattack.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)dh.c">
<Filter>Source Files</Filter>
</ClCompile>

View File

@ -200,6 +200,7 @@
<AdditionalIncludeDirectories>$(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)openbsd-compat;$(OpenSSH-Src-Path)libkrb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -216,6 +217,7 @@
<AdditionalIncludeDirectories>$(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)openbsd-compat;$(OpenSSH-Src-Path)libkrb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -233,6 +235,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)openbsd-compat;$(OpenSSH-Src-Path)libkrb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -253,6 +256,7 @@
<AdditionalIncludeDirectories>$(SolutionDir);$(LibreSSL-Path)include;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)openbsd-compat;$(OpenSSH-Src-Path)libkrb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -195,10 +195,16 @@
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\xcrypt.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\openbsd-compat\glob.c">
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\bsd-getpagesize.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\openbsd-compat\strcasestr.c">
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\recallocarray.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\glob.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)openbsd-compat\strcasestr.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>

View File

@ -113,6 +113,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -132,6 +133,8 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -153,6 +156,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -177,6 +181,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -115,6 +115,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -135,6 +136,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -156,6 +158,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -180,6 +183,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -118,6 +118,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -138,6 +139,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -159,6 +161,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -183,6 +186,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -116,6 +116,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -136,6 +137,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -157,6 +159,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -181,6 +184,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -111,6 +111,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<ExceptionHandling>Sync</ExceptionHandling>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -133,6 +134,7 @@
<CompileAs>CompileAsC</CompileAs>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -155,6 +157,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -181,6 +184,7 @@
<AdditionalIncludeDirectories>$(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</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -105,6 +105,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -127,6 +128,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -150,6 +152,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -177,6 +180,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WholeProgramOptimization>false</WholeProgramOptimization>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -102,7 +102,7 @@
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level1</WarningLevel>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x600;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
@ -110,6 +110,7 @@
</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -130,6 +131,7 @@
</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -140,7 +142,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
@ -151,6 +153,7 @@
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -175,6 +178,7 @@
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -111,6 +111,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<ExceptionHandling>Sync</ExceptionHandling>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -134,6 +135,7 @@
<CompileAs>CompileAsC</CompileAs>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -157,6 +159,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -184,6 +187,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -106,6 +106,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -130,6 +131,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -155,6 +157,7 @@
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -184,6 +187,7 @@
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WholeProgramOptimization>false</WholeProgramOptimization>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

Binary file not shown.

View File

@ -98,6 +98,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<SDLCheck>false</SDLCheck>
<ExceptionHandling>false</ExceptionHandling>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -112,6 +113,7 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<SDLCheck>false</SDLCheck>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -124,6 +126,7 @@
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<SDLCheck>false</SDLCheck>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -139,6 +142,7 @@
<Optimization>Disabled</Optimization>
<WholeProgramOptimization>false</WholeProgramOptimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -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;

View File

@ -1,4 +1,6 @@
#pragma once
#include <VersionHelpers.h>
#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 *);

View File

@ -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;
@ -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)
{
if(buf_len < MIN_CTRL_SEQ_LEN)
return 0;
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') {
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)
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) ) {
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;
@ -1171,10 +1281,8 @@ start_with_pty(wchar_t *command)
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, command));
}
@ -1269,14 +1377,13 @@ start_withno_pty(wchar_t *command)
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;
}
@ -1347,7 +1457,6 @@ start_withno_pty(wchar_t *command)
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, 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 */
@ -1414,11 +1528,9 @@ 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'))) {
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));
}
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));
@ -1450,6 +1562,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

View File

@ -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) {

View File

@ -32,6 +32,8 @@
#include "agent.h"
#include "..\misc_internal.h"
#include "..\Debug.h"
#include <wchar.h>
#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)) {

View File

@ -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,49 +95,11 @@ 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);
load_server_config(config_file_name, &cfg);
@ -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);

View File

@ -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;
}

View File

@ -107,8 +107,8 @@ ReadThread(_In_ LPVOID lpParameter)
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;
}
@ -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);
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);

View File

@ -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)
{
@ -115,6 +137,7 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen)
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:
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:
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:
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:
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:
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:
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:
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:
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 */
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 */
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:
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;
}
}

View File

@ -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);
if (t) {
WriteConsoleW(handle, t, (DWORD)wcslen(t), 0, 0);
free(t);
}
ConSaveViewRect();
return;
}

View File

@ -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,18 +556,18 @@ 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) {
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 (GetLastError() != ERROR_INVALID_HANDLE) {
debug3("fcntl - SetHandleInformation failed %d, io:%p",
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;
return 0;
@ -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

View File

@ -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 {

View File

@ -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));