Skip to content

Commit dbbe15a

Browse files
committed
Source snapshot from Powershell/openssh-portable:latestw_all
1 parent 0a83df7 commit dbbe15a

29 files changed

+794
-348
lines changed

auth-passwd.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ sys_auth_passwd(Authctxt *authctxt, const char *password)
231231

232232
#elif defined(WINDOWS)
233233
HANDLE password_auth_token = NULL;
234-
HANDLE process_custom_lsa_auth(char*, const char*, char*);
234+
HANDLE process_custom_lsa_auth(const char*, const char*, const char*);
235235

236236
void
237237
sys_auth_passwd_lsa(Authctxt *authctxt, const char *password)
@@ -253,8 +253,7 @@ sys_auth_passwd_lsa(Authctxt *authctxt, const char *password)
253253
lsa_auth_pkg = utf16_to_utf8(lsa_auth_pkg_w);
254254
if (!lsa_auth_pkg)
255255
fatal("utf16_to_utf8 failed to convert lsa_auth_pkg_w:%ls", lsa_auth_pkg_w);
256-
257-
debug("Authenticating using LSA Auth Package:%ls", lsa_auth_pkg_w);
256+
258257
password_auth_token = process_custom_lsa_auth(authctxt->pw->pw_name, password, lsa_auth_pkg);
259258
}
260259
}

auth.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ expand_authorized_keys(const char *filename, struct passwd *pw)
430430

431431
#ifdef WINDOWS
432432
/* Return if the path is absolute. If not, prepend the '%h\\' */
433-
if ((strlen(file) > 1) && (file[1] == ':'))
433+
if(is_absolute_path(file))
434434
return (file);
435435

436436
i = snprintf(ret, sizeof(ret), "%s\\%s", pw->pw_dir, file);

channels.c

-2
Original file line numberDiff line numberDiff line change
@@ -3950,8 +3950,6 @@ channel_disable_adm_local_opens(struct ssh *ssh)
39503950
void
39513951
channel_clear_permitted_opens(struct ssh *ssh)
39523952
{
3953-
if(ssh == NULL)
3954-
return;
39553953
struct ssh_channels *sc = ssh->chanctxt;
39563954

39573955
sc->permitted_opens = xrecallocarray(sc->permitted_opens,

contrib/win32/openssh/OpenSSHBuildHelper.psm1

+51-26
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ function Start-OpenSSHBootstrap
197197
Write-BuildMsg -AsVerbose -Message "$gitCmdPath already present in Path environment variable" -Silent:$silent
198198
}
199199

200-
$nativeMSBuildPath = Get-VS2015BuildToolPath
200+
$VS2015Path = Get-VS2015BuildToolPath
201+
$VS2017Path = Get-VS2017BuildToolPath
201202

202203
# Update machine environment path
203204
if ($newMachineEnvironmentPath -ne $machinePath)
@@ -206,9 +207,24 @@ function Start-OpenSSHBootstrap
206207
}
207208

208209
$vcVars = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat"
209-
$sdkPath = "${env:ProgramFiles(x86)}\Windows Kits\8.1\bin\x86\register_app.vbs"
210-
$packageName = "vcbuildtools"
211-
If (($nativeMSBuildPath -eq $null) -or (-not (Test-Path $VcVars)) -or (-not (Test-Path $sdkPath))) {
210+
$sdkPath = "${env:ProgramFiles(x86)}\Windows Kits\8.1\bin\x86\register_app.vbs"
211+
#use vs2017 build tool if exists
212+
if($VS2017Path -ne $null)
213+
{
214+
If (-not (Test-Path $sdkPath))
215+
{
216+
$packageName = "windows-sdk-8.1"
217+
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName ..."
218+
choco install $packageName -y --force --limitoutput --execution-timeout 10000 2>&1 >> $script:BuildLogFile
219+
}
220+
221+
if(-not (Test-Path $VcVars))
222+
{
223+
Write-BuildMsg -AsError -ErrorAction Stop -Message "VC++ 2015.3 v140 toolset are not installed."
224+
}
225+
}
226+
elseIf (($VS2015Path -eq $null) -or (-not (Test-Path $VcVars)) -or (-not (Test-Path $sdkPath))) {
227+
$packageName = "vcbuildtools"
212228
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName ..."
213229
choco install $packageName -ia "/InstallSelectableItems VisualCppBuildTools_ATLMFC_SDK;VisualCppBuildTools_NETFX_SDK;Win81SDK_CppBuildSKUV1" -y --force --limitoutput --execution-timeout 10000 2>&1 >> $script:BuildLogFile
214230
$errorCode = $LASTEXITCODE
@@ -234,24 +250,21 @@ function Start-OpenSSHBootstrap
234250
Write-BuildMsg -AsError -ErrorAction Stop -Message "User choose not to restart the machine to apply the changes."
235251
}
236252
}
237-
else
253+
elseif($errorCode -ne 0)
238254
{
239-
Write-BuildMsg -AsError -ErrorAction Stop -Message "$packageName installation failed with error code $errorCode"
255+
Write-BuildMsg -AsError -ErrorAction Stop -Message "$packageName installation failed with error code $errorCode."
240256
}
241257
}
242258
else
243259
{
244260
Write-BuildMsg -AsVerbose -Message 'VC++ 2015 Build Tools already present.'
245261
}
246262

247-
if($NativeHostArch.ToLower().Startswith('arm'))
248-
{
249-
$nativeMSBuildPath = Get-VS2017BuildToolPath
250-
If ($nativeMSBuildPath -eq $null)
251-
{
252-
#todo, install vs 2017 build tools
253-
Write-BuildMsg -AsError -ErrorAction Stop -Message "The required msbuild 15.0 is not installed on the machine."
254-
}
263+
if($NativeHostArch.ToLower().Startswith('arm') -and ($VS2017Path -eq $null))
264+
{
265+
266+
#todo, install vs 2017 build tools
267+
Write-BuildMsg -AsError -ErrorAction Stop -Message "The required msbuild 15.0 is not installed on the machine."
255268
}
256269

257270
if($OneCore -or ($NativeHostArch.ToLower().Startswith('arm')))
@@ -268,7 +281,7 @@ function Start-OpenSSHBootstrap
268281
# Ensure the VS C toolset is installed
269282
if ($null -eq $env:VS140COMNTOOLS)
270283
{
271-
Write-BuildMsg -AsError -ErrorAction Stop -Message "Cannot find Visual Studio 2015 Environment variable VS140COMNTOOlS"
284+
Write-BuildMsg -AsError -ErrorAction Stop -Message "Cannot find Visual Studio 2015 Environment variable VS140COMNTOOlS."
272285
}
273286

274287
$item = Get-Item(Join-Path -Path $env:VS140COMNTOOLS -ChildPath '../../vc')
@@ -314,7 +327,7 @@ function Copy-LibreSSLSDK
314327
Copy-Item -Container -Path $sourcePath -Destination $PSScriptRoot -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable e
315328
if($e -ne $null)
316329
{
317-
Write-BuildMsg -AsError -ErrorAction Stop -Message "Copy LibreSSLSDK from $sourcePath to $PSScriptRoot failed"
330+
Write-BuildMsg -AsError -ErrorAction Stop -Message "Copy LibreSSLSDK from $sourcePath to $PSScriptRoot failed."
318331
}
319332
}
320333

@@ -330,7 +343,8 @@ function Start-OpenSSHPackage
330343
[string]$Configuration = "Release",
331344

332345
# Copy payload to DestinationPath instead of packaging
333-
[string]$DestinationPath = ""
346+
[string]$DestinationPath = "",
347+
[switch]$NoOpenSSL
334348
)
335349

336350
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
@@ -390,7 +404,10 @@ function Start-OpenSSHPackage
390404

391405
#copy libcrypto dll
392406
$libreSSLSDKPath = Join-Path $PSScriptRoot $script:libreSSLSDKStr
393-
Copy-Item -Path $(Join-Path $libreSSLSDKPath "$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
407+
if (-not $NoOpenSSL.IsPresent)
408+
{
409+
Copy-Item -Path $(Join-Path $libreSSLSDKPath "$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
410+
}
394411

395412
if ($DestinationPath -ne "") {
396413
if (Test-Path $DestinationPath) {
@@ -400,7 +417,7 @@ function Start-OpenSSHPackage
400417
New-Item -ItemType Directory $DestinationPath -Force | Out-Null
401418
}
402419
Copy-Item -Path $packageDir\* -Destination $DestinationPath -Force -Recurse
403-
Write-BuildMsg -AsInfo -Message "Copied payload to $DestinationPath"
420+
Write-BuildMsg -AsInfo -Message "Copied payload to $DestinationPath."
404421
}
405422
else {
406423
Remove-Item ($packageDir + '.zip') -Force -ErrorAction SilentlyContinue
@@ -411,7 +428,7 @@ function Start-OpenSSHPackage
411428
}
412429
else
413430
{
414-
Write-BuildMsg -AsInfo -Message "Packaged Payload not compressed."
431+
Write-BuildMsg -AsInfo -Message "Packaged Payload not compressed."
415432
}
416433
}
417434
Remove-Item $packageDir -Recurse -Force -ErrorAction SilentlyContinue
@@ -470,7 +487,7 @@ function Start-OpenSSHBuild
470487
Remove-Item -Path $script:BuildLogFile -force
471488
}
472489

473-
Write-BuildMsg -AsInfo -Message "Starting Open SSH build; Build Log: $($script:BuildLogFile)"
490+
Write-BuildMsg -AsInfo -Message "Starting Open SSH build; Build Log: $($script:BuildLogFile)."
474491

475492
Start-OpenSSHBootstrap -OneCore:$OneCore
476493

@@ -523,17 +540,25 @@ function Start-OpenSSHBuild
523540
$xml.Project.PropertyGroup.WindowsSDKVersion = $win10SDKVer.ToString()
524541
$xml.Project.PropertyGroup.AdditionalDependentLibs = 'onecore.lib'
525542
$xml.Project.PropertyGroup.MinimalCoreWin = 'true'
543+
544+
#Use onecore libcrypto binaries
545+
$xml.Project.PropertyGroup."LibreSSL-x86-Path" = '$(SolutionDir)\LibreSSLSDK\onecore\x86\'
546+
$xml.Project.PropertyGroup."LibreSSL-x64-Path" = '$(SolutionDir)\LibreSSLSDK\onecore\x64\'
547+
$xml.Project.PropertyGroup."LibreSSL-arm-Path" = '$(SolutionDir)\LibreSSLSDK\onecore\arm\'
548+
$xml.Project.PropertyGroup."LibreSSL-arm64-Path" = '$(SolutionDir)\LibreSSLSDK\onecore\arm64\'
549+
526550
$xml.Save($PathTargets)
527551
}
528552

529553
$solutionFile = Get-SolutionFile -root $repositoryRoot.FullName
530-
$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/m", "/noconlog", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
531-
532-
if($NativeHostArch.ToLower().Startswith('arm'))
554+
$cmdMsg = @("${solutionFile}", "/t:Rebuild", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/m", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
555+
if($silent)
533556
{
534-
$msbuildCmd = Get-VS2017BuildToolPath
557+
$cmdMsg += "/noconlog"
535558
}
536-
else
559+
560+
$msbuildCmd = Get-VS2017BuildToolPath
561+
if($msbuildCmd -eq $null)
537562
{
538563
$msbuildCmd = Get-VS2015BuildToolPath
539564
}

contrib/win32/openssh/OpenSSHTestHelper.psm1

+8-2
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,14 @@ WARNING: Following changes will be made to OpenSSH configuration
162162
New-Item -ItemType Directory -Path $TestDataPath -Force -ErrorAction SilentlyContinue | out-null
163163
}
164164

165-
#Backup existing OpenSSH configuration
165+
166+
if(-not (Test-Path $OpenSSHConfigPath -pathType Container))
167+
{
168+
#starting the service will create ssh config folder
169+
start-service sshd
170+
}
166171
$backupConfigPath = Join-Path $OpenSSHConfigPath sshd_config.ori
172+
#Backup existing OpenSSH configuration
167173
if (-not (Test-Path $backupConfigPath -PathType Leaf)) {
168174
Copy-Item (Join-Path $OpenSSHConfigPath sshd_config) $backupConfigPath -Force
169175
}
@@ -244,7 +250,7 @@ WARNING: Following changes will be made to OpenSSH configuration
244250
$authorizedKeyPath = Join-Path $ssouserProfile .ssh\authorized_keys
245251
$testPubKeyPath = Join-Path $Script:E2ETestDirectory sshtest_userssokey_ed25519.pub
246252
Copy-Item $testPubKeyPath $authorizedKeyPath -Force -ErrorAction SilentlyContinue
247-
Repair-AuthorizedKeyPermission -FilePath $authorizedKeyPath -confirm:$false
253+
Repair-AuthorizedKeyPermission -FilePath $authorizedKeyPath -confirm:$false
248254

249255
copy-item (Join-Path $Script:E2ETestDirectory sshtest_userssokey_ed25519) $Global:OpenSSHTestInfo["TestDataPath"]
250256
$testPriKeypath = Join-Path $Global:OpenSSHTestInfo["TestDataPath"] sshtest_userssokey_ed25519

contrib/win32/openssh/config.h.vs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@
15651565
#define _PATH_PASSWD_PROG "/usr/bin/passwd"
15661566

15671567
/* Specify location of ssh.pid */
1568-
#define _PATH_SSH_PIDDIR "."
1568+
/* #undef _PATH_SSH_PIDDIR */
15691569

15701570
/* Define if we don't have struct __res_state in resolv.h */
15711571
#define __res_state state
@@ -1693,6 +1693,7 @@
16931693

16941694
#define _PATH_PRIVSEP_CHROOT_DIR "."
16951695
#define SSHDIR "__PROGRAMDATA__\\ssh"
1696+
#define _PATH_SSH_PIDDIR SSHDIR
16961697
#define _PATH_SFTP_SERVER "sftp-server.exe"
16971698
#define _PATH_SSH_PROGRAM "ssh.exe"
16981699
#define _PATH_LS "dir"

contrib/win32/openssh/paths.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<UseOpenSSL>true</UseOpenSSL>
1313
<SSLLib>libcrypto.lib;</SSLLib>
1414
<WindowsSDKVersion>8.1</WindowsSDKVersion>
15-
<AdditionalDependentLibs>bcrypt.lib;Userenv.lib;Crypt32.lib;Ws2_32.lib;Secur32.lib;Shlwapi.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;Netapi32.lib;Rpcrt4.lib</AdditionalDependentLibs>
15+
<AdditionalDependentLibs>bcrypt.lib;Userenv.lib;Crypt32.lib;Ws2_32.lib;Secur32.lib;Shlwapi.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;Netapi32.lib;Rpcrt4.lib;ntdll.lib</AdditionalDependentLibs>
1616
<MinimalCoreWin>false</MinimalCoreWin>
1717
</PropertyGroup>
1818
</Project>

contrib/win32/openssh/ssh-add-hostkey.ps1

-96
This file was deleted.

contrib/win32/openssh/sshd_config

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#ListenAddress 0.0.0.0
1212
#ListenAddress ::
1313

14-
#HostKey /etc/ssh/ssh_host_rsa_key
15-
#HostKey /etc/ssh/ssh_host_dsa_key
16-
#HostKey /etc/ssh/ssh_host_ecdsa_key
17-
#HostKey /etc/ssh/ssh_host_ed25519_key
14+
#HostKey __PROGRAMDATA__/ssh/ssh_host_rsa_key
15+
#HostKey __PROGRAMDATA__/ssh/ssh_host_dsa_key
16+
#HostKey __PROGRAMDATA__/ssh/ssh_host_ecdsa_key
17+
#HostKey __PROGRAMDATA__/ssh/ssh_host_ed25519_key
1818

1919
# Ciphers and keying
2020
#RekeyLimit default none
@@ -39,7 +39,7 @@ AuthorizedKeysFile .ssh/authorized_keys
3939

4040
#AuthorizedPrincipalsFile none
4141

42-
# For this to work you will also need host keys in %windir%/programdata/openssh/config/ssh_known_hosts
42+
# For this to work you will also need host keys in %programData%/ssh/ssh_known_hosts
4343
#HostbasedAuthentication no
4444
# Change to yes if you don't trust ~/.ssh/known_hosts for
4545
# HostbasedAuthentication

contrib/win32/openssh/version.rc

-1.96 KB
Binary file not shown.

0 commit comments

Comments
 (0)