Skip to content

Commit bef0593

Browse files
committed
add sshd-auth project
1 parent a884a53 commit bef0593

File tree

8 files changed

+751
-55
lines changed

8 files changed

+751
-55
lines changed

contrib/win32/install/server.wxs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<Component>
1010
<File Name="ssh-shellhost.exe" KeyPath="yes" />
1111
</Component>
12+
<Component>
13+
<File Name="sshd-auth.exe" KeyPath="yes" />
14+
</Component>
1215
<Component>
1316
<File Name="sshd-session.exe" KeyPath="yes" />
1417
</Component>

contrib/win32/openssh/OpenSSHBuildHelper.psm1

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Import-Module $PSScriptRoot\OpenSSHCommonUtils.psm1 -Force
88
[bool] $script:Verbose = $false
99
[string] $script:BuildLogFile = $null
1010
<#
11-
Called by Write-BuildMsg to write to the build log, if it exists.
11+
Called by Write-BuildMsg to write to the build log, if it exists.
1212
#>
1313
function Write-Log
1414
{
@@ -22,7 +22,7 @@ function Write-Log
2222
if (-not ([string]::IsNullOrEmpty($script:BuildLogFile)))
2323
{
2424
Add-Content -Path $script:BuildLogFile -Value $Message
25-
}
25+
}
2626
}
2727

2828
<#
@@ -94,7 +94,7 @@ function Write-BuildMsg
9494
return
9595
}
9696

97-
if($PSBoundParameters.ContainsKey("AsInfo"))
97+
if($PSBoundParameters.ContainsKey("AsInfo"))
9898
{
9999
Write-Log -Message "INFO: $message"
100100
if (-not $Silent)
@@ -151,7 +151,7 @@ function Start-OpenSSHBootstrap
151151

152152
# Add git\cmd to the path
153153
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE')
154-
$newMachineEnvironmentPath = $machinePath
154+
$newMachineEnvironmentPath = $machinePath
155155
$gitCmdPath = "$env:ProgramFiles\git\cmd"
156156
if (-not ($machinePath.ToLower().Contains($gitCmdPath.ToLower())))
157157
{
@@ -171,10 +171,10 @@ function Start-OpenSSHBootstrap
171171
if ($newMachineEnvironmentPath -ne $machinePath)
172172
{
173173
[Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE')
174-
}
174+
}
175175

176176
$sdkVersion = Get-Windows10SDKVersion
177-
if ($null -eq $sdkVersion)
177+
if ($null -eq $sdkVersion)
178178
{
179179
Get-Chocolatey
180180
$packageName = "windows-sdk-10.1"
@@ -196,7 +196,7 @@ function Start-OpenSSHBootstrap
196196
else {
197197
$MSBuildPath = Get-VS2015BuildToolPath
198198
}
199-
if ($MSBuildPath | Select-String "2022")
199+
if ($MSBuildPath | Select-String "2022")
200200
{
201201
$env:vctargetspath = Join-Path $VisualStudioPath "MSBuild\Microsoft\VC\v170\"
202202
if ($null -eq $env:VS170COMNTOOLS)
@@ -205,11 +205,11 @@ function Start-OpenSSHBootstrap
205205
}
206206
elseif (-not (Test-Path $env:VS170COMNTOOLS))
207207
{
208-
Write-BuildMsg -AsError -ErrorAction Stop -Message "$env:VS170COMNTOOLS build tools path is invalid"
208+
Write-BuildMsg -AsError -ErrorAction Stop -Message "$env:VS170COMNTOOLS build tools path is invalid"
209209
}
210210
$VSBuildToolsPath = Get-Item(Join-Path $VisualStudioPath 'vc/auxiliary/build')
211211
}
212-
elseif ($MSBuildPath | Select-String "2019")
212+
elseif ($MSBuildPath | Select-String "2019")
213213
{
214214
$env:vctargetspath = Join-Path $VisualStudioPath "Common7\IDE\VC\VCTargets"
215215
Write-BuildMsg -AsVerbose -Message "Setting vctargetspath env var to ${env:vctargetspath}"
@@ -219,11 +219,11 @@ function Start-OpenSSHBootstrap
219219
}
220220
elseif (-not (Test-Path $env:VS160COMNTOOLS))
221221
{
222-
Write-BuildMsg -AsError -ErrorAction Stop -Message "$env:VS160COMNTOOLS build tools path is invalid"
222+
Write-BuildMsg -AsError -ErrorAction Stop -Message "$env:VS160COMNTOOLS build tools path is invalid"
223223
}
224224
$VSBuildToolsPath = Get-Item(Join-Path $VisualStudioPath 'vc/auxiliary/build')
225225
}
226-
elseif ($MSBuildPath | Select-String "2017")
226+
elseif ($MSBuildPath | Select-String "2017")
227227
{
228228
$env:vctargetspath = Join-Path $VisualStudioPath "Common7\IDE\VC\VCTargets"
229229
if ($null -eq $env:VS150COMNTOOLS)
@@ -232,11 +232,11 @@ function Start-OpenSSHBootstrap
232232
}
233233
elseif (-not (Test-Path $env:VS150COMNTOOLS))
234234
{
235-
Write-BuildMsg -AsError -ErrorAction Stop -Message "$env:VS150COMNTOOLS build tools path is invalid"
235+
Write-BuildMsg -AsError -ErrorAction Stop -Message "$env:VS150COMNTOOLS build tools path is invalid"
236236
}
237237
$VSBuildToolsPath = Get-Item(Join-Path $VisualStudioPath 'vc/auxiliary/build')
238238
}
239-
else
239+
else
240240
{
241241
if($NativeHostArch.ToLower().Startswith('arm'))
242242
{
@@ -246,7 +246,7 @@ function Start-OpenSSHBootstrap
246246

247247
$VSBuildToolsPath = Get-Item(Join-Path -Path $env:VS140COMNTOOLS -ChildPath '../../vc')
248248
Write-BuildMsg -AsVerbose -Message 'VC++ 2015 Build Tools already present.'
249-
249+
250250
if (!$MSBuildPath -or ($null -eq $env:VS140COMNTOOLS)) {
251251
Get-Chocolatey
252252
$packageName = "vcbuildtools"
@@ -287,15 +287,15 @@ function Start-OpenSSHBootstrap
287287
Write-BuildMsg -AsVerbose -Message "vcPath: $script:vcPath" -Silent:$silent
288288
if ((Test-Path -Path "$script:vcPath\vcvarsall.bat") -eq $false)
289289
{
290-
Write-BuildMsg -AsError -ErrorAction Stop -Message "Could not find Visual Studio vcvarsall.bat at $script:vcPath, which means some required develop kits are missing on the machine."
290+
Write-BuildMsg -AsError -ErrorAction Stop -Message "Could not find Visual Studio vcvarsall.bat at $script:vcPath, which means some required develop kits are missing on the machine."
291291
}
292292
}
293293

294294
function Start-OpenSSHPackage
295295
{
296-
[CmdletBinding(SupportsShouldProcess=$false)]
296+
[CmdletBinding(SupportsShouldProcess=$false)]
297297
param
298-
(
298+
(
299299
[ValidateSet('x86', 'x64', 'arm64', 'arm')]
300300
[string]$NativeHostArch = "x64",
301301

@@ -314,10 +314,10 @@ function Start-OpenSSHPackage
314314
if($NativeHostArch -ieq 'x86')
315315
{
316316
$folderName = "Win32"
317-
}
317+
}
318318

319319
$buildDir = Join-Path $repositoryRoot ("bin\" + $folderName + "\" + $Configuration)
320-
$payload = "sshd.exe", "sshd-session.exe", "ssh.exe", "ssh-agent.exe", "ssh-add.exe", "sftp.exe"
320+
$payload = "sshd.exe", "sshd-auth.exe", "sshd-session.exe", "ssh.exe", "ssh-agent.exe", "ssh-add.exe", "sftp.exe"
321321
$payload += "sftp-server.exe", "scp.exe", "ssh-shellhost.exe", "ssh-keygen.exe", "ssh-keyscan.exe", "ssh-sk-helper.exe", "ssh-pkcs11-helper.exe"
322322
$payload += "sshd_config_default", "install-sshd.ps1", "uninstall-sshd.ps1"
323323
$payload += "FixHostFilePermissions.ps1", "FixUserFilePermissions.ps1", "OpenSSHUtils.psm1", "OpenSSHUtils.psd1"
@@ -335,20 +335,20 @@ function Start-OpenSSHPackage
335335
}
336336

337337
while((($service = Get-Service ssh-agent -ErrorAction SilentlyContinue) -ne $null) -and ($service.Status -ine 'Stopped'))
338-
{
338+
{
339339
Stop-Service ssh-agent -Force
340-
#sleep to wait the servicelog file write
340+
#sleep to wait the servicelog file write
341341
Start-Sleep 5
342342
}
343343

344344
$packageDir = Join-Path $buildDir $packageName
345345
Remove-Item $packageDir -Recurse -Force -ErrorAction SilentlyContinue
346346
New-Item $packageDir -Type Directory | Out-Null
347-
347+
348348
$symbolsDir = Join-Path $buildDir ($packageName + '_Symbols')
349349
Remove-Item $symbolsDir -Recurse -Force -ErrorAction SilentlyContinue
350350
New-Item $symbolsDir -Type Directory | Out-Null
351-
351+
352352
foreach ($file in $payload) {
353353
if ((-not(Test-Path (Join-Path $buildDir $file)))) {
354354
Throw "Cannot find $file under $buildDir. Did you run Build-OpenSSH?"
@@ -367,7 +367,7 @@ function Start-OpenSSHPackage
367367
#copy libcrypto dll
368368
$libreSSLPath = Join-Path $PSScriptRoot "LibreSSL"
369369
if (-not $NoOpenSSL.IsPresent)
370-
{
370+
{
371371
if($OneCore)
372372
{
373373
Copy-Item -Path $(Join-Path $libreSSLPath "bin\onecore\$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
@@ -378,10 +378,10 @@ function Start-OpenSSHPackage
378378
Copy-Item -Path $(Join-Path $libreSSLPath "bin\desktop\$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
379379
Copy-Item -Path $(Join-Path $libreSSLPath "bin\desktop\$NativeHostArch\libcrypto.pdb") -Destination $symbolsDir -Force -ErrorAction Stop
380380
}
381-
}
381+
}
382382

383383
if ($DestinationPath -ne "") {
384-
if (Test-Path $DestinationPath) {
384+
if (Test-Path $DestinationPath) {
385385
Remove-Item $DestinationPath\* -Force -Recurse -ErrorAction SilentlyContinue
386386
}
387387
else {
@@ -403,7 +403,7 @@ function Start-OpenSSHPackage
403403
}
404404
}
405405
Remove-Item $packageDir -Recurse -Force -ErrorAction SilentlyContinue
406-
406+
407407
if ($DestinationPath -ne "") {
408408
Copy-Item -Path $symbolsDir\* -Destination $DestinationPath -Force -Recurse
409409
Write-BuildMsg -AsInfo -Message "Copied symbols to $DestinationPath"
@@ -425,9 +425,9 @@ function Start-OpenSSHPackage
425425

426426
function Copy-OpenSSHUnitTests
427427
{
428-
[CmdletBinding(SupportsShouldProcess=$false)]
428+
[CmdletBinding(SupportsShouldProcess=$false)]
429429
param
430-
(
430+
(
431431
[ValidateSet('x86', 'x64', 'arm64', 'arm')]
432432
[string]$NativeHostArch = "x64",
433433

@@ -447,18 +447,18 @@ function Copy-OpenSSHUnitTests
447447
}
448448
$buildDir = Join-Path $repositoryRoot ("bin\" + $folderName + "\" + $Configuration)
449449
$unittestsDir = Join-Path $buildDir "unittests"
450-
$unitTestFolders = Get-ChildItem -Directory $buildDir\unittest-*
451-
450+
$unitTestFolders = Get-ChildItem -Directory $buildDir\unittest-*
451+
452452
if ($DestinationPath -ne "") {
453453
if (-not (Test-Path $DestinationPath -PathType Container)) {
454454
New-Item -ItemType Directory $DestinationPath -Force | Out-Null
455455
}
456456
foreach ($folder in $unitTestFolders) {
457457
Copy-Item $folder.FullName $DestinationPath\$($folder.Name) -Recurse -Force
458458
Write-BuildMsg -AsInfo -Message "Copied $($folder.FullName) to $DestinationPath\$($folder.Name)."
459-
}
459+
}
460460
}
461-
else {
461+
else {
462462
if(Test-Path ($unittestsDir + '.zip') -PathType Leaf) {
463463
Remove-Item ($unittestsDir + '.zip') -Force -ErrorAction SilentlyContinue
464464
}
@@ -476,9 +476,9 @@ function Copy-OpenSSHUnitTests
476476

477477
function Start-OpenSSHBuild
478478
{
479-
[CmdletBinding(SupportsShouldProcess=$false)]
479+
[CmdletBinding(SupportsShouldProcess=$false)]
480480
param
481-
(
481+
(
482482
[ValidateSet('x86', 'x64', 'arm64', 'arm')]
483483
[string]$NativeHostArch = "x64",
484484

@@ -488,7 +488,7 @@ function Start-OpenSSHBuild
488488
[switch]$NoOpenSSL,
489489

490490
[switch]$OneCore
491-
)
491+
)
492492
$script:BuildLogFile = $null
493493

494494
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
@@ -512,8 +512,8 @@ function Start-OpenSSHBuild
512512
Start-OpenSSHBootstrap -NativeHostArch $NativeHostArch -OneCore:$OneCore
513513

514514
$PathTargets = Join-Path -Path $PSScriptRoot -ChildPath 'paths.targets'
515-
if ($NoOpenSSL)
516-
{
515+
if ($NoOpenSSL)
516+
{
517517
[XML]$xml = Get-Content $PathTargets
518518
$xml.Project.PropertyGroup.UseOpenSSL = 'false'
519519
$xml.Project.PropertyGroup.SSLLib = [string]::Empty
@@ -523,11 +523,11 @@ function Start-OpenSSHBuild
523523
(Get-Content $f).Replace('#define OPENSSL_HAS_ECC 1','') | Set-Content $f
524524
(Get-Content $f).Replace('#define OPENSSL_HAS_NISTP521 1','') | Set-Content $f
525525
}
526-
526+
527527
$win10SDKVer = Get-Windows10SDKVersion
528528
[XML]$xml = Get-Content $PathTargets
529529
$xml.Project.PropertyGroup.WindowsSDKVersion = $win10SDKVer.ToString()
530-
530+
531531
if($NativeHostArch.ToLower().Startswith('arm'))
532532
{
533533
$arch = $NativeHostArch.ToUpper()
@@ -538,7 +538,7 @@ function Start-OpenSSHBuild
538538
$newElement =$xml.CreateElement($nodeName, $xml.Project.xmlns)
539539
$newNode = $xml.Project.PropertyGroup.AppendChild($newElement)
540540
$null = $newNode.AppendChild($xml.CreateTextNode("true"))
541-
}
541+
}
542542
else
543543
{
544544
$node.InnerText = "true"
@@ -553,18 +553,18 @@ function Start-OpenSSHBuild
553553
$xml.Project.PropertyGroup.WindowsSDKVersion = $win10SDKVer
554554
$xml.Project.PropertyGroup.AdditionalDependentLibs = 'onecore.lib;shlwapi.lib'
555555
$xml.Project.PropertyGroup.MinimalCoreWin = 'true'
556-
556+
557557
#Use onecore libcrypto binaries
558558
$xml.Project.PropertyGroup."LibreSSL-x86-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\x86\'
559559
$xml.Project.PropertyGroup."LibreSSL-x64-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\x64\'
560560
$xml.Project.PropertyGroup."LibreSSL-arm-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\arm\'
561561
$xml.Project.PropertyGroup."LibreSSL-arm64-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\arm64\'
562-
562+
563563
$xml.Save($PathTargets)
564564
}
565-
565+
566566
$solutionFile = Get-SolutionFile -root $repositoryRoot.FullName
567-
$cmdMsg = @("${solutionFile}", "/t:Rebuild", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/m", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
567+
$cmdMsg = @("${solutionFile}", "/t:Rebuild", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/m", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
568568
if($silent)
569569
{
570570
$cmdMsg += "/noconlog"
@@ -588,7 +588,7 @@ function Start-OpenSSHBuild
588588
if ($errorCode -ne 0)
589589
{
590590
Write-BuildMsg -AsError -ErrorAction Stop -Message "Build failed for OpenSSH.`nExitCode: $errorCode."
591-
}
591+
}
592592

593593
Write-BuildMsg -AsInfo -Message "SSH build successful."
594594
}
@@ -683,13 +683,13 @@ function Get-BuildToolPath
683683
if (-not (Test-Path($buildToolsPath)))
684684
{
685685
Write-BuildMsg -AsError -ErrorAction Stop -Message "$packageName installation failed with error code $LASTEXITCODE."
686-
}
687-
}
686+
}
687+
}
688688
return $buildToolsPath
689689
}
690690

691691
function Get-Windows10SDKVersion
692-
{
692+
{
693693
## Search for latest windows sdk available on the machine
694694
$windowsSDKPath = Join-Path ${env:ProgramFiles(x86)} "Windows Kits\10\Lib"
695695
$minSDKVersion = [version]"10.0.17763.0"
@@ -719,7 +719,7 @@ function Get-BuildLogFile
719719

720720
[ValidateSet('x86', 'x64', 'arm64', 'arm')]
721721
[string]$NativeHostArch = "x64",
722-
722+
723723
[ValidateSet('Debug', 'Release')]
724724
[string]$Configuration = "Release"
725725
)
@@ -738,7 +738,7 @@ function Get-SolutionFile
738738
[Parameter(Mandatory=$true)]
739739
[ValidateNotNull()]
740740
[System.IO.DirectoryInfo] $root
741-
)
741+
)
742742
if ($root.FullName -ieq $PSScriptRoot)
743743
{
744744
return Join-Path -Path $PSScriptRoot -ChildPath "Win32-OpenSSH.sln"
@@ -761,7 +761,7 @@ function Get-Chocolatey {
761761
}
762762

763763
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE')
764-
$newMachineEnvironmentPath = $machinePath
764+
$newMachineEnvironmentPath = $machinePath
765765

766766
if (-not ($machinePath.ToLower().Contains($chocolateyPath.ToLower())))
767767
{
@@ -781,7 +781,7 @@ function Get-Chocolatey {
781781
if ($newMachineEnvironmentPath -ne $machinePath)
782782
{
783783
[Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE')
784-
}
784+
}
785785
}
786786

787787
Export-ModuleMember -Function Start-OpenSSHBuild, Get-BuildLogFile, Start-OpenSSHPackage, Copy-OpenSSHUnitTests

0 commit comments

Comments
 (0)