Skip to content

Commit 776483f

Browse files
committed
Source snapshot from Powershell/openssh-portable:latestw_all
1 parent c8b8c4b commit 776483f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1045
-655
lines changed

appveyor.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ build_script:
1616
1717
after_build:
1818
- ps: |
19+
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
1920
Install-OpenSSH
2021
- ps: Write-Verbose "Restart computer ..."
2122
- ps: Restart-Computer -Force
@@ -37,8 +38,10 @@ test_script:
3738
3839
after_test:
3940
- ps: |
41+
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
4042
Upload-OpenSSHTestResults
4143
4244
on_finish:
4345
- ps: |
46+
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
4447
Publish-Artifact

auth-pam.c

+2
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,8 @@ fake_password(const char *wire_password)
830830
fatal("%s: password length too long: %zu", __func__, l);
831831

832832
ret = malloc(l + 1);
833+
if (ret == NULL)
834+
return NULL;
833835
for (i = 0; i < l; i++)
834836
ret[i] = junk[i % (sizeof(junk) - 1)];
835837
ret[i] = '\0';

authfd.c

-49
Original file line numberDiff line numberDiff line change
@@ -94,54 +94,6 @@ ssh_get_authentication_socket(int *fdp)
9494
if (fdp != NULL)
9595
*fdp = -1;
9696

97-
#ifdef WINDOWS
98-
/* Auth socket in Windows is a static-named pipe listener in ssh-agent */
99-
{
100-
HKEY agent_root = 0;
101-
DWORD agent_pid = 0, tmp_size = 4, pipe_server_pid = 0xff;
102-
DWORD connection_attempts = 0;
103-
HANDLE h;
104-
RegOpenKeyExW(HKEY_LOCAL_MACHINE, SSH_AGENT_REG_ROOT,
105-
0, KEY_QUERY_VALUE, &agent_root);
106-
if (agent_root) {
107-
RegQueryValueEx(agent_root, "ProcessId", 0,
108-
NULL, (LPBYTE)&agent_pid, &tmp_size);
109-
RegCloseKey(agent_root);
110-
}
111-
112-
do {
113-
h = CreateFileW(SSH_AGENT_PIPE_NAME, GENERIC_READ | GENERIC_WRITE, 0,
114-
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
115-
if (h != INVALID_HANDLE_VALUE || GetLastError() != ERROR_PIPE_BUSY ||
116-
++connection_attempts > 10)
117-
break;
118-
Sleep(100);
119-
} while(1);
120-
121-
if (h == INVALID_HANDLE_VALUE) {
122-
debug("ssh_get_authentication_socket - CreateFileW failed error %d",
123-
GetLastError());
124-
return SSH_ERR_AGENT_NOT_PRESENT;
125-
}
126-
127-
/*
128-
* ensure that connected server pid matches published pid.
129-
* this provides service side auth and prevents mitm
130-
*/
131-
if (!GetNamedPipeServerProcessId(h, &pipe_server_pid) ||
132-
(agent_pid != pipe_server_pid)) {
133-
debug("agent pid mismatch");
134-
CloseHandle(h);
135-
return SSH_ERR_AGENT_COMMUNICATION;
136-
}
137-
138-
/* alloc fd for pipe handle */
139-
if ((sock = w32_allocate_fd_for_handle(h, FALSE)) < 0) {
140-
CloseHandle(h);
141-
return SSH_ERR_SYSTEM_ERROR;
142-
}
143-
}
144-
#else /* !WINDOWS */
14597
authsocket = getenv(SSH_AUTHSOCKET_ENV_NAME);
14698
if (!authsocket)
14799
return SSH_ERR_AGENT_NOT_PRESENT;
@@ -161,7 +113,6 @@ ssh_get_authentication_socket(int *fdp)
161113
errno = oerrno;
162114
return SSH_ERR_SYSTEM_ERROR;
163115
}
164-
#endif /* !WINDOWS */
165116

166117
if (fdp != NULL)
167118
*fdp = sock;

authfd.h

-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,5 @@ int ssh_agent_sign(int sock, struct sshkey *key,
9696
#define SSH_AGENT_AUTHENTICATE 200
9797
#define PUBKEY_AUTH_REQUEST "pubkey"
9898
#define PASSWD_AUTH_REQUEST "password"
99-
#define SSH_AGENT_REG_ROOT L"SOFTWARE\\SSH\\Agent"
100-
#define SSH_AGENT_PIPE_NAME L"\\\\.\\pipe\\ssh-agent"
10199

102100
#endif /* AUTHFD_H */

channels.c

+41-7
Original file line numberDiff line numberDiff line change
@@ -4375,6 +4375,33 @@ connect_local_xsocket(u_int dnr)
43754375
return connect_local_xsocket_path(buf);
43764376
}
43774377

4378+
#ifdef __APPLE__
4379+
static int
4380+
is_path_to_xsocket(const char *display, char *path, size_t pathlen)
4381+
{
4382+
struct stat sbuf;
4383+
4384+
if (strlcpy(path, display, pathlen) >= pathlen) {
4385+
error("%s: display path too long", __func__);
4386+
return 0;
4387+
}
4388+
if (display[0] != '/')
4389+
return 0;
4390+
if (stat(path, &sbuf) == 0) {
4391+
return 1;
4392+
} else {
4393+
char *dot = strrchr(path, '.');
4394+
if (dot != NULL) {
4395+
*dot = '\0';
4396+
if (stat(path, &sbuf) == 0) {
4397+
return 1;
4398+
}
4399+
}
4400+
}
4401+
return 0;
4402+
}
4403+
#endif
4404+
43784405
int
43794406
x11_connect_display(void)
43804407
{
@@ -4396,15 +4423,22 @@ x11_connect_display(void)
43964423
* connection to the real X server.
43974424
*/
43984425

4399-
/* Check if the display is from launchd. */
44004426
#ifdef __APPLE__
4401-
if (strncmp(display, "/tmp/launch", 11) == 0) {
4402-
sock = connect_local_xsocket_path(display);
4403-
if (sock < 0)
4404-
return -1;
4427+
/* Check if display is a path to a socket (as set by launchd). */
4428+
{
4429+
char path[PATH_MAX];
44054430

4406-
/* OK, we now have a connection to the display. */
4407-
return sock;
4431+
if (is_path_to_xsocket(display, path, sizeof(path))) {
4432+
debug("x11_connect_display: $DISPLAY is launchd");
4433+
4434+
/* Create a socket. */
4435+
sock = connect_local_xsocket_path(path);
4436+
if (sock < 0)
4437+
return -1;
4438+
4439+
/* OK, we now have a connection to the display. */
4440+
return sock;
4441+
}
44084442
}
44094443
#endif
44104444
/*

clientloop.c

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: clientloop.c,v 1.290 2017/01/29 21:35:23 dtucker Exp $ */
1+
/* $OpenBSD: clientloop.c,v 1.291 2017/03/10 05:01:13 djm Exp $ */
22
/*
33
* Author: Tatu Ylonen <[email protected]>
44
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
@@ -2394,6 +2394,26 @@ client_global_hostkeys_private_confirm(int type, u_int32_t seq, void *_ctx)
23942394
hostkeys_update_ctx_free(ctx);
23952395
}
23962396

2397+
/*
2398+
* Returns non-zero if the key is accepted by HostkeyAlgorithms.
2399+
* Made slightly less trivial by the multiple RSA signature algorithm names.
2400+
*/
2401+
static int
2402+
key_accepted_by_hostkeyalgs(const struct sshkey *key)
2403+
{
2404+
const char *ktype = sshkey_ssh_name(key);
2405+
const char *hostkeyalgs = options.hostkeyalgorithms != NULL ?
2406+
options.hostkeyalgorithms : KEX_DEFAULT_PK_ALG;
2407+
2408+
if (key == NULL || key->type == KEY_UNSPEC)
2409+
return 0;
2410+
if (key->type == KEY_RSA &&
2411+
(match_pattern_list("rsa-sha2-256", hostkeyalgs, 0) == 1 ||
2412+
match_pattern_list("rsa-sha2-512", hostkeyalgs, 0) == 1))
2413+
return 1;
2414+
return match_pattern_list(ktype, hostkeyalgs, 0) == 1;
2415+
}
2416+
23972417
/*
23982418
* Handle [email protected] global request to inform the client of all
23992419
* the server's hostkeys. The keys are checked against the user's
@@ -2440,10 +2460,7 @@ client_input_hostkeys(void)
24402460
sshkey_type(key), fp);
24412461
free(fp);
24422462

2443-
/* Check that the key is accepted in HostkeyAlgorithms */
2444-
if (match_pattern_list(sshkey_ssh_name(key),
2445-
options.hostkeyalgorithms ? options.hostkeyalgorithms :
2446-
KEX_DEFAULT_PK_ALG, 0) != 1) {
2463+
if (!key_accepted_by_hostkeyalgs(key)) {
24472464
debug3("%s: %s key not permitted by HostkeyAlgorithms",
24482465
__func__, sshkey_ssh_name(key));
24492466
continue;

contrib/win32/openssh/appveyor.psm1

+17-12
Original file line numberDiff line numberDiff line change
@@ -497,16 +497,16 @@ function Deploy-OpenSSHTests
497497
else
498498
{
499499
$RealConfiguration = $Configuration
500-
}
501-
500+
}
502501

503502
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
504503
#copy all pester tests
505504
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "regress\pesterTests"
506505
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Include *.ps1,*.psm1, sshd_config -Force -ErrorAction Stop
507506
#copy all unit tests.
508-
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
509-
Copy-Item -Path "$sourceDir\unittest-*" -Destination $OpenSSHTestDir -Force -ErrorAction Stop
507+
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
508+
Copy-Item -Path "$sourceDir\*" -Destination "$OpenSSHTestDir\" -Container -Include unittest-* -Recurse -Force -ErrorAction Stop
509+
510510
#restart the service to use the test copy of sshd_config
511511
Restart-Service sshd
512512
}
@@ -668,14 +668,18 @@ function Run-OpenSSHUnitTest
668668
{
669669
Remove-Item -Path $unitTestOutputFile -Force -ErrorAction SilentlyContinue
670670
}
671-
672-
$unitTestFiles = Get-ChildItem -Path "$testRoot\unittest*.exe" -Exclude unittest-kex.exe,unittest-hostkeys.exe
671+
$testFolders = Get-ChildItem unittest-*.exe -Recurse -Exclude unittest-sshkey.exe,unittest-kex.exe |
672+
ForEach-Object{ Split-Path $_.FullName} |
673+
Sort-Object -Unique
673674
$testfailed = $false
674-
if ($unitTestFiles -ne $null)
675-
{
676-
$unitTestFiles | % {
677-
Write-Output "Running OpenSSH unit $($_.FullName)..."
678-
& $_.FullName >> $unitTestOutputFile
675+
if ($testFolders -ne $null)
676+
{
677+
$testFolders | % {
678+
Push-Location $_
679+
$unittestFile = "$(Split-Path $_ -Leaf).exe"
680+
Write-Output "Running OpenSSH unit $unittestFile ..."
681+
& .\$unittestFile >> $unitTestOutputFile
682+
679683
$errorCode = $LASTEXITCODE
680684
if ($errorCode -ne 0)
681685
{
@@ -685,6 +689,7 @@ function Run-OpenSSHUnitTest
685689
Write-BuildMessage -Message $errorMessage -Category Error
686690
Set-BuildVariable TestPassed False
687691
}
692+
Pop-Location
688693
}
689694
if(-not $testfailed)
690695
{
@@ -747,7 +752,7 @@ function Upload-OpenSSHTestResults
747752

748753
if($env:TestPassed -ieq 'True')
749754
{
750-
Write-BuildMessage -Message "The checkin validation success!"
755+
Write-BuildMessage -Message "The checkin validation success!" -Category Information
751756
}
752757
else
753758
{

contrib/win32/openssh/config.h.vs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@
10801080
#define HAVE_SYS_TYPES_H 1
10811081

10821082
/* Define to 1 if you have the <sys/un.h> header file. */
1083-
/* #undef HAVE_SYS_UN_H */
1083+
#define HAVE_SYS_UN_H 1
10841084

10851085
/* Define to 1 if you have the `tcgetpgrp' function. */
10861086
/* #undef HAVE_TCGETPGRP */
@@ -1641,7 +1641,6 @@
16411641
#undef HAVE_SYS_CDEFS_H
16421642
#undef HAVE_SYS_SYSMACROS_H
16431643
#undef HAVE_SYS_MMAN_H
1644-
#undef HAVE_SYS_UN_H
16451644
#define _STRUCT_WINSIZE 1
16461645

16471646
#define HAVE_TCGETPGRP 1

contrib/win32/openssh/config.vcxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
<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>
116116
</PreBuildEvent>
117117
<PreBuildEvent>
118-
<Message>Setup config.h in openssh source path for visual studio</Message>
118+
<Message>Generate crtheaders.h and config.h</Message>
119119
</PreBuildEvent>
120120
</ItemDefinitionGroup>
121121
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -139,7 +139,7 @@
139139
<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>
140140
</PreBuildEvent>
141141
<PreBuildEvent>
142-
<Message>Setup config.h in openssh source path for visual studio</Message>
142+
<Message>Generate crtheaders.h and config.h</Message>
143143
</PreBuildEvent>
144144
</ItemDefinitionGroup>
145145
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -167,7 +167,7 @@
167167
<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>
168168
</PreBuildEvent>
169169
<PreBuildEvent>
170-
<Message>Setup config.h in openssh source path for visual studio</Message>
170+
<Message>Generate crtheaders.h and config.h</Message>
171171
</PreBuildEvent>
172172
</ItemDefinitionGroup>
173173
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -195,7 +195,7 @@
195195
<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>
196196
</PreBuildEvent>
197197
<PreBuildEvent>
198-
<Message>Setup config.h in openssh source path for visual studio</Message>
198+
<Message>Generate crtheaders.h and config.h</Message>
199199
</PreBuildEvent>
200200
</ItemDefinitionGroup>
201201
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

contrib/win32/openssh/keygen.vcxproj

-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
158158
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
159159
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
160-
<StripPrivateSymbols>No</StripPrivateSymbols>
161160
</Link>
162161
</ItemDefinitionGroup>
163162
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -182,7 +181,6 @@
182181
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
183182
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
184183
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
185-
<StripPrivateSymbols>No</StripPrivateSymbols>
186184
</Link>
187185
</ItemDefinitionGroup>
188186
<ItemGroup>

contrib/win32/openssh/libssh.vcxproj

-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@
283283
<ClCompile Include="$(OpenSSH-Src-Path)platform-tracing.c" />
284284
<ClCompile Include="$(OpenSSH-Src-Path)platform.c" />
285285
<ClCompile Include="$(OpenSSH-Src-Path)sandbox-pledge.c" />
286-
<ClCompile Include="$(OpenSSH-Src-Path)utf8.c" />
287286
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\ttymodes_windows.c" />
288287
<ClCompile Include="$(OpenSSH-Src-Path)digest-openssl.c">
289288
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>

contrib/win32/openssh/libssh.vcxproj.filters

-3
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@
282282
<ClCompile Include="$(OpenSSH-Src-Path)sandbox-pledge.c">
283283
<Filter>Source Files</Filter>
284284
</ClCompile>
285-
<ClCompile Include="$(OpenSSH-Src-Path)utf8.c">
286-
<Filter>Source Files</Filter>
287-
</ClCompile>
288285
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\ttymodes_windows.c">
289286
<Filter>Source Files</Filter>
290287
</ClCompile>

contrib/win32/openssh/scp.vcxproj

-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
163163
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
164164
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
165-
<StripPrivateSymbols>No</StripPrivateSymbols>
166165
</Link>
167166
</ItemDefinitionGroup>
168167
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -187,7 +186,6 @@
187186
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
188187
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
189188
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
190-
<StripPrivateSymbols>No</StripPrivateSymbols>
191189
</Link>
192190
</ItemDefinitionGroup>
193191
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

contrib/win32/openssh/sftp-server.vcxproj

-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@
166166
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
167167
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
168168
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
169-
<StripPrivateSymbols>No</StripPrivateSymbols>
170169
</Link>
171170
</ItemDefinitionGroup>
172171
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -191,7 +190,6 @@
191190
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
192191
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
193192
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
194-
<StripPrivateSymbols>No</StripPrivateSymbols>
195193
</Link>
196194
</ItemDefinitionGroup>
197195
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

0 commit comments

Comments
 (0)