Source snapshot from Powershell/openssh-portable:latestw_all

This commit is contained in:
Manoj Ampalam 2017-01-30 00:14:58 -08:00
parent e85070d50e
commit e404237322
84 changed files with 1416 additions and 1012 deletions

3
.gitignore vendored
View File

@ -283,4 +283,5 @@ __pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/
# tools/
contrib/win32/win32compat/inc/crtheaders.h

View File

@ -1,4 +1,4 @@
version: 0.0.6.0.{build}
version: 0.0.8.0.{build}
image: Visual Studio 2015
branches:
@ -11,33 +11,34 @@ init:
build_script:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
Invoke-AppVeyorBuild
after_build:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Install-OpenSSH
- ps: Write-Verbose "Restart computer ..."
- ps: Restart-Computer -ComputerName localhost -Force
- ps: Restart-Computer -Force
- ps: Start-Sleep -s 5 # Needs to be proceeded with -ps: as it's interpreted by AppVeyor
- ps: Write-Verbose "Restart computer completed"
- ps: Write-Verbose "Restart computer completed!"
before_test:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Install-TestDependencies
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
Install-TestDependencies
Deploy-OpenSSHTests
test_script:
- cmd: |
"%ProgramFiles%\PowerShell\6.0.0.14\powershell.exe" -Command "Import-Module \"%APPVEYOR_BUILD_FOLDER%\contrib\win32\openssh\AppVeyor.psm1\" -WarningAction SilentlyContinue;Run-OpenSSHTests"
"%ProgramFiles%\PowerShell\6.0.0.14\powershell.exe" -Command "Import-Module \"%APPVEYOR_BUILD_FOLDER%\contrib\win32\openssh\AppVeyor.psm1\" -DisableNameChecking;Run-OpenSSHPesterTest"
- ps: |
Check-PesterTestResult
Run-OpenSSHUnitTest
after_test:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Upload-OpenSSHTestResults
on_finish:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Publish-Artifact

View File

@ -108,10 +108,18 @@ ssh_get_authentication_socket(int *fdp)
RegCloseKey(agent_root);
}
h = CreateFileW(SSH_AGENT_PIPE_NAME, GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (h == INVALID_HANDLE_VALUE)
do {
h = CreateFileW(SSH_AGENT_PIPE_NAME, GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (h != INVALID_HANDLE_VALUE || GetLastError() != ERROR_PIPE_BUSY)
break;
Sleep(100);
} while(1);
if (h == INVALID_HANDLE_VALUE) {
debug("ssh_get_authentication_socket - CreateFileW failed error %d", GetLastError());
return SSH_ERR_AGENT_NOT_PRESENT;
}
/*
* ensure that connected server pid matches published pid. this provides service side

View File

@ -56,14 +56,24 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "config", "config.vcxproj", "{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-lsa", "ssh-lsa.vcxproj", "{02FB3D98-6516-42C6-9762-98811A99960F}"
ProjectSection(ProjectDependencies) = postProject
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "posix_compat", "win32iocompat.vcxproj", "{0D02F0F0-013B-4EE3-906D-86517F3822C0}"
ProjectSection(ProjectDependencies) = postProject
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-shellhost", "ssh-shellhost.vcxproj", "{C0AE8A30-E4FA-49CE-A2B5-0C072C77EC64}"
ProjectSection(ProjectDependencies) = postProject
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-agent", "ssh-agent.vcxproj", "{F6644EC5-D6B6-42A1-828C-75E2977470E0}"
ProjectSection(ProjectDependencies) = postProject
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
EndProjectSection
@ -87,6 +97,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest-bitmap", "unittest-bitmap.vcxproj", "{D901596E-76C7-4608-9CFA-2B42A9FD7250}"
ProjectSection(ProjectDependencies) = postProject
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
EndProjectSection
@ -94,6 +105,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest-kex", "unittest-kex.vcxproj", "{8EC56B06-5A9A-4D6D-804D-037FE26FD43E}"
ProjectSection(ProjectDependencies) = postProject
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
EndProjectSection
@ -108,6 +120,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest-win32compat", "unittest-win32compat.vcxproj", "{BF295BA9-4BF8-43F8-8CBF-FAE84815466C}"
ProjectSection(ProjectDependencies) = postProject
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
EndProjectSection
@ -115,6 +128,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest-utf8", "unittest-utf8.vcxproj", "{114CAA59-46C0-4B87-BA86-C1946A68101D}"
ProjectSection(ProjectDependencies) = postProject
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
EndProjectSection
@ -122,6 +136,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest-hostkeys", "unittest-hostkeys.vcxproj", "{890C6129-286F-4CD8-8252-FB8D3B4E6E1B}"
ProjectSection(ProjectDependencies) = postProject
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
EndProjectSection
@ -129,6 +144,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest-sshkey", "unittest-sshkey.vcxproj", "{FC568FF0-60F2-4B2E-AF62-FD392EDBA1B9}"
ProjectSection(ProjectDependencies) = postProject
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
EndProjectSection
@ -137,6 +153,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{17322AAF-8
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A8096E32-E084-4FA0-AE01-A8D909EB2BB4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest-match", "unittest-match.vcxproj", "{484A8CDE-B949-4BDA-B447-74685C8E032F}"
ProjectSection(ProjectDependencies) = postProject
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@ -313,6 +337,14 @@ Global
{FC568FF0-60F2-4B2E-AF62-FD392EDBA1B9}.Release|x64.Build.0 = Release|x64
{FC568FF0-60F2-4B2E-AF62-FD392EDBA1B9}.Release|x86.ActiveCfg = Release|Win32
{FC568FF0-60F2-4B2E-AF62-FD392EDBA1B9}.Release|x86.Build.0 = Release|Win32
{484A8CDE-B949-4BDA-B447-74685C8E032F}.Debug|x64.ActiveCfg = Debug|x64
{484A8CDE-B949-4BDA-B447-74685C8E032F}.Debug|x64.Build.0 = Debug|x64
{484A8CDE-B949-4BDA-B447-74685C8E032F}.Debug|x86.ActiveCfg = Debug|Win32
{484A8CDE-B949-4BDA-B447-74685C8E032F}.Debug|x86.Build.0 = Debug|Win32
{484A8CDE-B949-4BDA-B447-74685C8E032F}.Release|x64.ActiveCfg = Release|x64
{484A8CDE-B949-4BDA-B447-74685C8E032F}.Release|x64.Build.0 = Release|x64
{484A8CDE-B949-4BDA-B447-74685C8E032F}.Release|x86.ActiveCfg = Release|Win32
{484A8CDE-B949-4BDA-B447-74685C8E032F}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -339,5 +371,6 @@ Global
{114CAA59-46C0-4B87-BA86-C1946A68101D} = {A8096E32-E084-4FA0-AE01-A8D909EB2BB4}
{890C6129-286F-4CD8-8252-FB8D3B4E6E1B} = {A8096E32-E084-4FA0-AE01-A8D909EB2BB4}
{FC568FF0-60F2-4B2E-AF62-FD392EDBA1B9} = {A8096E32-E084-4FA0-AE01-A8D909EB2BB4}
{484A8CDE-B949-4BDA-B447-74685C8E032F} = {A8096E32-E084-4FA0-AE01-A8D909EB2BB4}
EndGlobalSection
EndGlobal

View File

@ -1,8 +1,9 @@
$ErrorActionPreference = 'Stop'
Import-Module $PSScriptRoot\build.psm1
Import-Module $PSScriptRoot\build.psm1 -Force -DisableNameChecking
$repoRoot = Get-RepositoryRoot
$script:logFile = join-path $repoRoot.FullName "appveyorlog.log"
$script:logFile = join-path $repoRoot.FullName "appveyor.log"
$script:messageFile = join-path $repoRoot.FullName "BuildMessage.log"
$testfailed = $false
<#
Called by Write-BuildMsg to write to the build log, if it exists.
@ -22,6 +23,28 @@ function Write-Log
}
}
# Sets a build variable
Function Write-BuildMessage
{
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $Message,
$Category,
[string] $Details)
if($env:AppVeyor)
{
Add-AppveyorMessage @PSBoundParameters
}
# write it to the log file, if present.
if (-not ([string]::IsNullOrEmpty($script:messageFile)))
{
Add-Content -Path $script:messageFile -Value "$Category--$Message"
}
}
# Sets a build variable
Function Set-BuildVariable
{
@ -35,13 +58,17 @@ Function Set-BuildVariable
$Value
)
if($env:AppVeyor)
if($env:AppVeyor -and (Get-Command Set-AppveyorBuildVariable -ErrorAction Ignore) -ne $null)
{
Set-AppveyorBuildVariable @PSBoundParameters
}
else
elseif($env:AppVeyor)
{
Set-Item env:/$name -Value $Value
appveyor SetVariable -Name $Name -Value $Value
}
else
{
Set-Item env:$Name -Value $Value
}
}
@ -71,7 +98,6 @@ function Invoke-AppVeyorFull
Invoke-AppVeyorBuild
Install-OpenSSH
Install-TestDependencies
& "$env:ProgramFiles\PowerShell\6.0.0.12\powershell.exe" -Command {Import-Module $($repoRoot.FullName)\contrib\win32\openssh\AppVeyor.psm1;Run-OpenSSHTests -uploadResults}
Run-OpenSSHTests
Publish-Artifact
}
@ -85,9 +111,11 @@ function Invoke-AppVeyorFull
# Implements the AppVeyor 'build_script' step
function Invoke-AppVeyorBuild
{
{
Set-BuildVariable TestPassed True
Start-SSHBuild -Configuration Release -NativeHostArch x64
Start-SSHBuild -Configuration Debug -NativeHostArch x86
Write-BuildMessage -Message "OpenSSH binaries build success!" -Category Information
}
<#
@ -193,6 +221,7 @@ function Download-PSCoreMSI
if ($v)
{
Write-BuildMessage -Message "Failed to download PSCore MSI package from $url" -Category Error
throw "Failed to download PSCore MSI package from $url"
}
else
@ -216,14 +245,37 @@ function Install-TestDependencies
if (-not ($isModuleAvailable))
{
Write-Log -Message "Installing Pester..."
choco install Pester -y --force --limitoutput
choco install Pester -y --force --limitoutput 2>&1 >> $script:logFile
}
if ( -not (Test-Path "$env:ProgramData\chocolatey\lib\sysinternals\tools" ) ) {
Write-Log -Message "sysinternals not present. Installing sysinternals."
choco install sysinternals -y --force --limitoutput
}
choco install sysinternals -y --force --limitoutput 2>&1 >> $script:logFile
}
<#if ( (-not (Test-Path "${env:ProgramFiles(x86)}\Windows Kits\8.1\Debuggers\" )) -and (-not (Test-Path "${env:ProgramFiles(x86)}\Windows Kits\10\Debuggers\" ))) {
Write-Log -Message "debugger not present. Installing windbg."
choco install windbg --force --limitoutput -y 2>&1 >> $script:logFile
}#>
Install-PSCoreFromGithub
$psCorePath = GetLocalPSCorePath
Set-BuildVariable -Name psPath -Value $psCorePath
Write-BuildMessage -Message "All testDependencies installed!" -Category Information
}
<#
.Synopsis
Get the path to the installed powershell score
#>
function GetLocalPSCorePath {
$psPath = Get-ChildItem "$env:ProgramFiles\PowerShell\*\powershell.exe" -Recurse -ErrorAction SilentlyContinue
if($psPath.Count -eq 0)
{
""
}
else
{
$psPath[-1].FullName
}
}
<#
.Synopsis
@ -246,7 +298,7 @@ function Install-OpenSSH
Build-Win32OpenSSHPackage @PSBoundParameters
Push-Location $OpenSSHDir
&( "$OpenSSHDir\install-sshd.ps1")
& ( "$OpenSSHDir\install-sshd.ps1")
.\ssh-keygen.exe -A
Start-Service ssh-agent
&( "$OpenSSHDir\install-sshlsa.ps1")
@ -256,6 +308,7 @@ function Install-OpenSSH
Start-Service sshd
Pop-Location
Write-BuildMessage -Message "OpenSSH installed!" -Category Information
}
<#
@ -337,20 +390,28 @@ function Build-Win32OpenSSHPackage
{
$RealConfiguration = $Configuration
}
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHDir -Include *.exe,*.dll -Exclude *unittest*.* -Force -ErrorAction Stop
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "contrib\win32\openssh"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHDir -Include *.ps1,sshd_config -Exclude AnalyzeCodeDiff.ps1 -Force -ErrorAction Stop
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHDir -Include *.ps1,sshd_config -Exclude AnalyzeCodeDiff.ps1 -Force -ErrorAction Stop
$packageName = "rktools.2003"
$rktoolsPath = "${env:ProgramFiles(x86)}\Windows Resource Kits\Tools\ntrights.exe"
if (-not (Test-Path -Path $rktoolsPath))
{
Write-Log -Message "$packageName not present. Installing $packageName."
choco install $packageName -y --force
choco install $packageName -y --force 2>&1 >> $script:logFile
if (-not (Test-Path -Path $rktoolsPath))
{
choco install $packageName -y --force 2>&1 >> $script:logFile
if (-not (Test-Path -Path $rktoolsPath))
{
Write-BuildMessage "Installation dependencies: failed to download $packageName. try again please." -Category Error
throw "failed to download $packageName"
}
}
}
Copy-Item -Path $rktoolsPath -Destination $OpenSSHDir -Force -ErrorAction Stop
@ -439,7 +500,37 @@ function Deploy-OpenSSHTests
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Include *.ps1,*.psm1 -Force -ErrorAction Stop
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Exclude ssh-agent.exe, sshd.exe -Force -ErrorAction Stop
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Exclude ssh-agent.exe, sshd.exe -Force -ErrorAction Stop
$sshdConfigFile = "$OpenSSHTestDir\sshd_config"
if (-not (Test-Path -Path $sshdConfigFile -PathType Leaf))
{
Write-BuildMessage "Installation dependencies: $OpenSSHTestDir\sshd_config is missing in the folder" -Category Error
throw "$OpenSSHTestDir\sshd_config is missing in the folder"
}
if ($env:DebugMode)
{
$strToReplace = "#LogLevel INFO"
(Get-Content $sshdConfigFile).Replace($strToReplace,"LogLevel Debug3") | Set-Content $sshdConfigFile
}
if(-not ($env:psPath))
{
$psCorePath = GetLocalPSCorePath
Set-BuildVariable -Name psPath -Value $psCorePath
}
$strToReplace = "Subsystem sftp sftp-server.exe"
if($env:psPath)
{
$strNewsubSystem = @"
Subsystem sftp sftp-server.exe
Subsystem powershell $env:psPath
"@
}
(Get-Content $sshdConfigFile).Replace($strToReplace, $strNewsubSystem) | Set-Content $sshdConfigFile
}
@ -491,7 +582,7 @@ function Add-Artifact
(
[ValidateNotNull()]
[System.Collections.ArrayList] $artifacts,
[string] $FileToAdd = "$env:SystemDrive\Win32OpenSSH*.zip"
[string] $FileToAdd
)
$files = Get-ChildItem -Path $FileToAdd -ErrorAction Ignore
@ -499,11 +590,11 @@ function Add-Artifact
{
$files | % {
$null = $artifacts.Add($_.FullName)
}
}
}
else
{
Write-Warning "Skip publishing package artifacts. $FileToAdd does not exist"
Write-Log -Message "Skip publishing package artifacts. $FileToAdd does not exist"
}
}
@ -513,7 +604,7 @@ function Add-Artifact
#>
function Publish-Artifact
{
Write-Output "Publishing project artifacts"
Write-Host -ForegroundColor Yellow "Publishing project artifacts"
[System.Collections.ArrayList] $artifacts = [System.Collections.ArrayList]::new()
$packageFolder = $env:SystemDrive
@ -524,14 +615,17 @@ function Publish-Artifact
Add-Artifact -artifacts $artifacts -FileToAdd "$packageFolder\Win32OpenSSH*.zip"
Add-Artifact -artifacts $artifacts -FileToAdd "$env:SystemDrive\OpenSSH\UnitTestResults.txt"
Add-Artifact -artifacts $artifacts -FileToAdd "$script:logFile"
Add-Artifact -artifacts $artifacts -FileToAdd "$env:SystemDrive\OpenSSH\TestError.txt"
# Get the build.log file for each build configuration
Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName)
Add-Artifact -artifacts $artifacts -FileToAdd "$script:logFile"
Add-Artifact -artifacts $artifacts -FileToAdd "$script:messageFile"
foreach ($artifact in $artifacts)
{
Write-Output "Publishing $artifact as Appveyor artifact"
Write-Log -Message "Publishing $artifact as Appveyor artifact"
# NOTE: attempt to publish subsequent artifacts even if the current one fails
Push-AppveyorArtifact $artifact -ErrorAction "Continue"
}
@ -543,54 +637,82 @@ function Publish-Artifact
#>
function Run-OpenSSHPesterTest
{
param($testRoot, $outputXml)
param($testRoot = "$env:SystemDrive\OpenSSH",
$outputXml = "$env:SystemDrive\OpenSSH\TestResults.xml")
# Discover all CI tests and run them.
Push-Location $testRoot
Write-Log -Message "Running OpenSSH Pester tests..."
$testFolders = Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique
$testFolders = Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique
Invoke-Pester $testFolders -OutputFormat NUnitXml -OutputFile $outputXml -Tag 'CI'
Pop-Location
}
function Check-PesterTestResult
{
param($outputXml = "$env:SystemDrive\OpenSSH\TestResults.xml")
if (-not (Test-Path $outputXml))
{
Write-Warning "$($xml.'test-results'.failures) tests in regress\pesterTests failed"
Write-BuildMessage -Message "Test result file $outputXml not found after tests." -Category Error
Set-BuildVariable TestPassed False
}
$xml = [xml](Get-Content -raw $outputXml)
if ([int]$xml.'test-results'.failures -gt 0)
{
$errorMessage = "$($xml.'test-results'.failures) tests in regress\pesterTests failed. Detail test log is at TestResults.xml."
Write-Warning $errorMessage
Write-BuildMessage -Message $errorMessage -Category Error
Set-BuildVariable TestPassed False
}
# Writing out warning when the $Error.Count is non-zero. Tests Should clean $Error after success.
if ($Error.Count -gt 0)
{
Write-BuildMessage -Message "Tests Should clean $Error after success." -Category Warning
$Error| Out-File "$testInstallFolder\TestError.txt" -Append
}
}
<#
.Synopsis
Run unit tests.
#>
function Run-OpenSSHUnitTest
{
param($testRoot, $unitTestOutputFile)
param($testRoot = "$env:SystemDrive\OpenSSH",
$unitTestOutputFile = "$env:SystemDrive\OpenSSH\UnitTestResults.txt")
# Discover all CI tests and run them.
Push-Location $testRoot
Push-Location $testRoot
Write-Log -Message "Running OpenSSH unit tests..."
if (Test-Path $unitTestOutputFile)
{
Remove-Item -Path $unitTestOutputFile -Force -ErrorAction SilentlyContinue
}
$unitTestFiles = Get-ChildItem -Path "$testRoot\unittest*.exe"
$testFailed = $false
$unitTestFiles = Get-ChildItem -Path "$testRoot\unittest*.exe" -Exclude unittest-kex.exe
$testfailed = $false
if ($unitTestFiles -ne $null)
{
$unitTestFiles | % {
Write-Log -Message "Running OpenSSH unit $($_.FullName)..."
Write-Output "Running OpenSSH unit $($_.FullName)..."
& $_.FullName >> $unitTestOutputFile
$errorCode = $LASTEXITCODE
if ($errorCode -ne 0)
{
$testFailed = $true
Write-Log -Message "$($_.FullName) test failed for OpenSSH.`nExitCode: $error"
$testfailed = $true
$errorMessage = "$($_.FullName) test failed for OpenSSH.`nExitCode: $errorCode. Detail test log is at UnitTestResults.txt."
Write-Warning $errorMessage
Write-BuildMessage -Message $errorMessage -Category Error
Set-BuildVariable TestPassed False
}
}
if($testFailed)
}
if(-not $testfailed)
{
throw "SSH unit tests failed"
Write-BuildMessage -Message "All Unit tests passed!" -Category Information
}
}
Pop-Location
}
@ -602,17 +724,9 @@ function Run-OpenSSHUnitTest
The name of the xml file to write pester results.
The default value is '.\testResults.xml'
.Parameter uploadResults
Uploads the tests results.
.Example
.\RunTests.ps1
Runs the tests and creates the default 'testResults.xml'
.Example
.\RunTests.ps1 -uploadResults
Runs the tests and creates teh default 'testResults.xml' and uploads it to appveyor.
#>
function Run-OpenSSHTests
{
@ -621,39 +735,47 @@ function Run-OpenSSHTests
(
[string] $testResultsFile = "$env:SystemDrive\OpenSSH\TestResults.xml",
[string] $unitTestResultsFile = "$env:SystemDrive\OpenSSH\UnitTestResults.txt",
[string] $testInstallFolder = "$env:SystemDrive\OpenSSH"
[string] $testInstallFolder = "$env:SystemDrive\OpenSSH"
)
Deploy-OpenSSHTests -OpenSSHTestDir $testInstallFolder
Run-OpenSSHUnitTest -testRoot $testInstallFolder -unitTestOutputFile $unitTestResultsFile
# Run all pester tests.
Run-OpenSSHPesterTest -testRoot $testInstallFolder -outputXml $testResultsFile
$xml = [xml](Get-Content -raw $testResultsFile)
if ([int]$xml.'test-results'.failures -gt 0)
{
throw "$($xml.'test-results'.failures) tests in regress\pesterTests failed"
}
# Writing out warning when the $Error.Count is non-zero. Tests Should clean $Error after success.
if ($Error.Count -gt 0)
{
$Error| Out-File "$env:SystemDrive\OpenSSH\TestError.txt" -Append
}
Run-OpenSSHUnitTest -testRoot $testInstallFolder -unitTestOutputFile $unitTestResultsFile
}
function Upload-OpenSSHTestResults
{
[CmdletBinding()]
param
(
[string] $testResultsFile = "$env:SystemDrive\OpenSSH\TestResults.xml"
)
[CmdletBinding()]
param
(
[string] $testResultsFile = "$env:SystemDrive\OpenSSH\TestResults.xml"
)
if ($env:APPVEYOR_JOB_ID)
{
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
}
if ($env:APPVEYOR_JOB_ID)
{
$resultFile = Resolve-Path $testResultsFile -ErrorAction Ignore
if($resultFile)
{
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $resultFile)
Write-BuildMessage -Message "Test results uploaded!" -Category Information
}
}
if ($env:DebugMode)
{
Remove-Item $env:DebugMode
}
if($env:TestPassed -ieq 'True')
{
Write-BuildMessage -Message "The checkin validation success!"
}
else
{
Write-BuildMessage -Message "The checkin validation failed!" -Category Error
throw "The checkin validation failed!"
}
}
Export-ModuleMember -Function Set-BuildVariable, Invoke-AppVeyorBuild, Install-OpenSSH, Install-TestDependencies, GetLocalPSCorePath, Upload-OpenSSHTestResults, Run-OpenSSHTests, Publish-Artifact, Start-SSHBuild, Deploy-OpenSSHTests, Run-OpenSSHUnitTest,Run-OpenSSHPesterTest,Check-PesterTestResult

View File

@ -151,7 +151,7 @@ function Start-SSHBootstrap
else
{
Write-BuildMsg -AsInfo -Message "Chocolatey not present. Installing chocolatey." -Silent:$silent
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) 2>&1 >> $script:BuildLogFile
if (-not ($machinePath.ToLower().Contains($chocolateyPath.ToLower())))
{
@ -207,7 +207,7 @@ function Start-SSHBootstrap
if (-not (Test-Path -Path $nasmPath -PathType Container))
{
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName." -Silent:$silent
choco install $packageName -y --force --limitoutput --execution-timeout 10000
choco install $packageName -y --force --limitoutput --execution-timeout 10000 2>&1 >> $script:BuildLogFile
}
else
{
@ -220,9 +220,9 @@ function Start-SSHBootstrap
if ($null -eq $VSPackageInstalled)
{
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName." -Silent:$silent
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName."
$adminFilePath = "$script:OpenSSHRoot\contrib\win32\openssh\VSWithBuildTools.xml"
choco install $packageName -packageParameters "--AdminFile $adminFilePath" -y --force --limitoutput --execution-timeout 10000
choco install $packageName -packageParameters "--AdminFile $adminFilePath" -y --force --limitoutput --execution-timeout 10000 2>&1 >> $script:BuildLogFile
}
else
{
@ -235,8 +235,8 @@ function Start-SSHBootstrap
if (-not (Test-Path -Path $sdkPath))
{
Write-BuildMsg -AsInfo -Message "Windows 8.1 SDK not present. Installing $packageName." -Silent:$silent
choco install $packageName -y --limitoutput --force
Write-BuildMsg -AsInfo -Message "Windows 8.1 SDK not present. Installing $packageName."
choco install $packageName -y --limitoutput --force 2>&1 >> $script:BuildLogFile
}
else
{
@ -330,7 +330,7 @@ function Start-SSHBuild
$script:BuildLogFile = Get-BuildLogFile -root $repositoryRoot.FullName -Configuration $Configuration -NativeHostArch $NativeHostArch
if (Test-Path -Path $script:BuildLogFile)
{
Remove-Item -Path $script:BuildLogFile
Remove-Item -Path $script:BuildLogFile -force
}
Write-BuildMsg -AsInfo -Message "Starting Open SSH build; Build Log: $($script:BuildLogFile)"
@ -341,10 +341,8 @@ function Start-SSHBuild
Copy-OpenSSLSDK
$msbuildCmd = "msbuild.exe"
$solutionFile = Get-SolutionFile -root $repositoryRoot.FullName
$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/noconlog", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
#$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/m", "/noconlog", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
& $msbuildCmd $cmdMsg
$errorCode = $LASTEXITCODE
@ -353,7 +351,7 @@ function Start-SSHBuild
Write-BuildMsg -AsError -ErrorAction Stop -Message "Build failed for OpenSSH.`nExitCode: $error."
}
Write-BuildMsg -AsInfo -Message "SSH build passed."
Write-BuildMsg -AsInfo -Message "SSH build passed." -Silent:$silent
}
function Get-BuildLogFile

View File

@ -939,7 +939,7 @@
/* #undef HAVE_STRICT_MKSTEMP */
/* Define to 1 if you have the <strings.h> header file. */
/* #undef HAVE_STRINGS_H
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
@ -1332,6 +1332,7 @@
/* libcrypto includes complete ECC support */
#define OPENSSL_HAS_ECC 1
#define OPENSSL_HAS_NISTP521 1
/* libcrypto is missing AES 192 and 256 bit functions */
/* #undef OPENSSL_LOBOTOMISED_AES */
@ -1580,7 +1581,6 @@
#define WIN32_LEAN_AND_MEAN 1
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#define WIN32_FIXME 1
#define WINDOWS 1
/* Define if you must implement a startup_needs function for your platform */

View File

@ -0,0 +1,19 @@
Param($Config_h_vs, $Config_h, $VCIncludePath, $OutCRTHeader)
Copy-Item $Config_h_vs $Config_h -Force
if (Test-Path $OutCRTHeader) {exit}
$headers = ("stdio.h", "string.h", "sys\types.h", "ctype.h", "stdlib.h", "sys\stat.h", "fcntl.h")
$paths = $VCIncludePath.Split(";")
Set-Content -Path $OutCRTHeader -Value "/*`r`n * DO NOT EDIT - AutoGenerated by config.ps1`r`n */`r`n" -Force
foreach ($header in $headers) {
foreach ($path in $paths)
{
if ($path -and (Test-Path (Join-Path $path $header)))
{
$entry = "#define " + $header.ToUpper().Replace(".","_").Replace("\","_") + " `"" + (Join-Path $path $header) + "`""
Add-Content -Path $OutCRTHeader -Value $entry
break
}
}
}

View File

@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="paths.targets" />
<PropertyGroup>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -112,7 +112,7 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PreBuildEvent>
<Command>copy /Y $(SolutionDir)config.h.vs $(OpenSSH-Src-Path)\config.h</Command>
<Command>powershell.exe -Executionpolicy Bypass "$(SolutionDir)config.ps1" -Config_h_vs '$(SolutionDir)config.h.vs' -Config_h '$(OpenSSH-Src-Path)config.h' -VCIncludePath '$(VC_IncludePath)' -OutCRTHeader '$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h'</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Setup config.h in openssh source path for visual studio</Message>
@ -136,7 +136,7 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PreBuildEvent>
<Command>copy /Y $(SolutionDir)config.h.vs $(OpenSSH-Src-Path)\config.h</Command>
<Command>powershell.exe -Executionpolicy Bypass "$(SolutionDir)config.ps1" -Config_h_vs '$(SolutionDir)config.h.vs' -Config_h '$(OpenSSH-Src-Path)config.h' -VCIncludePath '$(VC_IncludePath)' -OutCRTHeader '$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h'</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Setup config.h in openssh source path for visual studio</Message>
@ -164,7 +164,7 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PreBuildEvent>
<Command>copy /Y $(SolutionDir)config.h.vs $(OpenSSH-Src-Path)\config.h</Command>
<Command>powershell.exe -Executionpolicy Bypass "$(SolutionDir)config.ps1" -Config_h_vs '$(SolutionDir)config.h.vs' -Config_h '$(OpenSSH-Src-Path)config.h' -VCIncludePath '$(VC_IncludePath)' -OutCRTHeader '$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h'</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Setup config.h in openssh source path for visual studio</Message>
@ -192,7 +192,7 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PreBuildEvent>
<Command>copy /Y $(SolutionDir)config.h.vs $(OpenSSH-Src-Path)\config.h</Command>
<Command>powershell.exe -Executionpolicy Bypass "$(SolutionDir)config.ps1" -Config_h_vs '$(SolutionDir)config.h.vs' -Config_h '$(OpenSSH-Src-Path)config.h' -VCIncludePath '$(VC_IncludePath)' -OutCRTHeader '$(OpenSSH-Src-Path)contrib\win32\win32compat\inc\crtheaders.h'</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Setup config.h in openssh source path for visual studio</Message>

View File

@ -156,6 +156,8 @@
<AdditionalDependencies>posix_compat.lib;bcrypt.lib;Netapi32.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -179,6 +181,8 @@
<AdditionalDependencies>posix_compat.lib;bcrypt.lib;Netapi32.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -288,7 +288,7 @@
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\ttymodes_windows.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\digest-openssl.c">
<ClCompile Include="$(OpenSSH-Src-Path)digest-openssl.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>

View File

@ -161,6 +161,8 @@
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -184,6 +186,8 @@
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -165,6 +165,8 @@
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -188,6 +190,8 @@
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -24,6 +24,9 @@
<ClCompile Include="$(OpenSSH-Src-Path)sftp-server.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\wmain_common.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc">

View File

@ -167,6 +167,8 @@
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -190,6 +192,8 @@
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -166,6 +166,8 @@
<AdditionalDependencies>posix_compat.lib;Netapi32.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -189,6 +191,8 @@
<AdditionalDependencies>posix_compat.lib;Netapi32.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -163,6 +163,8 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Netapi32.lib;Crypt32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
@ -188,6 +190,8 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Netapi32.lib;Crypt32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>

View File

@ -158,6 +158,8 @@
<AdditionalDependencies>advapi32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ModuleDefinitionFile>ssh-lsa.def</ModuleDefinitionFile>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -181,6 +183,8 @@
<AdditionalDependencies>advapi32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ModuleDefinitionFile>ssh-lsa.def</ModuleDefinitionFile>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -158,6 +158,8 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>kernel32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -180,6 +182,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>kernel32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -166,6 +166,8 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
@ -192,6 +194,8 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>

View File

@ -165,6 +165,8 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
@ -193,6 +195,8 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>

View File

@ -112,7 +112,7 @@ AuthorizedKeysFile .ssh/authorized_keys
#Banner none
# override default of no subsystems
Subsystem sftp C:/Program Files/OpenSSH/sftp-server.exe
Subsystem sftp sftp-server.exe
# Example of overriding settings on a per-user basis
#Match User anoncvs

View File

@ -0,0 +1,214 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="paths.targets" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{484A8CDE-B949-4BDA-B447-74685C8E032F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Win32OpenSSH</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>unittest-match</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-match</TargetName>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-match</TargetName>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-match</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-match</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level1</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x600;WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);$(OpenSSL-Win32-Debug-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>
<CompileAs>CompileAsC</CompileAs>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<ExceptionHandling>Sync</ExceptionHandling>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level1</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x600;WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);$(OpenSSL-x64-Debug-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>
<CompileAs>CompileAsC</CompileAs>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_WIN32_WINNT=0x600;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);$(OpenSSL-Win32-Release-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>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_WIN32_WINNT=0x600;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);$(OpenSSL-x64-Release-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>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Netapi32.lib;posix_compat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link>
<Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\match\tests.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\test_helper\test_helper.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\wmain_common.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

Binary file not shown.

View File

@ -156,14 +156,12 @@
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\no-ops.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\win32_zlib.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\ansiprsr.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\conio.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\console.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tncon.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tnnet.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\defs.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\fcntl.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\signal.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\select.h" />
@ -172,7 +170,6 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\time.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\wait.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\unistd.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\w32posix.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\poll.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\statvfs.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dlfcn.h" />
@ -199,6 +196,12 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dirent.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\pwd.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\misc_internal.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\stdio.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\string.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\strings.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\types.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\ctype.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\stdlib.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -14,11 +14,10 @@
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\win32_dirent.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\no-ops.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\win32_zlib.c" />
<ClCompile Include="..\win32compat\ansiprsr.c" />
<ClCompile Include="..\win32compat\conio.c" />
<ClCompile Include="..\win32compat\console.c" />
<ClCompile Include="..\win32compat\tncon.c" />
<ClCompile Include="..\win32compat\tnnet.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\ansiprsr.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\console.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tncon.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tnnet.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" />
@ -34,9 +33,6 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\time.h">
<Filter>inc\sys</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\defs.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\fcntl.h">
<Filter>inc</Filter>
</ClInclude>
@ -46,9 +42,6 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\unistd.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\w32posix.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\poll.h">
<Filter>inc</Filter>
</ClInclude>
@ -58,8 +51,6 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\statvfs.h">
<Filter>inc\sys</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dlfcn.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\syslog.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_internal.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\param.h">
<Filter>inc\sys</Filter>
@ -112,12 +103,40 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\termios.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dirent.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\libgen.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\pwd.h" />
<ClInclude Include="..\win32compat\misc_internal.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\misc_internal.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\stdio.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\string.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\pwd.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dirent.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dlfcn.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\types.h">
<Filter>inc\sys</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\strings.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\syslog.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\stdlib.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\ctype.h">
<Filter>inc</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="inc">

View File

@ -56,6 +56,8 @@ extern int ScreenY;
extern int ScrollTop;
extern int ScrollBottom;
extern BOOL bAnsiParsing;
// end of imports from outside module
bool gbVTAppMode = false;
@ -67,7 +69,7 @@ static int AutoWrap = 1;
BOOL bAtEOLN = FALSE;
static int term_mode;
static int term_mode = TERM_ANSI;
// ParseANSI globals - these need to be here, because sometimes blocks are sent
// in mid ANSI sequence
@ -176,14 +178,10 @@ unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd
unsigned char * pszCurrent = pszBuffer+1;
unsigned char * pszNewCurrent = pszCurrent;
if (term_mode == TERM_ANSI)
if (term_mode == TERM_ANSI && bAnsiParsing)
{
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
}
else if (term_mode == TERM_VT52)
{
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd, respbuf, resplen);
}
if (pszCurrent == pszNewCurrent) // Pointer didn't move inside Parse function
{
@ -294,10 +292,6 @@ unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd
{
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
}
else if (term_mode == TERM_VT52)
{
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd, respbuf, resplen);
}
}
if (pszNewCurrent > pszCurrent)
pszBuffer = pszNewCurrent;
@ -427,11 +421,6 @@ void ConSetExtendedMode(int iFunction, BOOL bEnable)
break;
}
if ((iFunction == 2) && (bEnable))
{
term_mode = TERM_VT52;
}
}
#define MODE_EXT 0x00000001
@ -893,108 +882,3 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
else
return pszBuffer;
}
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen)
{
unsigned char * pszCurrent = pszBuffer;
int iLine;
int iColumn;
switch ((unsigned char) *pszCurrent)
{
case 'A': // Cursor Up
ConMoveCursorPosition(0, -1);
pszCurrent++;
bAtEOLN = FALSE;
break;
case 'B': // Cursor Down
ConMoveCursorPosition(0, 1);
pszCurrent++;
bAtEOLN = FALSE;
break;
case 'C': // Cursor Right
ConMoveCursorPosition(1, 0);
pszCurrent++;
break;
case 'D': // Cursor Left
ConMoveCursorPosition(-1, 0);
pszCurrent++;
bAtEOLN = FALSE;
break;
case 'F': // Special Graphics Character Set
case 'G': // ASCII Character Set
pszCurrent++;
break;
case 'H': // Cursor Home
ConSetCursorPosition(1, 1);
pszCurrent++;
bAtEOLN = FALSE;
break;
case 'I': // Reverse Line Feed
pszCurrent++;
break;
case 'J': // Erase to End of Screen
ConClearEOScreen();
pszCurrent++;
break;
case 'K': // Erase to End of Line
ConClearEOLine();
pszCurrent++;
break;
case 'Y': // Direct Cursor Addressing
pszCurrent = GetNextChar(pszCurrent, pszBufferEnd);
if (pszCurrent != NULL)
{
iLine = *pszCurrent - 31;
pszCurrent = GetNextChar(pszCurrent, pszBufferEnd);
if (pszCurrent != NULL)
{
iColumn = *pszCurrent - 31;
ConSetCursorPosition(iLine,iColumn);
pszCurrent++;
}
else
pszCurrent = pszBuffer;
}
else
pszCurrent = pszBuffer;
break;
case 'Z': // Identify
*respbuf = VT52_TERMINAL_ID;
if (resplen != NULL)
{
*resplen = 3;
}
pszCurrent++;
break;
case '=': // Enter Alt Keypad mode
case '>': // Exit Alt Keypad mode
case '1': // Graphics processor on
case '2': // Graphics processor off
pszCurrent++;
break;
case '<': // Enter ANSI mode
term_mode = TERM_ANSI;
pszCurrent++;
break;
default:
pszCurrent++;
break;
}
return pszCurrent;
}

View File

@ -37,12 +37,10 @@
#define __ANSIPRSR_H
#define TERM_ANSI 0
#define TERM_VT52 1
unsigned char * ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char **respbuf, size_t *resplen);
unsigned char * GetNextChar(unsigned char * pszBuffer, unsigned char *pszBufferEnd);
unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen);
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen);
#define true TRUE
#define false FALSE

View File

@ -1,183 +0,0 @@
/*
* Author: Microsoft Corp.
*
* Copyright (c) 2015 Microsoft Corp.
* All rights reserved
*
* Microsoft openssh win32 port
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* conio.c
*
* Inserts data into Windows Console Input. Needed WriteToConsole() API implemented.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include "console.h"
#include <conio.h>
COORD lastCursorLoc = { 0, 0 };
BYTE KeyboardState[256];
INPUT_RECORD srec;
DWORD dwGlobalConsoleMode ;
int WriteToConsole(HANDLE fd, unsigned char *buf, size_t len, size_t *dwWritten, void *flag)
{
static KEY_EVENT_RECORD *pkey;
static KEY_EVENT_RECORD *pkey2;
static INPUT_RECORD irec[2];
static BOOL bInitKeyboard = TRUE;
size_t ctr;
int rc;
DWORD dwRecords;
DWORD vkey;
BOOL bNeedToWait = TRUE;
CONSOLE_SCREEN_BUFFER_INFO csbi;
int scr_width = 80; /* screen horizontal width, e.g. 80 */
int scr_height = 25; /* screen vertical length, e.g. 25 */
char tmpbuf[2];
int local_echo = 0;
/*
* Need to set pkey and pkey2 which we use below. Initialize the keyboard state table.
*/
if (bInitKeyboard)
{
GetKeyboardState(KeyboardState);
bInitKeyboard = FALSE;
srec.EventType = KEY_EVENT;
srec.Event.KeyEvent.bKeyDown = TRUE;
srec.Event.KeyEvent.wRepeatCount = 1;
srec.Event.KeyEvent.wVirtualKeyCode = 0x10;
srec.Event.KeyEvent.wVirtualScanCode = 0x2a;
srec.Event.KeyEvent.uChar.AsciiChar = 0;
srec.Event.KeyEvent.uChar.UnicodeChar = 0;
srec.Event.KeyEvent.dwControlKeyState = 0x10;
irec[0].EventType = KEY_EVENT; /* init key down message */
pkey = &(irec[0].Event.KeyEvent);
pkey->wRepeatCount = 1;
pkey->bKeyDown = TRUE;
irec[1].EventType = KEY_EVENT; /* init key up message */
pkey2 = &(irec[1].Event.KeyEvent);
pkey2->wRepeatCount = 1;
pkey2->bKeyDown = FALSE;
}
// Stream mode processing
if (local_echo)
{
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
}
GetConsoleMode(fd, &dwGlobalConsoleMode);
ctr = 0;
while (ctr < len)
{
if (local_echo)
{
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
lastCursorLoc.Y = csbi.dwCursorPosition.Y;
lastCursorLoc.X = csbi.dwCursorPosition.X;
}
{
pkey->dwControlKeyState = 0x00000000;
pkey->uChar.AsciiChar = buf[ctr]; /* next char in ascii */
mbtowc(&(pkey->uChar.UnicodeChar), (const char *)&(buf[ctr]), 1);
vkey = VkKeyScan(pkey->uChar.AsciiChar);
if ((BYTE)(vkey >> 8) != 0xFF) // high order word
{
if (vkey & 0x0100 || (KeyboardState[VK_LSHIFT] & 0x80)) /* high word gives shift, ctrl, alt status */
pkey->dwControlKeyState |= SHIFT_PRESSED; /* shift key presssed*/
if (vkey & 0x0200 || (KeyboardState[VK_LCONTROL] & 0x80))
pkey->dwControlKeyState |= LEFT_CTRL_PRESSED; /* any ctrl really*/
if ((vkey & 0x0400) || (KeyboardState[VK_LMENU] & 0x80))
pkey->dwControlKeyState |= LEFT_ALT_PRESSED; /* any ALT really*/
}
if ((BYTE)vkey != 0xFF) // low order word
{
pkey->wVirtualKeyCode = (BYTE)vkey;
pkey->wVirtualScanCode = MapVirtualKey(pkey->wVirtualKeyCode, 0);
if (pkey->uChar.UnicodeChar == 0x1b) // stream mode fix for Admark ESC sequences
pkey->wVirtualKeyCode = 0x00db;
}
/* we need to mimic key up and key down */
if (pkey->dwControlKeyState & 0x0100)
{
srec.Event.KeyEvent.bKeyDown = TRUE;
srec.Event.KeyEvent.dwControlKeyState = 0x10;
WriteConsoleInput(fd, &srec, 1, &dwRecords); /* write shift down */
tmpbuf[0] = irec[0].Event.KeyEvent.uChar.AsciiChar;
tmpbuf[1] = '\0';
}
pkey->bKeyDown = TRUE; /*since pkey is mucked by others we do it again*/
/* dup these into key up message structure from key down message */
pkey2->wVirtualKeyCode = pkey->wVirtualKeyCode;
pkey2->wVirtualScanCode = pkey->wVirtualScanCode;
pkey2->uChar.AsciiChar = pkey->uChar.AsciiChar;
pkey2->uChar.UnicodeChar = pkey->uChar.UnicodeChar;
pkey2->dwControlKeyState = pkey->dwControlKeyState;
WriteConsoleInput(fd, irec, 2, &dwRecords); /* key down,up msgs */
tmpbuf[0] = irec[0].Event.KeyEvent.uChar.AsciiChar;
tmpbuf[1] = '\0';
if (pkey->dwControlKeyState & 0x0100)
{
srec.Event.KeyEvent.bKeyDown = FALSE;
srec.Event.KeyEvent.dwControlKeyState = 0x0;
WriteConsoleInput(fd, &srec, 1, &dwRecords); /* write shift up */
}
//if ((local_echo))
//{
// bNeedToWait = EchoInputCharacter(buf[ctr], &csbi.dwCursorPosition, dwGlobalConsoleMode);
//}
}
ctr++;
Sleep(0);
}
*dwWritten = len;
//netflush();
return 0;
}

View File

@ -57,6 +57,8 @@ int ScrollBottom;
int LastCursorX;
int LastCursorY;
BOOL bAnsiParsing = FALSE;
char *pSavedScreen = NULL;
static COORD ZeroCoord = {0,0};
COORD SavedScreenSize = {0,0};
@ -72,6 +74,7 @@ typedef struct _SCREEN_RECORD{
}SCREEN_RECORD,*PSCREEN_RECORD;
PSCREEN_RECORD pSavedScreenRec = NULL;
int in_raw_mode = 0;
/* ************************************************************ */
/* Function: ConInit */
@ -82,6 +85,7 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
OSVERSIONINFO os;
DWORD dwAttributes = 0;
DWORD dwRet = 0;
BOOL bRet = FALSE;
CONSOLE_SCREEN_BUFFER_INFO csbi;
static bool bFirstConInit = true;
@ -91,13 +95,13 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
hOutputConsole = GetStdHandle(OutputHandle);
if (hOutputConsole == INVALID_HANDLE_VALUE) {
dwRet = GetLastError();
printf("GetStdHandle failed with %d\n", dwRet);
printf("GetStdHandle on OutputHandle failed with %d\n", dwRet);
return dwRet;
}
if (!GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwSavedAttributes)) {
dwRet = GetLastError();
printf("GetConsoleMode failed with %d\n", GetLastError());
printf("GetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet);
return dwRet;
}
@ -106,12 +110,23 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
dwAttributes |= ENABLE_WINDOW_INPUT;
char *term = getenv("TERM");
if (!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes)) { // Windows NT
dwRet = GetLastError();
printf("SetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet);
return dwRet;
}
if (term != NULL && (_stricmp(term, "ansi") == 0 || _stricmp(term, "passthru") == 0))
dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if (!GetConsoleMode(hOutputConsole, &dwAttributes)) {
dwRet = GetLastError();
printf("GetConsoleMode on hOutputConsole failed with %d\n", dwRet);
return dwRet;
}
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes); // Windows NT
dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if (!SetConsoleMode(hOutputConsole, dwAttributes)) { // Windows NT
bAnsiParsing = TRUE;
}
ConSetScreenX();
ConSetScreenY();
@ -121,6 +136,7 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
if (GetConsoleScreenBufferInfo(hOutputConsole, &csbi))
SavedViewRect = csbi.srWindow;
in_raw_mode = 1;
return 0;
}
@ -133,6 +149,7 @@ int ConUnInit( void )
{
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
in_raw_mode = 0;
if ( hOutputConsole == NULL )
return 0;

View File

@ -33,7 +33,6 @@
#include <sys/types.h>
#include <io.h>
#include "w32fd.h"
#include "inc/defs.h"
#include <errno.h>
#include <stddef.h>
#include "inc\utf.h"
@ -205,9 +204,7 @@ createFile_flags_setup(int flags, int mode, struct createFile_flags* cf_flags) {
switch (rwflags) {
case O_RDONLY:
cf_flags->dwDesiredAccess = GENERIC_READ;
/*todo: need to review to make sure all flags are correct*/
if (flags & O_NONBLOCK)
cf_flags->dwShareMode = FILE_SHARE_READ;
cf_flags->dwShareMode = FILE_SHARE_READ;
break;
case O_WRONLY:
cf_flags->dwDesiredAccess = GENERIC_WRITE;

View File

@ -0,0 +1,5 @@
#include "crtheaders.h"
#include CTYPE_H
#define isascii __isascii

View File

@ -1,97 +0,0 @@
/*
* Author: Manoj Ampalam <manoj.ampalam@microsoft.com>
*
* Redefined and missing POSIX macros
*/
#pragma once
#include <memory.h>
/* total fds that can be allotted */
#define MAX_FDS 256 /* a 2^n number */
#undef FD_ZERO
#define FD_ZERO(set) (memset( (set), 0, sizeof(w32_fd_set)))
#undef FD_SET
#define FD_SET(fd,set) ( (set)->bitmap[(fd) >> 3] |= (0x80 >> ((fd) % 8)))
#undef FD_ISSET
#define FD_ISSET(fd, set) (( (set)->bitmap[(fd) >> 3] & (0x80 >> ((fd) % 8)))?1:0)
#undef FD_CLR
#define FD_CLR(fd, set) ((set)->bitmap[(fd) >> 3] &= (~(0x80 >> ((fd) % 8))))
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
/*fcntl commands*/
#define F_GETFL 0x1
#define F_SETFL 0x2
#define F_GETFD 0x4
#define F_SETFD 0x8
/*fd flags*/
#define FD_CLOEXEC 0x1
/* signal related defs*/
/* supported signal types */
#define W32_SIGINT 0
#define W32_SIGSEGV 1
#define W32_SIGPIPE 2
#define W32_SIGCHLD 3
#define W32_SIGALRM 4
#define W32_SIGTSTP 5
#define W32_SIGHUP 6
#define W32_SIGQUIT 7
#define W32_SIGTERM 8
#define W32_SIGTTIN 9
#define W32_SIGTTOU 10
#define W32_SIGWINCH 11
#define W32_SIGMAX 12
/* these signals are not supposed to be raised on Windows*/
#define W32_SIGSTOP 13
#define W32_SIGABRT 14
#define W32_SIGFPE 15
#define W32_SIGILL 16
#define W32_SIGKILL 17
#define W32_SIGUSR1 18
#define W32_SIGUSR2 19
/* singprocmask "how" codes*/
#define SIG_BLOCK 0
#define SIG_UNBLOCK 1
#define SIG_SETMASK 2
typedef void(*sighandler_t)(int);
typedef int sigset_t;
#define sigemptyset(set) (memset( (set), 0, sizeof(sigset_t)))
#define sigaddset(set, sig) ( (*(set)) |= (0x80000000 >> (sig)))
#define sigismember(set, sig) ( (*(set) & (0x80000000 >> (sig)))?1:0 )
#define sigdelset(set, sig) ( (*(set)) &= (~( 0x80000000 >> (sig)) ) )
/* signal action codes*/
#define W32_SIG_ERR ((sighandler_t)-1)
#define W32_SIG_DFL ((sighandler_t)0)
#define W32_SIG_IGN ((sighandler_t)1)
typedef unsigned short _mode_t;
typedef _mode_t mode_t;
typedef int ssize_t;
/* TODO - investigate if it makes sense to make pid_t a DWORD_PTR.
* Double check usage of pid_t as int */
typedef int pid_t;
/* wait pid options */
#define WNOHANG 1
/*ioctl macros and structs*/
#define TIOCGWINSZ 1
struct winsize {
unsigned short ws_row; /* rows, in characters */
unsigned short ws_col; /* columns, in character */
unsigned short ws_xpixel; /* horizontal size, pixels */
unsigned short ws_ypixel; /* vertical size, pixels */
};

View File

@ -1,23 +1,40 @@
#include "crtheaders.h"
#include FCNTL_H
/*fcntl commands*/
#define F_GETFL 0x1
#define F_SETFL 0x2
#define F_GETFD 0x4
#define F_SETFD 0x8
/*fd flags*/
#define FD_CLOEXEC 0x1
#define F_OK 0
#pragma once
int w32_fcntl(int fd, int cmd, ... /* arg */);
#define fcntl(a,b,...) w32_fcntl((a), (b), __VA_ARGS__)
#define open w32_open
int w32_open(const char *pathname, int flags, ...);
void* w32_fd_to_handle(int fd);
int w32_allocate_fd_for_handle(void* h, int is_sock);
#define O_RDONLY 0x0000 // open for reading only
#define O_WRONLY 0x0001 // open for writing only
#define O_RDWR 0x0002 // open for reading and writing
#define O_ACCMODE 0x0003
#define O_APPEND 0x0008 // writes done at eof
#define O_CREAT 0x0100 // create and open file
#define O_TRUNC 0x0200 // open and truncate
#define O_EXCL 0x0400 // open only if file doesn't already exist
#define O_TEXT 0x4000 /* file mode is text (translated) */
#define O_BINARY 0x8000 /* file mode is binary (untranslated) */
#define O_WTEXT 0x10000 /* file mode is UTF16 (translated) */
#define O_U16TEXT 0x20000 /* file mode is UTF16 no BOM (translated) */
#define O_U8TEXT 0x40000 /* file mode is UTF8 no BOM (translated) */
#define O_NOCTTY 0x80000 /* TODO - implement this if it makes sense on Windows*/
#define F_OK 0
#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
#define O_RDWR _O_RDWR
#define O_APPEND _O_APPEND
#define O_CREAT _O_CREAT
#define O_TRUNC _O_TRUNC
#define O_EXCL _O_EXCL
#define O_TEXT _O_TEXT
#define O_BINARY _O_BINARY
#define O_RAW _O_BINARY
#define O_TEMPORARY _O_TEMPORARY
#define O_NOINHERIT _O_NOINHERIT
#define O_SEQUENTIAL _O_SEQUENTIAL
#define O_RANDOM _O_RANDOM
#define O_U16TEXT _O_U16TEXT

View File

@ -1,6 +1,7 @@
#pragma once
#include "w32posix.h"
#include "sys\types.h"
#include "sys\socket.h"
/* created to #def out decarations in open-bsd.h (that are defined in winsock2.h) */

View File

@ -10,7 +10,7 @@
#ifndef COMPAT_PWD_H
#define COMPAT_PWD_H 1
#include "sys\param.h"
#include "sys\types.h"
struct passwd {
char *pw_name; /* user's login name */

View File

@ -6,13 +6,62 @@
#ifndef COMPAT_SIGNAL_H
#define COMPAT_SIGNAL_H 1
#include "w32posix.h"
/* signal related defs*/
/* supported signal types */
#define W32_SIGINT 0
#define W32_SIGSEGV 1
#define W32_SIGPIPE 2
#define W32_SIGCHLD 3
#define W32_SIGALRM 4
#define W32_SIGTSTP 5
#define W32_SIGHUP 6
#define W32_SIGQUIT 7
#define W32_SIGTERM 8
#define W32_SIGTTIN 9
#define W32_SIGTTOU 10
#define W32_SIGWINCH 11
#define W32_SIGMAX 12
/* these signals are not supposed to be raised on Windows*/
#define W32_SIGSTOP 13
#define W32_SIGABRT 14
#define W32_SIGFPE 15
#define W32_SIGILL 16
#define W32_SIGKILL 17
#define W32_SIGUSR1 18
#define W32_SIGUSR2 19
/* singprocmask "how" codes*/
#define SIG_BLOCK 0
#define SIG_UNBLOCK 1
#define SIG_SETMASK 2
typedef void(*sighandler_t)(int);
typedef int sigset_t;
#define sigemptyset(set) (memset( (set), 0, sizeof(sigset_t)))
#define sigaddset(set, sig) ( (*(set)) |= (0x80000000 >> (sig)))
#define sigismember(set, sig) ( (*(set) & (0x80000000 >> (sig)))?1:0 )
#define sigdelset(set, sig) ( (*(set)) &= (~( 0x80000000 >> (sig)) ) )
/* signal action codes*/
#define W32_SIG_ERR ((sighandler_t)-1)
#define W32_SIG_DFL ((sighandler_t)0)
#define W32_SIG_IGN ((sighandler_t)1)
sighandler_t w32_signal(int signum, sighandler_t handler);
#define signal(a,b) w32_signal((a), (b))
#define mysignal(a,b) w32_signal((a), (b))
int w32_raise(int sig);
#define raise(a) w32_raise(a)
int w32_kill(int pid, int sig);
#define kill(a,b) w32_kill((a), (b))
#define ftruncate(a, b) w32_ftruncate((a), (b))
int w32_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
#define sigprocmask(a,b,c) w32_sigprocmask((a), (b), (c))
#define SIGINT W32_SIGINT

View File

@ -0,0 +1,17 @@
#include "crtheaders.h"
#include STDIO_H
/* stdio.h overrides */
FILE* w32_fopen_utf8(const char *, const char *);
#define fopen w32_fopen_utf8
/* stdio.h additional definitions */
#define popen _popen
#define pclose _pclose
FILE* w32_fdopen(int fd, const char *mode);
#define fdopen(a,b) w32_fdopen((a), (b))
int w32_rename(const char *old_name, const char *new_name);
#define rename w32_rename

View File

@ -0,0 +1,4 @@
#include "crtheaders.h"
#include STDLIB_H
#define environ _environ

View File

@ -0,0 +1,10 @@
#include "crtheaders.h"
#include STRING_H
#include "utf.h"
/* string.h overrides */
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
char *w32_strerror(int);
#define strerror w32_strerror
#define strdup _strdup

View File

@ -0,0 +1,6 @@
#pragma once
#define bzero(p,l) memset((void *)(p),0,(size_t)(l))
void
explicit_bzero(void *b, size_t len);

View File

@ -1,8 +1,17 @@
#ifndef COMPAT_IOCTL_H
#define COMPAT_IOCTL_H 1
#include "..\w32posix.h"
/*ioctl macros and structs*/
#define TIOCGWINSZ 1
struct winsize {
unsigned short ws_row; /* rows, in characters */
unsigned short ws_col; /* columns, in character */
unsigned short ws_xpixel; /* horizontal size, pixels */
unsigned short ws_ypixel; /* vertical size, pixels */
};
int w32_ioctl(int d, int request, ...);
#define ioctl w32_ioctl
#endif

View File

@ -1,10 +1 @@
#ifndef COMPAT_PARAM_H
#define COMPAT_PARAM_H 1
typedef unsigned int uid_t;
typedef unsigned int gid_t;
typedef long long off_t;
typedef unsigned int dev_t;
#endif
#pragma once

View File

@ -5,9 +5,30 @@
*/
#pragma once
#include "..\w32posix.h"
/* total fds that can be allotted */
#define MAX_FDS 256 /* a 2^n number */
typedef struct w32_fd_set_ {
unsigned char bitmap[MAX_FDS >> 3];
}w32_fd_set;
#define fd_set w32_fd_set
#undef FD_ZERO
#define FD_ZERO(set) (memset( (set), 0, sizeof(w32_fd_set)))
#undef FD_SET
#define FD_SET(fd,set) ( (set)->bitmap[(fd) >> 3] |= (0x80 >> ((fd) % 8)))
#undef FD_ISSET
#define FD_ISSET(fd, set) (( (set)->bitmap[(fd) >> 3] & (0x80 >> ((fd) % 8)))?1:0)
#undef FD_CLR
#define FD_CLR(fd, set) ((set)->bitmap[(fd) >> 3] &= (~(0x80 >> ((fd) % 8))))
#undef FD_SETSIZE
#define FD_SETSIZE MAX_FDS
int w32_select(int fds, w32_fd_set * , w32_fd_set * , w32_fd_set * ,
const struct timeval *);
#define select(a,b,c,d,e) w32_select((a), (b), (c), (d), (e))

View File

@ -3,22 +3,73 @@
*
* POSIX header and needed function definitions
*/
#pragma once
#include <WinSock2.h>
#include <WS2tcpip.h>
#include "..\w32posix.h"
/* Shutdown constants */
#define SHUT_WR SD_SEND
#define SHUT_RD SD_RECEIVE
#define SHUT_RDWR SD_BOTH
/* Other constants */
#define IN_LOOPBACKNET 127 /* 127.* is the loopback network */
#define MAXHOSTNAMELEN 64
#define EPFNOSUPPORT WSAEPFNOSUPPORT
/*network i/o*/
int w32_socket(int domain, int type, int protocol);
#define socket(a,b,c) w32_socket((a), (b), (c))
int w32_accept(int fd, struct sockaddr* addr, int* addrlen);
#define accept(a,b,c) w32_accept((a), (b), (c))
int w32_setsockopt(int fd, int level, int optname, const void* optval, int optlen);
#define setsockopt(a,b,c,d,e) w32_setsockopt((a), (b), (c), (d), (e))
int w32_getsockopt(int fd, int level, int optname, void* optval, int* optlen);
#define getsockopt(a,b,c,d,e) w32_getsockopt((a), (b), (c), (d), (e))
int w32_getsockname(int fd, struct sockaddr* name, int* namelen);
#define getsockname(a,b,c) w32_getsockname((a), (b), (c))
int w32_getpeername(int fd, struct sockaddr* name, int* namelen);
#define getpeername(a,b,c) w32_getpeername((a), (b), (c))
int w32_listen(int fd, int backlog);
#define listen(a,b) w32_listen((a), (b))
int w32_bind(int fd, const struct sockaddr *name, int namelen);
#define bind(a,b,c) w32_bind((a), (b), (c))
int w32_connect(int fd, const struct sockaddr* name, int namelen);
#define connect(a,b,c) w32_connect((a), (b), (c))
int w32_recv(int fd, void *buf, size_t len, int flags);
#define recv(a,b,c,d) w32_recv((a), (b), (c), (d))
int w32_send(int fd, const void *buf, size_t len, int flags);
#define send(a,b,c,d) w32_send((a), (b), (c), (d))
int w32_shutdown(int fd, int how);
#define shutdown(a,b) w32_shutdown((a), (b))
int w32_socketpair(int domain, int type, int protocol, int sv[2]);
#define socketpair(a,b,c,d) w32_socketpair((a), (b), (c), (d))
void w32_freeaddrinfo(struct addrinfo *);
#define freeaddrinfo w32_freeaddrinfo
int w32_getaddrinfo(const char *, const char *,
const struct addrinfo *, struct addrinfo **);
#define getaddrinfo w32_getaddrinfo
struct w32_pollfd {
int fd;
short events;
short revents;
};
#define pollfd w32_pollfd

View File

@ -1,28 +1,11 @@
/*
* Author: Manoj Ampalam <manoj.ampalam@microsoft.com>
*
* private stat.h (all code relying on POSIX wrapper should include this version
* instead of the one in Windows SDK.
*/
#pragma once
#include "..\fcntl.h"
#include "param.h"
#include "..\crtheaders.h"
#include "types.h"
#include SYS_STAT_H
/* flags COPIED FROM STAT.H
*/
#define _S_IFMT 0xF000 // File type mask
#define _S_IFDIR 0x4000 // Directory
#define _S_IFCHR 0x2000 // Character special
#define _S_IFIFO 0x1000 // Pipe
#define _S_IFREG 0x8000 // Regular
#define _S_IREAD 0x0100 // Read permission, owner
#define _S_IWRITE 0x0080 // Write permission, owner
#define _S_IEXEC 0x0040 // Execute/search permission, owner
#define _S_IFLNK 0xA000 // symbolic link
#define _S_IFSOCK 0xC000 // socket
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#define S_IFMT _S_IFMT
#define S_IFDIR _S_IFDIR
#define S_IFCHR _S_IFCHR
@ -33,13 +16,20 @@
#define S_IFLNK _S_IFLNK
#define S_IFSOCK _S_IFSOCK
/* TODO - is this the right place for these defs ?*/
# define S_ISUID 0x800
# define S_ISGID 0x400
int w32_fstat(int fd, struct w32_stat *buf);
#define fstat(a,b) w32_fstat((a), (b))
int w32_stat(const char *path, struct w32_stat *buf);
#define stat w32_stat
#define lstat w32_stat
int w32_mkdir(const char *pathname, unsigned short mode);
#define mkdir w32_mkdir
int w32_chmod(const char *, mode_t);
#define chmod w32_chmod
struct w32_stat {
@ -56,9 +46,5 @@ struct w32_stat {
__int64 st_ctime; /* time of last status change */
};
typedef unsigned short _mode_t;
typedef _mode_t mode_t;
void strmode(mode_t mode, char *p);
int w32_chmod(const char *, mode_t);
int w32_mkdir(const char *pathname, unsigned short mode);
void strmode(mode_t mode, char *p);

View File

@ -0,0 +1,15 @@
#define __STDC__ 1
#include "..\crtheaders.h"
#include SYS_TYPES_H
typedef _dev_t dev_t;
typedef long long off_t;
typedef unsigned int uid_t;
typedef unsigned int gid_t;
typedef unsigned short _mode_t;
typedef _mode_t mode_t;
typedef int ssize_t;
typedef int pid_t;
typedef unsigned int nfds_t;

View File

@ -1,7 +1,7 @@
#ifndef COMPAT_UIO_H
#define COMPAT_UIO_H 1
#pragma once
/* Compatibility header to avoid #ifdefs on Win32 */
#endif
struct iovec
{
void *iov_base;
size_t iov_len;
};

View File

@ -1,5 +1,4 @@
#pragma once
#include "..\w32posix.h"
//#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */
//#define WIFEXITED(w) (!((_W_INT(w)) & 0377))
@ -16,4 +15,7 @@
#define WNOHANG 1
#define WUNTRACED 2
/* wait pid options */
#define WNOHANG 1
int waitpid(int pid, int *status, int options);

View File

@ -3,48 +3,82 @@
*
* POSIX header and needed function definitions
*/
#ifndef COMPAT_UNISTD_H
#define COMPAT_UNISTD_H 1
#pragma once
#include "sys\types.h"
#include "fcntl.h"
#include "w32posix.h"
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
int w32_ftruncate(int, off_t);
#define ftruncate(a, b) w32_ftruncate((a), (b))
#define pipe w32_pipe
#define open w32_open
int w32_pipe(int *pfds);
#define read w32_read
int w32_read(int fd, void *dst, size_t max);
#define write w32_write
int w32_write(int fd, const void *buf, unsigned int max);
#define writev w32_writev
int w32_writev(int fd, const struct iovec *iov, int iovcnt);
int w32_isatty(int fd);
/* can't do this #define isatty w32_isatty
* as there is a variable in code named isatty*/
#define isatty(a) w32_isatty((a))
int w32_close(int fd);
#define close w32_close
int w32_dup(int oldfd);
#define dup w32_dup
int w32_dup2(int oldfd, int newfd);
#define dup2 w32_dup2
#define sleep(sec) Sleep(1000 * sec)
unsigned int w32_alarm(unsigned int seconds);
#define alarm w32_alarm
long w32_lseek(int fd, long offset, int origin);
#define lseek w32_lseek
#define getdtablesize() MAX_FDS
int w32_gethostname(char *, size_t);
#define gethostname w32_gethostname
int w32_fsync(int fd);
#define fsync(a) w32_fsync((a))
#define ftruncate(a, b) w32_ftruncate((a), (b))
int w32_symlink(const char *target, const char *linkpath);
#define symlink w32_symlink
int w32_chown(const char *pathname, unsigned int owner, unsigned int group);
#define chown w32_chown
int w32_unlink(const char *path);
#define unlink w32_unlink
int w32_rmdir(const char *pathname);
#define rmdir w32_rmdir
int w32_chdir(const char *dirname);
#define chdir w32_chdir
char *w32_getcwd(char *buffer, int maxlen);
#define getcwd w32_getcwd
int daemon(int nochdir, int noclose);
char *crypt(const char *key, const char *salt);
int link(const char *oldpath, const char *newpath);
int w32_symlink(const char *target, const char *linkpath);
int w32_chown(const char *pathname, unsigned int owner, unsigned int group);
int w32_unlink(const char *path);
int w32_rmdir(const char *pathname);
int w32_chdir(const char *dirname);
char *w32_getcwd(char *buffer, int maxlen);
int readlink(const char *path, char *link, int linklen);
#endif
int spawn_child(char* cmd, int in, int out, int err, unsigned long flags);

View File

@ -1,166 +0,0 @@
/*
* Author: Manoj Ampalam <manoj.ampalam@microsoft.com>
*
* Win32 renamed POSIX APIs
*/
#pragma once
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <stdio.h>
#include "defs.h"
#include "utf.h"
#include "sys\param.h"
typedef struct w32_fd_set_ {
unsigned char bitmap[MAX_FDS >> 3];
}w32_fd_set;
#define fd_set w32_fd_set
void w32posix_initialize();
void w32posix_done();
/*network i/o*/
int w32_socket(int domain, int type, int protocol);
int w32_accept(int fd, struct sockaddr* addr, int* addrlen);
int w32_setsockopt(int fd, int level, int optname, const void* optval, int optlen);
int w32_getsockopt(int fd, int level, int optname, void* optval, int* optlen);
int w32_getsockname(int fd, struct sockaddr* name, int* namelen);
int w32_getpeername(int fd, struct sockaddr* name, int* namelen);
int w32_listen(int fd, int backlog);
int w32_bind(int fd, const struct sockaddr *name, int namelen);
int w32_connect(int fd, const struct sockaddr* name, int namelen);
int w32_recv(int fd, void *buf, size_t len, int flags);
int w32_send(int fd, const void *buf, size_t len, int flags);
int w32_shutdown(int fd, int how);
int w32_socketpair(int domain, int type, int protocol, int sv[2]);
/*non-network (file) i/o*/
#undef fdopen
#define fdopen(a,b) w32_fdopen((a), (b))
#define fstat(a,b) w32_fstat((a), (b))
#define rename w32_rename
struct w32_stat;
int w32_pipe(int *pfds);
int w32_open(const char *pathname, int flags, ...);
int w32_read(int fd, void *dst, size_t max);
int w32_write(int fd, const void *buf, unsigned int max);
int w32_writev(int fd, const struct iovec *iov, int iovcnt);
int w32_fstat(int fd, struct w32_stat *buf);
int w32_stat(const char *path, struct w32_stat *buf);
long w32_lseek( int fd, long offset, int origin);
int w32_isatty(int fd);
FILE* w32_fdopen(int fd, const char *mode);
int w32_rename(const char *old_name, const char *new_name);
/*common i/o*/
#define fcntl(a,b,...) w32_fcntl((a), (b), __VA_ARGS__)
#define select(a,b,c,d,e) w32_select((a), (b), (c), (d), (e))
int w32_close(int fd);
int w32_select(int fds, w32_fd_set* readfds, w32_fd_set* writefds, w32_fd_set* exceptfds,
const struct timeval *timeout);
int w32_fcntl(int fd, int cmd, ... /* arg */);
int w32_dup(int oldfd);
int w32_dup2(int oldfd, int newfd);
/* misc */
unsigned int w32_alarm(unsigned int seconds);
sighandler_t w32_signal(int signum, sighandler_t handler);
int w32_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
int w32_raise(int sig);
int w32_kill(int pid, int sig);
int w32_gethostname(char *, size_t);
void w32_freeaddrinfo(struct addrinfo *);
int w32_getaddrinfo(const char *, const char *,
const struct addrinfo *, struct addrinfo **);
FILE* w32_fopen_utf8(const char *, const char *);
int w32_ftruncate(int fd, off_t length);
char* w32_programdir();
int w32_fsync(int fd);
int w32_ioctl(int d, int request, ...);
/* Shutdown constants */
#define SHUT_WR SD_SEND
#define SHUT_RD SD_RECEIVE
#define SHUT_RDWR SD_BOTH
/* Other constants */
#define IN_LOOPBACKNET 127 /* 127.* is the loopback network */
#define MAXHOSTNAMELEN 64
/* Errno helpers */
#ifndef EXX
#define EXX WSAEMFILE
#endif
#ifndef EXX1
#define EXX1 WSAENOBUFS
#endif
#ifndef ESOCKTNOSUPPORT
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#endif
#ifndef ENOTUNREACH
#define ENOTUNREACH WSAENOTUNREACH
#endif
#ifndef EPFNOSUPPORT
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#endif
int spawn_child(char* cmd, int in, int out, int err, DWORD flags);
/*
* these routines are temporarily defined here to allow transition
* from older POSIX wrapper to the newer one. After complete transition
* these should be gone or moved to a internal header.
*/
HANDLE w32_fd_to_handle(int fd);
int w32_allocate_fd_for_handle(HANDLE h, BOOL is_sock);
int sw_add_child(HANDLE child, DWORD pid);
/* temporary definitions to aid in transition */
#define sfd_to_handle(a) w32_fd_to_handle((a))
/* TODO - These defs need to revisited and positioned appropriately */
#define environ _environ
typedef unsigned int nfds_t;
struct w32_pollfd {
int fd;
SHORT events;
SHORT revents;
};
#define pollfd w32_pollfd
struct iovec
{
void *iov_base;
size_t iov_len;
};
#define bzero(p,l) memset((void *)(p),0,(size_t)(l))
void
explicit_bzero(void *b, size_t len);
/* string.h overrides */
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
char *w32_strerror(int);
#define strerror w32_strerror
/* stdio.h overrides */
#define fopen w32_fopen_utf8
#define popen _popen
#define pclose _pclose
void convertToBackslash(char *str);
void convertToForwardslash(char *str);

View File

@ -30,8 +30,7 @@
#include <Windows.h>
#include <stdio.h>
#include "inc\defs.h"
#include "sys\stat.h"
#include "inc\sys\stat.h"
#include "inc\sys\statvfs.h"
#include "inc\sys\time.h"
#include <time.h>
@ -39,6 +38,10 @@
#include "misc_internal.h"
#include "inc\dlfcn.h"
#include "inc\dirent.h"
#include "inc\sys\types.h"
#include "inc\sys\ioctl.h"
#include "inc\fcntl.h"
#include "signal_internal.h"
int usleep(unsigned int useconds)
{
@ -254,7 +257,6 @@ int w32_ioctl(int d, int request, ...) {
}
}
HANDLE w32_fd_to_handle(int fd);
int
spawn_child(char* cmd, int in, int out, int err, DWORD flags) {
PROCESS_INFORMATION pi;
@ -314,7 +316,7 @@ spawn_child(char* cmd, int in, int out, int err, DWORD flags) {
b = CreateProcessW(NULL, cmd_utf16, NULL, NULL, TRUE, flags, NULL, NULL, &si, &pi);
if (b) {
if (sw_add_child(pi.hProcess, pi.dwProcessId) == -1) {
if (register_child(pi.hProcess, pi.dwProcessId) == -1) {
TerminateProcess(pi.hProcess, 0);
CloseHandle(pi.hProcess);
pi.dwProcessId = -1;

View File

@ -1,4 +1,12 @@
#define PATH_MAX MAX_PATH
/* removes first '/' for Windows paths that are unix styled. Ex: /c:/ab.cd */
char * sanitized_path(const char *);
char * sanitized_path(const char *);
void w32posix_initialize();
void w32posix_done();
char* w32_programdir();
void convertToBackslash(char *str);
void convertToForwardslash(char *str);

View File

@ -28,7 +28,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "inc\sys\param.h"
#include "inc\sys\types.h"
/* uuidswap.c defs */
void temporarily_use_uid(struct passwd *pw){

View File

@ -45,8 +45,6 @@ static struct passwd pw;
static char* pw_shellpath = NULL;
#define SHELL_HOST "\\ssh-shellhost.exe"
char* w32_programdir();
int
initialize_pw() {
if (pw_shellpath == NULL) {
@ -120,25 +118,35 @@ get_passwd(const char *user_utf8, LPWSTR user_sid) {
}
if (user_sid == NULL) {
if (NetUserGetInfo(udom_utf16, uname_utf16, 23, &user_info) != NERR_Success) {
if (DsGetDcNameW(NULL, udom_utf16, NULL, NULL, DS_DIRECTORY_SERVICE_PREFERRED, &pdc) == ERROR_SUCCESS) {
if (NetUserGetInfo(pdc->DomainControllerName, uname_utf16, 23, &user_info) != NERR_Success ||
ConvertSidToStringSidW(((LPUSER_INFO_23)user_info)->usri23_user_sid, &user_sid_local) == FALSE) {
errno = ENOMEM; //??
goto done;
}
}
else {
NET_API_STATUS status;
if ((status = NetUserGetInfo(udom_utf16, uname_utf16, 23, &user_info)) != NERR_Success) {
debug("NetUserGetInfo() failed with error: %d \n", status);
DWORD dsStatus;
if ((dsStatus = DsGetDcNameW(NULL, udom_utf16, NULL, NULL, DS_DIRECTORY_SERVICE_PREFERRED, &pdc)) == ERROR_SUCCESS) {
if ((status = NetUserGetInfo(pdc->DomainControllerName, uname_utf16, 23, &user_info)) != NERR_Success) {
debug("NetUserGetInfo() with domainController failed with error: %d \n", status);
if (ConvertSidToStringSidW(((LPUSER_INFO_23)user_info)->usri23_user_sid, &user_sid_local) == FALSE) {
error("ConvertSidToStringSidW() failed with error: %d\n", GetLastError());
errno = ENOMEM; //??
goto done;
}
}
} else {
error("DsGetDcNameW() failed with error: %d \n", dsStatus);
errno = ENOMEM; //??
goto done;
}
}
else {
} else {
if (ConvertSidToStringSidW(((LPUSER_INFO_23)user_info)->usri23_user_sid, &user_sid_local) == FALSE) {
error("NetUserGetInfo() Succeded but ConvertSidToStringSidW() failed with error: %d\n", GetLastError());
errno = ENOMEM; //??
goto done;
}
}
user_sid = user_sid_local;
}

View File

@ -95,7 +95,7 @@ struct key_translation keys[] = {
{ "\x1b", VK_ESCAPE, "\x1b" },
{ "\r", VK_RETURN, "\r" },
{ "\b", VK_BACK, "\b" },
{ "\x7f", VK_BACK, "\x7f" },
{ "\x7f", VK_BACK, "\b" },
{ "\t", VK_TAB, "\t" },
{ "\x1b[A", VK_UP, 0 },
{ "\x1b[B", VK_DOWN, 0 },
@ -1069,15 +1069,15 @@ int start_with_pty(int ac, wchar_t **av) {
/*TODO - pick this up from system32*/
cmd[0] = L'\0';
if (ac)
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L"cmd.exe"));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L"cmd.exe"));
ac--;
av++;
if (ac)
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L" /c"));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" /c"));
while (ac) {
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L" "));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, *av));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" "));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, *av));
ac--;
av++;
}
@ -1183,14 +1183,14 @@ int start_withno_pty(int ac, wchar_t **av) {
/*TODO - pick this up from system32*/
cmd[0] = L'\0';
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L"cmd.exe"));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L"cmd.exe"));
ac -= 2;
av += 2;
if (ac)
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L" /c"));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" /c"));
while (ac) {
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L" "));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, *av));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" "));
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, *av));
ac--;
av++;
}

View File

@ -30,8 +30,21 @@
#include "w32fd.h"
#include <errno.h>
#include <signal.h>
#include "signal_internal.h"
#include "inc\signal.h"
#undef signal
#undef raise
#undef SIGINT
#undef SIGILL
#undef SIGPFE
#undef SIGSEGV
#undef SIGTERM
#undef SIGFPE
#undef SIGABRT
#undef SIG_DFL
#undef SIG_IGN
#undef SIG_ERR
#include <signal.h>
/* pending signals to be processed */
sigset_t pending_signals;
@ -106,14 +119,14 @@ sw_init_signal_handler_table() {
SetConsoleCtrlHandler(native_sig_handler, TRUE);
sigemptyset(&pending_signals);
/* this automatically sets all to SIG_DFL (0)*/
/* this automatically sets all to W32_SIG_DFL (0)*/
memset(sig_handlers, 0, sizeof(sig_handlers));
}
extern struct _children children;
sighandler_t
sw_signal(int signum, sighandler_t handler) {
w32_signal(int signum, sighandler_t handler) {
sighandler_t prev;
debug2("signal() sig:%d, handler:%p", signum, handler);
@ -128,7 +141,7 @@ sw_signal(int signum, sighandler_t handler) {
}
int
sw_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
w32_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
/* this is only used by sshd to block SIGCHLD while doing waitpid() */
/* our implementation of waidpid() is never interrupted, so no need to implement this for now*/
debug3("sigprocmask() how:%d");
@ -138,7 +151,7 @@ sw_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
int
sw_raise(int sig) {
w32_raise(int sig) {
debug("raise sig:%d", sig);
if (sig == W32_SIGSEGV)
return raise(SIGSEGV); /* raise native exception handler*/
@ -196,7 +209,7 @@ sw_process_pending_signals() {
for (i = 0; i < (sizeof(exp) / sizeof(exp[0])); i++) {
if (sigismember(&pending_tmp, exp[i])) {
if (sig_handlers[exp[i]] != W32_SIG_IGN) {
sw_raise(exp[i]);
w32_raise(exp[i]);
/* dont error EINTR for SIG_ALRM, */
/* sftp client is not expecting it */
if (exp[i] != W32_SIGALRM)

View File

@ -1,12 +1,4 @@
#include <Windows.h>
#include "inc\defs.h"
int sw_initialize();
sighandler_t sw_signal(int signum, sighandler_t handler);
int sw_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
int sw_raise(int sig);
int sw_kill(int pid, int sig);
/* child processes */
#define MAX_CHILDREN 50
@ -25,7 +17,9 @@ struct _children {
DWORD num_zombies;
};
int sw_add_child(HANDLE child, DWORD pid);
int sw_initialize();
int register_child(HANDLE child, DWORD pid);
int sw_remove_child_at_index(DWORD index);
int sw_child_to_zombie(DWORD index);
void sw_cleanup_child_zombies();
@ -36,4 +30,3 @@ struct _timer_info {
__int64 run_time_sec; /* time in seconds, timer is set to go off from ticks_at_start */
};
int sw_init_timer();
unsigned int sw_alarm(unsigned int seconds);

View File

@ -29,6 +29,7 @@
*/
#include "signal_internal.h"
#include "inc\signal.h"
struct _timer_info timer_info;
extern sigset_t pending_signals;
@ -43,7 +44,7 @@ sigalrm_APC(
}
unsigned int
sw_alarm(unsigned int sec) {
w32_alarm(unsigned int sec) {
LARGE_INTEGER due;
ULONGLONG sec_passed;
int ret = 0;

View File

@ -29,11 +29,12 @@
*/
#include "signal_internal.h"
#include "inc\sys\wait.h"
struct _children children;
int
sw_add_child(HANDLE child, DWORD pid) {
register_child(HANDLE child, DWORD pid) {
DWORD first_zombie_index;
debug("Register child %p pid %d, %d zombies of %d", child, pid,
@ -128,10 +129,10 @@ sw_child_to_zombie(DWORD index) {
}
int
sw_kill(int pid, int sig) {
w32_kill(int pid, int sig) {
int child_index, i;
if (pid == GetCurrentProcessId())
return sw_raise(sig);
return w32_raise(sig);
/* for child processes - only SIGTERM supported*/
child_index = -1;
@ -207,6 +208,9 @@ int waitpid(int pid, int *status, int options) {
if (children.num_zombies) {
/* return one of them */
ret_id = children.process_id[children.num_children - 1];
GetExitCodeProcess(children.handles[children.num_children - 1], &exit_code);
if (status)
*status = exit_code;
sw_remove_child_at_index(children.num_children - 1);
return ret_id;
}

View File

@ -47,6 +47,7 @@
static
int errno_from_WSAError(int wsaerrno)
{
/* TODO - create a mapping table - more efficient */
switch (wsaerrno) {
case WSAEWOULDBLOCK:
return EAGAIN;
@ -56,6 +57,8 @@ int errno_from_WSAError(int wsaerrno)
return EINVAL;
case WSAECONNABORTED:
return ECONNABORTED;
case WSAETIMEDOUT:
return ETIMEDOUT;
case WSAECONNREFUSED:
return ECONNREFUSED;
case WSAEINPROGRESS:
@ -64,6 +67,8 @@ int errno_from_WSAError(int wsaerrno)
return ECONNRESET;
case WSAENOTCONN:
return ENOTCONN;
case WSAECONNRESET:
return ECONNRESET;
default:
/* */
return wsaerrno - 10000;

View File

@ -1,11 +1,12 @@
#include <Windows.h>
#include "w32fd.h"
#include "tncon.h"
#include "inc\defs.h"
#include "inc\utf.h"
#define TERM_IO_BUF_SIZE 2048
extern int in_raw_mode;
struct io_status {
DWORD to_transfer;
DWORD transferred;
@ -29,27 +30,6 @@ static VOID CALLBACK ReadAPCProc(
pio->read_overlapped.hEvent = 0;
}
static DWORD WINAPI ReadThread(
_In_ LPVOID lpParameter
) {
struct w32_io* pio = (struct w32_io*)lpParameter;
debug3("TermRead thread, io:%p", pio);
memset(&read_status, 0, sizeof(read_status));
if (!ReadFile(WINHANDLE(pio), pio->read_details.buf,
pio->read_details.buf_size, &read_status.transferred, NULL)) {
read_status.error = GetLastError();
debug("TermRead thread - ReadFile failed %d, io:%p", GetLastError(), pio);
}
if (0 == QueueUserAPC(ReadAPCProc, main_thread, (ULONG_PTR)pio)) {
debug("TermRead thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio);
pio->read_details.pending = FALSE;
pio->read_details.error = GetLastError();
DebugBreak();
}
return 0;
}
static DWORD WINAPI ReadConsoleThread(
_In_ LPVOID lpParameter
) {
@ -129,25 +109,19 @@ static DWORD WINAPI WriteThread(
DWORD dwSavedAttributes = ENABLE_PROCESSED_INPUT;
debug3("TermWrite thread, io:%p", pio);
/* decide to call parsing engine or directly write to console
* doing the following trick to decide -
* if console in handle is set to process Ctrl+C, then it is likely
* serving a PTY enabled session
*/
GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwSavedAttributes);
if (dwSavedAttributes & ENABLE_PROCESSED_INPUT) {
if (in_raw_mode == 0) {
/* convert stream to utf16 and dump on console */
pio->write_details.buf[write_status.to_transfer] = '\0';
wchar_t* t = utf8_to_utf16(pio->write_details.buf);
WriteConsoleW(WINHANDLE(pio), t, wcslen(t), 0, 0);
free(t);
write_status.transferred = write_status.to_transfer;
} else {
telProcessNetwork(pio->write_details.buf, write_status.to_transfer, &respbuf, &resplen);
/*TODO - respbuf is not null in some cases, this needs to be returned back via read stream*/
write_status.transferred = write_status.to_transfer;
}
} else {
/* console mode */
telProcessNetwork(pio->write_details.buf, write_status.to_transfer, &respbuf, &resplen);
/*TODO - respbuf is not null in some cases, this needs to be returned back via read stream*/
write_status.transferred = write_status.to_transfer;
}
if (0 == QueueUserAPC(WriteAPCProc, main_thread, (ULONG_PTR)pio)) {
debug("TermWrite thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio);

View File

@ -57,16 +57,9 @@ size_t telProcessNetwork(char *buf, size_t len, unsigned char **respbuf, size_t
unsigned char* pszHead = NULL;
unsigned char* pszTail = NULL;
char *term = NULL;
if (len == 0)
return len;
term = getenv("TERM");
if (term != NULL && _stricmp(term, "passthru") == 0)
return len;
// Transform a single carriage return into a single linefeed before
// continuing.
if ((len == 1) && (buf[0] == 13))

View File

@ -29,7 +29,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "inc\w32posix.h"
#include "inc\sys\socket.h"
#include "inc\sys\select.h"
#include "inc\sys\uio.h"
#include "inc\sys\types.h"
#include "inc\unistd.h"
#include "inc\fcntl.h"
#include "w32fd.h"
#include "signal_internal.h"
#include <stdarg.h>
@ -804,30 +810,6 @@ int w32_allocate_fd_for_handle(HANDLE h, BOOL is_sock) {
}
unsigned int
w32_alarm(unsigned int seconds) {
return sw_alarm(seconds);;
}
sighandler_t
w32_signal(int signum, sighandler_t handler) {
return sw_signal(signum, handler);
}
int
w32_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) {
return sw_sigprocmask(how, set, oldset);
}
int
w32_raise(int sig) {
return sw_raise(sig);
}
int
w32_kill(int pid, int sig) {
return sw_kill(pid, sig);
}
int
w32_ftruncate(int fd, off_t length) {
CHECK_FD(fd);

View File

@ -8,7 +8,6 @@
#include <Windows.h>
#include <stdio.h>
#include "inc\defs.h"
enum w32_io_type {
UNKNOWN_FD = 0,

View File

@ -32,14 +32,14 @@
#include <Windows.h>
#include "inc\utf.h"
#include "misc_internal.h"
int main(int, char **);
void w32posix_initialize();
int
wmain(int argc, wchar_t **wargv) {
char** argv = NULL;
int i;
int i,r;
if (argc) {
if ((argv = malloc(argc * sizeof(char*))) == NULL)
@ -49,5 +49,7 @@ wmain(int argc, wchar_t **wargv) {
}
w32posix_initialize();
return main(argc, argv);
r = main(argc, argv);
w32posix_done();
return r;
}

View File

@ -35,9 +35,9 @@
#include <Windows.h>
#include <wchar.h>
#include "inc\utf.h"
#include "misc_internal.h"
int main(int, char **);
void w32posix_initialize();
extern HANDLE main_thread;
extern int is_child;
@ -97,10 +97,9 @@ static VOID WINAPI service_handler(DWORD dwControl)
ReportSvcStatus(service_status.dwCurrentState, NO_ERROR, 0);
}
char* w32_programdir();
int sshd_main(int argc, wchar_t **wargv) {
char** argv = NULL;
int i;
int i, r;
if (argc) {
if ((argv = malloc(argc * sizeof(char*))) == NULL)
@ -118,7 +117,9 @@ int sshd_main(int argc, wchar_t **wargv) {
_wchdir(path_utf16);
free(path_utf16);
return main(argc, argv);
r = main(argc, argv);
w32posix_done();
return r;
}
int wmain(int argc, wchar_t **wargv) {

View File

@ -166,15 +166,6 @@
#define _PATH_LS "ls"
#endif
/* path to login program */
#ifndef LOGIN_PROGRAM
# ifdef LOGIN_PROGRAM_FALLBACK
# define LOGIN_PROGRAM LOGIN_PROGRAM_FALLBACK
# else
# define LOGIN_PROGRAM "/usr/bin/login"
# endif
#endif /* LOGIN_PROGRAM */
/* Askpass program define */
#ifndef ASKPASS_PROGRAM
#define ASKPASS_PROGRAM "/usr/lib/ssh/ssh-askpass"

View File

@ -25,6 +25,7 @@ Describe "Tests for scp command" -Tags "CI" {
[Machine] $server = [Machine]::new([MachineRole]::Server)
$client.SetupClient($server)
$server.SetupServer($client)
$script:logNum = 0
$testData = @(
@{
@ -35,7 +36,7 @@ Describe "Tests for scp command" -Tags "CI" {
@{
Title = 'Simple copy local file to remote file'
Source = $SourceFilePath
Destination = "$($server.localAdminUserName)@$($server.MachineName):$DestinationFilePath"
Destination = "$($server.localAdminUserName)@$($server.MachineName):$DestinationFilePath"
},
@{
Title = 'Simple copy remote file to local file'
@ -76,6 +77,19 @@ Describe "Tests for scp command" -Tags "CI" {
Destination = $DestinationDir
}
)
function CheckTarget {
param([string]$target)
if(-not (Test-path $target))
{
Copy-Item .\logs\ssh-agent.log ".\logs\failedagent$script:logNum.log" -Force
Copy-Item .\logs\sshd.log ".\logs\failedsshd$script:logNum.log" -Force
$script:logNum++
return $false
}
return $true
}
}
AfterAll {
@ -87,7 +101,7 @@ Describe "Tests for scp command" -Tags "CI" {
}
BeforeAll {
$null = New-Item $DestinationDir -ItemType directory -Force
$null = New-Item $DestinationDir -ItemType directory -Force -ErrorAction SilentlyContinue
}
AfterEach {
@ -105,30 +119,44 @@ Describe "Tests for scp command" -Tags "CI" {
$Server.SecureHostKeys($server.PrivateHostKeyPaths)
$privateKeyFile = $client.clientPrivateKeyPaths[0]
}
BeforeEach {
if ($env:DebugMode)
{
Stop-Service ssh-agent -Force
Start-Sleep 2
Remove-Item .\logs\ssh-agent.log -Force -ErrorAction ignore
Remove-Item .\logs\sshd.log -Force -ErrorAction ignore
Start-Service sshd
}
}
AfterAll {
$Server.CleanupHostKeys()
}
It 'File copy with -i option and private key: <Title> ' -TestCases:$testData {
param([string]$Title, $Source, $Destination)
param([string]$Title, $Source, $Destination)
.\scp -i $privateKeyFile $Source $Destination
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length).Length -eq 0
$equal | Should Be $true
}
}
It 'Directory recursive copy with -i option and private key: <Title> ' -TestCases:$testData1 {
param([string]$Title, $Source, $Destination)
param([string]$Title, $Source, $Destination)
.\scp -r -i $privateKeyFile $Source $Destination
$LASTEXITCODE | Should Be 0
CheckTarget -target (join-path $DestinationDir $SourceDirName) | Should Be $true
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length).Length -eq 0
$equal | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -Recurse -path $SourceDir) (Get-ChildItem -Recurse -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length).Length -eq 0
$equal | Should Be $true
$equal | Should Be $true
}
}
@ -147,28 +175,34 @@ Describe "Tests for scp command" -Tags "CI" {
.\ssh-add.exe -D
}
It 'File copy with -S option (positive)' {
.\scp -S .\ssh.exe $SourceFilePath "$($server.localAdminUserName)@$($server.MachineName):$DestinationFilePath"
It 'File copy with -S -v option (positive)' {
.\scp -S .\ssh.exe -v $SourceFilePath "$($server.localAdminUserName)@$($server.MachineName):$DestinationFilePath"
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length).Length -eq 0
$equal | Should Be $true
}
It 'File copy with -p -c -v option: <Title> ' -TestCases:$testData {
It 'File copy with -p -c option: <Title> ' -TestCases:$testData {
param([string]$Title, $Source, $Destination)
.\scp -p -c aes128-ctr -v -C $Source $Destination
.\scp -p -c aes128-ctr -C $Source $Destination
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true
}
It 'Directory recursive copy with -r -p -v option: <Title> ' -TestCases:$testData1 {
param([string]$Title, $Source, $Destination)
.\scp -r -p -c aes128-ctr -v $Source $Destination
It 'Directory recursive copy with -r -p -c option: <Title> ' -TestCases:$testData1 {
param([string]$Title, $Source, $Destination)
.\scp -r -p -c aes128-ctr $Source $Destination
$LASTEXITCODE | Should Be 0
CheckTarget -target (join-path $DestinationDir $SourceDirName) | Should Be $true
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true
$equal | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -Recurse -path $SourceDir) (Get-ChildItem -Recurse -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true
@ -184,7 +218,9 @@ Describe "Tests for scp command" -Tags "CI" {
param([string]$Title, $Source, $Destination)
.\scp -i $identifyFile -C -q $Source $Destination
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length).Length -eq 0
$equal | Should Be $true
}
@ -193,6 +229,8 @@ Describe "Tests for scp command" -Tags "CI" {
param([string]$Title, $Source, $Destination)
.\scp -i $identifyFile -C -r -q $Source $Destination
$LASTEXITCODE | Should Be 0
CheckTarget -target (join-path $DestinationDir $SourceDirName) | Should Be $true
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length).Length -eq 0
$equal | Should Be $true
@ -213,8 +251,10 @@ Describe "Tests for scp command" -Tags "CI" {
It 'File copy with -p options: <Title> ' -TestCases:$testData {
param([string]$Title, $Source, $Destination)
.\scp -p $Source $Destination
.\scp -p $Source $Destination
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true
}
@ -222,7 +262,9 @@ Describe "Tests for scp command" -Tags "CI" {
It 'Directory recursive copy with -p and -v options: <Title> ' -TestCases:$testData1 {
param([string]$Title, $Source, $Destination)
.\scp -r -p $Source $Destination
.\scp -r -p $Source $Destination
$LASTEXITCODE | Should Be 0
CheckTarget -target (join-path $DestinationDir $SourceDirName) | Should Be $true
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true

View File

@ -0,0 +1,267 @@
using module .\PlatformAbstractLayer.psm1
Describe "SFTP Testcases" -Tags "CI" {
BeforeAll {
$rootDirectory = $TestDrive
$outputFileName = "output.txt"
$batchFileName = "sftp-batchcmds.txt"
$outputFilePath = Join-Path $rootDirectory $outputFileName
$batchFilePath = Join-Path $rootDirectory $batchFileName
$tempFileName = "tempFile.txt"
$tempFilePath = Join-Path $rootDirectory $tempFileName
$tempUnicodeFileName = "tempFile_язык.txt"
$tempUnicodeFilePath = Join-Path $rootDirectory $tempUnicodeFileName
$clientDirectory = Join-Path $rootDirectory 'client_dir'
$serverDirectory = Join-Path $rootDirectory 'server_dir'
$null = New-Item $clientDirectory -ItemType directory -Force
$null = New-Item $serverDirectory -ItemType directory -Force
$null = New-Item $batchFilePath -ItemType file -Force
$null = New-Item $outputFilePath -ItemType file -Force
$null = New-Item $tempFilePath -ItemType file -Force -value "temp file data"
$null = New-Item $tempUnicodeFilePath -ItemType file -Force -value "temp file data"
$expectedOutputDelimiter = "#DL$"
[Machine] $client = [Machine]::new([MachineRole]::Client)
[Machine] $server = [Machine]::new([MachineRole]::Server)
$client.SetupClient($server)
$server.SetupServer($client)
$testData1 = @(
@{
title = "put, ls for non-unicode file names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "put $tempFilePath $serverDirectory
ls $serverDirectory"
expectedoutput = (join-path $serverdirectory $tempFileName).replace("\", "/")
},
@{
title = "get, ls for non-unicode file names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "get $tempFilePath $clientDirectory
ls $clientDirectory"
expectedoutput = (join-path $clientDirectory $tempFileName).replace("\", "/")
},
@{
title = "mput, ls for non-unicode file names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "mput $tempFilePath $serverDirectory
ls $serverDirectory"
expectedoutput = (join-path $serverdirectory $tempFileName).replace("\", "/")
},
@{
title = "mget, ls for non-unicode file names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "mget $tempFilePath $clientDirectory
ls $clientDirectory"
expectedoutput = (join-path $clientDirectory $tempFileName).replace("\", "/")
},
@{
title = "mkdir, cd, pwd for non-unicode directory names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "cd $serverdirectory
mkdir server_test_dir
cd server_test_dir
pwd"
expectedoutput = (join-path $serverdirectory "server_test_dir").replace("\", "/")
},
@{
Title = "lmkdir, lcd, lpwd for non-unicode directory names"
LogonStr = "$($server.localAdminUserName)@$($server.MachineName)"
Options = '-i $identifyFile'
Commands = "lcd $clientDirectory
lmkdir client_test_dir
lcd client_test_dir
lpwd"
ExpectedOutput = (Join-Path $clientDirectory "client_test_dir")
},
@{
title = "put, ls for unicode file names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "put $tempUnicodeFilePath $serverDirectory
ls $serverDirectory"
expectedoutput = (join-path $serverdirectory $tempUnicodeFileName).replace("\", "/")
},
@{
title = "get, ls for unicode file names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "get $tempUnicodeFilePath $clientDirectory
ls $clientDirectory"
expectedoutput = (join-path $clientDirectory $tempUnicodeFileName).replace("\", "/")
},
@{
title = "mput, ls for unicode file names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "mput $tempUnicodeFilePath $serverDirectory
ls $serverDirectory"
expectedoutput = (join-path $serverdirectory $tempUnicodeFileName).replace("\", "/")
},
@{
title = "mget, ls for unicode file names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "mget $tempUnicodeFilePath $clientDirectory
ls $clientDirectory"
expectedoutput = (join-path $clientDirectory $tempUnicodeFileName).replace("\", "/")
},
@{
title = "mkdir, cd, pwd for unicode directory names"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile'
commands = "cd $serverdirectory
mkdir server_test_dir_язык
cd server_test_dir_язык
pwd"
expectedoutput = (join-path $serverdirectory "server_test_dir_язык").replace("\", "/")
},
@{
Title = "lmkdir, lcd, lpwd for unicode directory names"
LogonStr = "$($server.localAdminUserName)@$($server.MachineName)"
Options = '-i $identifyFile'
Commands = "lcd $clientDirectory
lmkdir client_test_dir_язык
lcd client_test_dir_язык
lpwd
lls $clientDirectory"
ExpectedOutput = (Join-Path $clientDirectory "client_test_dir_язык")
}
)
$testData2 = @(
@{
title = "rm, rmdir, rename for unicode file, directory"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile -b $batchFilePath'
tmpFileName1 = $tempUnicodeFileName
tmpFilePath1 = $tempUnicodeFilePath
tmpFileName2 = "tempfile_язык_2.txt"
tmpFilePath2 = (join-path $serverDirectory "tempfile_язык_2.txt")
tmpDirectoryName1 = "test_dir_язык_1"
tmpDirectoryPath1 = (join-path $serverDirectory "test_dir_язык_1")
tmpDirectoryName2 = "test_dir_язык_2"
tmpDirectoryPath2 = (join-path $serverDirectory "test_dir_язык_2")
},
@{
title = "rm, rmdir, rename for non-unicode file, directory"
logonstr = "$($server.localadminusername)@$($server.machinename)"
options = '-i $identifyfile -b $batchFilePath'
tmpFileName1 = $tempFileName
tmpFilePath1 = $tempFilePath
tmpFileName2 = "tempfile_2.txt"
tmpFilePath2 = (join-path $serverDirectory "tempfile_2.txt")
tmpDirectoryName1 = "test_dir_1"
tmpDirectoryPath1 = (join-path $serverDirectory "test_dir_1")
tmpDirectoryName2 = "test_dir_2"
tmpDirectoryPath2 = (join-path $serverDirectory "test_dir_2")
}
)
}
AfterAll {
$client.CleanupClient()
$server.CleanupServer()
}
Context "Single signon" {
BeforeAll {
$Server.SecureHostKeys($server.PrivateHostKeyPaths)
$identifyFile = $client.clientPrivateKeyPaths[0]
.\ssh-add.exe $identifyFile #setup single signon
}
AfterAll {
$Server.CleanupHostKeys()
.\ssh-add.exe -D #cleanup single signon
Get-Item $rootDirectory | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
}
BeforeEach {
Get-ChildItem $serverDirectory | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem $clientDirectory | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $batchFilePath
Remove-Item $outputFilePath
}
It '<Title>' -TestCases:$testData1 {
param([string]$Title, $LogonStr, $Options, $Commands, $ExpectedOutput, $SkipVerification = $false)
Set-Content $batchFilePath -Encoding UTF8 -value $Commands
$str = $ExecutionContext.InvokeCommand.ExpandString(".\sftp $($Options) -b $batchFilePath $($LogonStr) > $outputFilePath")
$client.RunCmd($str)
#validate file content.
$($ExpectedOutput).split($expectedOutputDelimiter) | foreach {
$outputFilePath | Should Contain ([RegEx]::Escape($_))
}
}
It '<Title>' -TestCases:$testData2 {
param([string]$Title, $LogonStr, $Options, $tmpFileName1, $tmpFilePath1, $tmpFileName2, $tmpFilePath2, $tmpDirectoryName1, $tmpDirectoryPath1, $tmpDirectoryName2, $tmpDirectoryPath2, $SkipVerification = $false)
#rm (remove file)
$commands = "mkdir $tmpDirectoryPath1
put $tmpFilePath1 $tmpDirectoryPath1
ls $tmpDirectoryPath1"
Set-Content $batchFilePath -Encoding UTF8 -value $commands
$str = $ExecutionContext.InvokeCommand.ExpandString(".\sftp $($Options) $($LogonStr) > $outputFilePath")
$client.RunCmd($str)
$outputFilePath | Should Contain ([RegEx]::Escape((join-path $tmpDirectoryPath1 $tmpFileName1).replace("\", "/")))
$commands = "rm $tmpDirectoryPath1\*
ls $tmpDirectoryPath1
pwd
"
Set-Content $batchFilePath -Encoding UTF8 -value $commands
$str = $ExecutionContext.InvokeCommand.ExpandString(".\sftp $($Options) $($LogonStr) > $outputFilePath")
$client.RunCmd($str)
$outputFilePath | Should Not Contain ([RegEx]::Escape((join-path $tmpDirectoryPath1 $tmpFileName1).replace("\", "/")))
#rename file
Remove-Item $outputFilePath
Copy-Item $tmpFilePath1 -destination $tmpDirectoryPath1
$commands = "rename $tmpDirectoryPath1\$tmpFileName1 $tmpDirectoryPath1\$tmpFileName2
ls $tmpDirectoryPath1
pwd"
Set-Content $batchFilePath -Encoding UTF8 -value $commands
$str = $ExecutionContext.InvokeCommand.ExpandString(".\sftp $($Options) $($LogonStr) > $outputFilePath")
$client.RunCmd($str)
$outputFilePath | Should Contain ([RegEx]::Escape((join-path $tmpDirectoryPath1 $tmpFileName2).replace("\", "/")))
#rename directory
Remove-Item $outputFilePath
$commands = "rm $tmpDirectoryPath1\*
rename $tmpDirectoryPath1 $tmpDirectoryPath2
ls $serverDirectory"
Set-Content $batchFilePath -Encoding UTF8 -value $commands
$str = $ExecutionContext.InvokeCommand.ExpandString(".\sftp $($Options) $($LogonStr) > $outputFilePath")
$client.RunCmd($str)
$outputFilePath | Should Contain ([RegEx]::Escape($tmpDirectoryPath2.replace("\", "/")))
#rmdir (remove directory)
Remove-Item $outputFilePath
$commands = "rmdir $tmpDirectoryPath2
ls $serverDirectory"
Set-Content $batchFilePath -Encoding UTF8 -value $commands
$str = $ExecutionContext.InvokeCommand.ExpandString(".\sftp $($Options) $($LogonStr) > $outputFilePath")
$client.RunCmd($str)
$outputFilePath | Should Not Contain ([RegEx]::Escape($tmpDirectoryPath2).replace("\", "/"))
}
}
}

View File

@ -14,9 +14,9 @@ Describe "Tests for ssh command" -Tags "CI" {
$testData = @(
@{
Title = 'Simple logon -v option';
Title = 'Simple logon no option';
LogonStr = "$($server.localAdminUserName)@$($server.MachineName)"
Options = "-v"
Options = ""
},
@{
Title = 'Simple logon using -C -l option'
@ -32,9 +32,9 @@ Describe "Tests for ssh command" -Tags "CI" {
Options = '-i $identifyFile -q'
},
@{
Title = "logon using -i -v option"
Title = "logon using -i option"
LogonStr = "$($server.localAdminUserName)@$($server.MachineName)"
Options = '-i $identifyFile -v'
Options = '-i $identifyFile'
},
@{
Title = "logon using -i -c option"

View File

@ -62,9 +62,7 @@ check(struct hostkey_foreach_line *l, void *_ctx)
test_subtest_info("entry %zu/%zu, file line %ld",
ctx->i + 1, ctx->nexpected, l->linenum);
for (;;) {
#ifndef WIN32_FIXME
//ASSERT_SIZE_T_LT(ctx->i, ctx->nexpected);
#endif
ASSERT_SIZE_T_LT(ctx->i, ctx->nexpected);
expected = ctx->expected + ctx->i++;
/* If we are matching host/IP then skip entries that don't */
if (!matching)
@ -114,7 +112,6 @@ check(struct hostkey_foreach_line *l, void *_ctx)
UPDATE_MATCH_STATUS(match_ipv6);
ASSERT_PTR_NE(l->path, NULL); /* Don't care about path */
#ifndef WIN32_FIXME
ASSERT_LONG_LONG_EQ(l->linenum, expected->l.linenum);
ASSERT_U_INT_EQ(l->status, expected_status);
ASSERT_U_INT_EQ(l->match, expected_match);
@ -140,7 +137,6 @@ check(struct hostkey_foreach_line *l, void *_ctx)
}
if (parse_key && !(l->comment == NULL && expected->l.comment == NULL))
ASSERT_STRING_EQ(l->comment, expected->l.comment);
#endif
return 0;
}
@ -285,7 +281,7 @@ struct expected expected_full[] = {
NULL, /* filled at runtime */
"DSA #2",
} },
#ifndef WIN32_FIXME
#ifdef OPENSSL_HAS_NISTP521
{ "ecdsa_2.pub" , -1, -1, HKF_MATCH_HOST, 0, HKF_MATCH_IP, HKF_MATCH_IP, -1, {
NULL,
10,
@ -812,7 +808,6 @@ struct expected expected_full[] = {
NULL, /* filled at runtime */
"ECDSA #4",
} },
#ifndef WIN32_FIXME
{ "dsa_4.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, 0, 0, -1, {
NULL,
50,
@ -826,7 +821,6 @@ struct expected expected_full[] = {
NULL, /* filled at runtime */
"DSA #4",
} },
#endif
{ NULL, -1, -1, 0, 0, 0, 0, -1, {
NULL,
51,

View File

@ -195,7 +195,7 @@ kex_tests(void)
#ifdef OPENSSL_HAS_ECC
do_kex("ecdh-sha2-nistp256");
do_kex("ecdh-sha2-nistp384");
#ifndef WIN32_FIXME
#ifdef OPENSSL_HAS_NISTP521
do_kex("ecdh-sha2-nistp521");
#endif
#endif

View File

@ -136,7 +136,7 @@ sshkey_file_tests(void)
ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
sshkey_free(k2);
TEST_DONE();
#ifndef WIN32_FIXME
TEST_START("parse RSA from new-format w/ passphrase");
buf = load_file("rsa_n_pw");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
@ -146,7 +146,7 @@ sshkey_file_tests(void)
ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
sshkey_free(k2);
TEST_DONE();
#endif
TEST_START("load RSA from public");
ASSERT_INT_EQ(sshkey_load_public(test_data_file("rsa_1.pub"), &k2,
NULL), 0);
@ -228,7 +228,6 @@ sshkey_file_tests(void)
sshkey_free(k2);
TEST_DONE();
#ifndef WIN32_FIXME
TEST_START("parse DSA from new-format w/ passphrase");
buf = load_file("dsa_n_pw");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
@ -238,7 +237,7 @@ sshkey_file_tests(void)
ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
sshkey_free(k2);
TEST_DONE();
#endif
TEST_START("load DSA from public");
ASSERT_INT_EQ(sshkey_load_public(test_data_file("dsa_1.pub"), &k2,
NULL), 0);
@ -327,7 +326,7 @@ sshkey_file_tests(void)
ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
sshkey_free(k2);
TEST_DONE();
#ifndef WIN32_FIXME
TEST_START("parse ECDSA from new-format w/ passphrase");
buf = load_file("ecdsa_n_pw");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
@ -337,7 +336,7 @@ sshkey_file_tests(void)
ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
sshkey_free(k2);
TEST_DONE();
#endif
TEST_START("load ECDSA from public");
ASSERT_INT_EQ(sshkey_load_public(test_data_file("ecdsa_1.pub"), &k2,
NULL), 0);
@ -384,7 +383,7 @@ sshkey_file_tests(void)
sshkey_free(k1);
#endif /* OPENSSL_HAS_ECC */
#ifndef WIN32_FIXME
TEST_START("parse Ed25519 from private");
buf = load_file("ed25519_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@ -451,5 +450,5 @@ sshkey_file_tests(void)
sshkey_free(k1);
sshbuf_free(pw);
#endif
}

View File

@ -269,7 +269,7 @@ sshkey_fuzz_tests(void)
fuzz_cleanup(fuzz);
TEST_DONE();
#endif
#ifndef WIN32_FIXME
TEST_START("fuzz Ed25519 private");
buf = load_file("ed25519_1");
fuzz = fuzz_begin(FUZZ_BASE64, sshbuf_mutable_ptr(buf),
@ -289,7 +289,7 @@ sshkey_fuzz_tests(void)
sshbuf_free(fuzzed);
fuzz_cleanup(fuzz);
TEST_DONE();
#endif
TEST_START("fuzz RSA public");
buf = load_file("rsa_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@ -333,7 +333,7 @@ sshkey_fuzz_tests(void)
sshkey_free(k1);
TEST_DONE();
#endif
#ifndef WIN32_FIXME
TEST_START("fuzz Ed25519 public");
buf = load_file("ed25519_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@ -347,7 +347,7 @@ sshkey_fuzz_tests(void)
public_fuzz(k1);
sshkey_free(k1);
TEST_DONE();
#endif
TEST_START("fuzz RSA sig");
buf = load_file("rsa_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@ -389,7 +389,7 @@ sshkey_fuzz_tests(void)
sshkey_free(k1);
TEST_DONE();
#endif
#ifndef WIN32_FIXME
TEST_START("fuzz Ed25519 sig");
buf = load_file("ed25519_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@ -397,7 +397,7 @@ sshkey_fuzz_tests(void)
sig_fuzz(k1, NULL);
sshkey_free(k1);
TEST_DONE();
#endif
/* XXX fuzz decoded new-format blobs too */
}

View File

@ -429,8 +429,7 @@ sshkey_tests(void)
#endif
sshkey_free(kf);
#ifndef WIN32_FIXME
TEST_START("certify key");
TEST_START("certify key");
ASSERT_INT_EQ(sshkey_load_public(test_data_file("ed25519_1.pub"),
&k1, NULL), 0);
k2 = get_private("ed25519_2");
@ -472,7 +471,6 @@ sshkey_tests(void)
sshkey_free(k3);
sshbuf_reset(b);
TEST_DONE();
#endif
TEST_START("sign and verify RSA");
k1 = get_private("rsa_1");
@ -512,7 +510,6 @@ sshkey_tests(void)
#ifdef OPENSSL_HAS_ECC
#ifndef WIN32_FIXME
TEST_START("sign and verify ECDSA");
k1 = get_private("ecdsa_1");
ASSERT_INT_EQ(sshkey_load_public(test_data_file("ecdsa_2.pub"), &k2,
@ -546,5 +543,4 @@ sshkey_tests(void)
sshbuf_free(b);
TEST_DONE();
#endif
#endif
}

View File

@ -116,12 +116,6 @@ static void *onerror_ctx = NULL;
static const char *data_dir = NULL;
static char subtest_info[512];
#ifndef WIN32_FIXME
void fatal(const char *fmt,...) {/*stub*/}
void logit(const char *fmt,...) {/*stub*/}
void debug3(const char *fmt,...) {/*stub*/}
#endif
int
main(int argc, char **argv)
{

View File

@ -59,12 +59,14 @@ tests(void)
{
char *loc;
#ifdef WINDOWS
TEST_START("not applicable to Windows yet");
TEST_DONE();
return;
#endif
TEST_START("utf8_setlocale");
#ifdef WIN32_FIXME
loc = setlocale(LC_CTYPE, "English");
#else
loc = setlocale(LC_CTYPE, "en_US.UTF-8");
#endif
ASSERT_PTR_NE(loc, NULL);
TEST_DONE();
@ -74,20 +76,14 @@ tests(void)
one("newline", "a\nb", -2, -2, -2, "a\nb");
one("cr", "a\rb", -2, -2, -2, "a\rb");
one("tab", "a\tb", -2, -2, -2, "a\tb");
#ifndef WIN32_FIXME
one("esc", "\033x", -2, -2, -2, "\\033x");
one("inv_badbyte", "\377x", -2, -2, -2, "\\377x");
one("inv_nocont", "\341x", -2, -2, -2, "\\341x");
one("inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
#endif
one("sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
#ifndef WIN32_FIXME
one("sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
#endif
one("width_ascii", "123", 2, 2, -1, "12");
one("width_double", "a\343\201\201", 2, 1, -1, "a");
#ifndef WIN32_FIXME
one("double_fit", "a\343\201\201", 3, 3, 4, "a\343\201\201");
one("double_spc", "a\343\201\201", 4, 3, 4, "a\343\201\201");
#endif
}

View File

@ -239,12 +239,10 @@ void console_io_test()
void
file_tests()
{
w32posix_initialize();
//console_io_test();
//file_simple_fileio();
file_blocking_io_tests();
file_nonblocking_io_tests();
file_select_tests();
w32posix_done();
}

View File

@ -387,7 +387,7 @@ socket_nonblocking_io_tests()
void
socket_select_tests() {
int s, r;
int num_bytes = 1024 * 700; //700KB
int num_bytes = 1024 * 1024 * 2; //2 MB
int bytes_sent = 0;
int bytes_received = 0;
int seed = 326;
@ -613,12 +613,10 @@ socket_typical_ssh_payload_tests() {
void
socket_tests()
{
w32posix_initialize();
socket_fd_tests();
socket_blocking_io_tests();
socket_nonblocking_io_tests();
socket_select_tests();
socket_typical_ssh_payload_tests();
w32posix_done();
}

4
scp.c
View File

@ -387,14 +387,12 @@ do_cmd2(char *host, char *remuser, char *cmd, int fdin, int fdout)
size_t cmdlen = 0;
char** list = args.list;
cmdlen = strlen(w32_programdir()) + 2;
cmdlen = 1; /* null term */
while (*list)
cmdlen += strlen(*list++) + 1;
full_cmd = xmalloc(cmdlen);
full_cmd[0] = '\0';
strcat(full_cmd, w32_programdir());
strcat(full_cmd, "\\");
list = args.list;
while (*list) {
strcat(full_cmd, *list++);

View File

@ -450,6 +450,9 @@ void setup_session_vars(Session* s)
free(pw_dir_w);
}
char* w32_programdir();
int register_child(void* child, unsigned long pid);
int do_exec_windows(Session *s, const char *command, int pty) {
int pipein[2], pipeout[2], pipeerr[2], r;
char *exec_command = NULL, *progdir = w32_programdir();
@ -548,9 +551,9 @@ int do_exec_windows(Session *s, const char *command, int pty) {
si.cbReserved2 = 0;
si.lpReserved2 = 0;
si.hStdInput = (HANDLE)sfd_to_handle(pipein[0]);
si.hStdOutput = (HANDLE)sfd_to_handle(pipeout[1]);
si.hStdError = (HANDLE)sfd_to_handle(pipeerr[1]);
si.hStdInput = (HANDLE)w32_fd_to_handle(pipein[0]);
si.hStdOutput = (HANDLE)w32_fd_to_handle(pipeout[1]);
si.hStdError = (HANDLE)w32_fd_to_handle(pipeerr[1]);
si.lpDesktop = NULL;
hToken = s->authctxt->methoddata;
@ -605,7 +608,7 @@ int do_exec_windows(Session *s, const char *command, int pty) {
CloseHandle(pi.hThread);
s->pid = pi.dwProcessId;
sw_add_child(pi.hProcess, pi.dwProcessId);
register_child(pi.hProcess, pi.dwProcessId);
}
/*
* Set interactive/non-interactive mode.

48
sftp.c
View File

@ -296,19 +296,16 @@ help(void)
/* printf version to account for utf-8 input */
/* TODO - merge this with vfmprint */
static void printf_utf8(char *fmt, ... ) {
/* TODO - is 1024 sufficient */
char buf[1024];
wchar_t* wtmp;
va_list valist;
va_start(valist, fmt);
/* TODO - is 1024 sufficient */
char buf[1024];
int length = 0;
va_list valist;
va_start(valist, fmt);
length = vsnprintf(buf, 1024, fmt, valist);
va_end(valist);
vsnprintf(buf, 1024, fmt, valist);
va_end(valist);
if ((wtmp = utf8_to_utf16(buf)) == NULL)
fatal("unable to allocate memory");
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
free(wtmp);
write(STDOUT_FILENO, buf, length);
}
/* override mprintf */
@ -931,11 +928,17 @@ do_ls_dir(struct sftp_conn *conn, const char *path,
#ifdef WINDOWS
/* cannot use printf_utf8 becuase of width specification */
/* printf_utf8 does not account for utf-16 based argument widths */
char *p = NULL;
wchar_t buf[1024];
wchar_t* wtmp = utf8_to_utf16(fname);
swprintf(buf, 1024, L"%-*s", colspace, wtmp);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), buf, wcslen(buf), 0, 0);
if ((p = utf16_to_utf8(buf)) == NULL)
continue;
write(STDOUT_FILENO, p, strlen(p));
free(wtmp);
free(p);
#else
mprintf("%-*s", colspace, fname);
#endif
@ -1025,11 +1028,17 @@ do_globbed_ls(struct sftp_conn *conn, const char *path,
#ifdef WINDOWS
/* cannot use printf_utf8 becuase of width specification */
/* printf_utf8 does not account for utf-16 based argument widths */
char *p = NULL;
wchar_t buf[1024];
wchar_t* wtmp = utf8_to_utf16(fname);
swprintf(buf, 1024, L"%-*s", colspace, wtmp);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), buf, wcslen(buf), 0, 0);
if ((p = utf16_to_utf8(buf)) == NULL)
continue;
write(STDOUT_FILENO, p, strlen(p));
free(wtmp);
free(p);
#else
mprintf("%-*s", colspace, fname);
#endif
@ -2199,17 +2208,22 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
free(dir);
}
interactive = !batchmode && isatty(STDIN_FILENO);
err = 0;
#ifdef WINDOWS
/* Min buffer size allowed in Windows is 2*/
setvbuf(stdout, NULL, _IOLBF, 2);
setvbuf(infile, NULL, _IOLBF, 2);
/* We do this only in interactive mode as we are unable to read files with UTF8 BOM */
if(interactive)
setvbuf(infile, NULL, _IOLBF, 2);
#else /* !WINDOWS */
setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf(infile, NULL, _IOLBF, 0);
#endif /* !WINDOWS */
interactive = !batchmode && isatty(STDIN_FILENO);
err = 0;
for (;;) {
char *cp;

4
sshd.c
View File

@ -1302,9 +1302,9 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
if (path_utf8 == NULL)
fatal("Failed to alloc memory");
if (snprintf(fd_handle, sizeof(fd_handle), "%p", sfd_to_handle(*newsock)) == -1
if (snprintf(fd_handle, sizeof(fd_handle), "%p", w32_fd_to_handle(*newsock)) == -1
|| SetEnvironmentVariable("SSHD_REMSOC", fd_handle) == FALSE
|| snprintf(fd_handle, sizeof(fd_handle), "%p", sfd_to_handle(startup_p[1])) == -1
|| snprintf(fd_handle, sizeof(fd_handle), "%p", w32_fd_to_handle(startup_p[1])) == -1
|| SetEnvironmentVariable("SSHD_STARTUPSOC", fd_handle) == FALSE
|| fcntl(startup_p[0], F_SETFD, FD_CLOEXEC) == -1) {
error("unable to set the right environment for child, closing connection ");