Source snapshot from Powershell/openssh-portable:latestw_all

This commit is contained in:
Manoj Ampalam 2017-03-14 12:36:27 -07:00
parent c8b8c4b82a
commit 776483fb4e
75 changed files with 1045 additions and 655 deletions

View File

@ -16,6 +16,7 @@ build_script:
after_build: after_build:
- ps: | - ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
Install-OpenSSH Install-OpenSSH
- ps: Write-Verbose "Restart computer ..." - ps: Write-Verbose "Restart computer ..."
- ps: Restart-Computer -Force - ps: Restart-Computer -Force
@ -37,8 +38,10 @@ test_script:
after_test: after_test:
- ps: | - ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
Upload-OpenSSHTestResults Upload-OpenSSHTestResults
on_finish: on_finish:
- ps: | - ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
Publish-Artifact Publish-Artifact

View File

@ -830,6 +830,8 @@ fake_password(const char *wire_password)
fatal("%s: password length too long: %zu", __func__, l); fatal("%s: password length too long: %zu", __func__, l);
ret = malloc(l + 1); ret = malloc(l + 1);
if (ret == NULL)
return NULL;
for (i = 0; i < l; i++) for (i = 0; i < l; i++)
ret[i] = junk[i % (sizeof(junk) - 1)]; ret[i] = junk[i % (sizeof(junk) - 1)];
ret[i] = '\0'; ret[i] = '\0';

View File

@ -94,54 +94,6 @@ ssh_get_authentication_socket(int *fdp)
if (fdp != NULL) if (fdp != NULL)
*fdp = -1; *fdp = -1;
#ifdef WINDOWS
/* Auth socket in Windows is a static-named pipe listener in ssh-agent */
{
HKEY agent_root = 0;
DWORD agent_pid = 0, tmp_size = 4, pipe_server_pid = 0xff;
DWORD connection_attempts = 0;
HANDLE h;
RegOpenKeyExW(HKEY_LOCAL_MACHINE, SSH_AGENT_REG_ROOT,
0, KEY_QUERY_VALUE, &agent_root);
if (agent_root) {
RegQueryValueEx(agent_root, "ProcessId", 0,
NULL, (LPBYTE)&agent_pid, &tmp_size);
RegCloseKey(agent_root);
}
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 ||
++connection_attempts > 10)
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 auth and prevents mitm
*/
if (!GetNamedPipeServerProcessId(h, &pipe_server_pid) ||
(agent_pid != pipe_server_pid)) {
debug("agent pid mismatch");
CloseHandle(h);
return SSH_ERR_AGENT_COMMUNICATION;
}
/* alloc fd for pipe handle */
if ((sock = w32_allocate_fd_for_handle(h, FALSE)) < 0) {
CloseHandle(h);
return SSH_ERR_SYSTEM_ERROR;
}
}
#else /* !WINDOWS */
authsocket = getenv(SSH_AUTHSOCKET_ENV_NAME); authsocket = getenv(SSH_AUTHSOCKET_ENV_NAME);
if (!authsocket) if (!authsocket)
return SSH_ERR_AGENT_NOT_PRESENT; return SSH_ERR_AGENT_NOT_PRESENT;
@ -161,7 +113,6 @@ ssh_get_authentication_socket(int *fdp)
errno = oerrno; errno = oerrno;
return SSH_ERR_SYSTEM_ERROR; return SSH_ERR_SYSTEM_ERROR;
} }
#endif /* !WINDOWS */
if (fdp != NULL) if (fdp != NULL)
*fdp = sock; *fdp = sock;

View File

@ -96,7 +96,5 @@ int ssh_agent_sign(int sock, struct sshkey *key,
#define SSH_AGENT_AUTHENTICATE 200 #define SSH_AGENT_AUTHENTICATE 200
#define PUBKEY_AUTH_REQUEST "pubkey" #define PUBKEY_AUTH_REQUEST "pubkey"
#define PASSWD_AUTH_REQUEST "password" #define PASSWD_AUTH_REQUEST "password"
#define SSH_AGENT_REG_ROOT L"SOFTWARE\\SSH\\Agent"
#define SSH_AGENT_PIPE_NAME L"\\\\.\\pipe\\ssh-agent"
#endif /* AUTHFD_H */ #endif /* AUTHFD_H */

View File

@ -4375,6 +4375,33 @@ connect_local_xsocket(u_int dnr)
return connect_local_xsocket_path(buf); return connect_local_xsocket_path(buf);
} }
#ifdef __APPLE__
static int
is_path_to_xsocket(const char *display, char *path, size_t pathlen)
{
struct stat sbuf;
if (strlcpy(path, display, pathlen) >= pathlen) {
error("%s: display path too long", __func__);
return 0;
}
if (display[0] != '/')
return 0;
if (stat(path, &sbuf) == 0) {
return 1;
} else {
char *dot = strrchr(path, '.');
if (dot != NULL) {
*dot = '\0';
if (stat(path, &sbuf) == 0) {
return 1;
}
}
}
return 0;
}
#endif
int int
x11_connect_display(void) x11_connect_display(void)
{ {
@ -4396,15 +4423,22 @@ x11_connect_display(void)
* connection to the real X server. * connection to the real X server.
*/ */
/* Check if the display is from launchd. */
#ifdef __APPLE__ #ifdef __APPLE__
if (strncmp(display, "/tmp/launch", 11) == 0) { /* Check if display is a path to a socket (as set by launchd). */
sock = connect_local_xsocket_path(display); {
if (sock < 0) char path[PATH_MAX];
return -1;
/* OK, we now have a connection to the display. */ if (is_path_to_xsocket(display, path, sizeof(path))) {
return sock; debug("x11_connect_display: $DISPLAY is launchd");
/* Create a socket. */
sock = connect_local_xsocket_path(path);
if (sock < 0)
return -1;
/* OK, we now have a connection to the display. */
return sock;
}
} }
#endif #endif
/* /*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: clientloop.c,v 1.290 2017/01/29 21:35:23 dtucker Exp $ */ /* $OpenBSD: clientloop.c,v 1.291 2017/03/10 05:01:13 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -2394,6 +2394,26 @@ client_global_hostkeys_private_confirm(int type, u_int32_t seq, void *_ctx)
hostkeys_update_ctx_free(ctx); hostkeys_update_ctx_free(ctx);
} }
/*
* Returns non-zero if the key is accepted by HostkeyAlgorithms.
* Made slightly less trivial by the multiple RSA signature algorithm names.
*/
static int
key_accepted_by_hostkeyalgs(const struct sshkey *key)
{
const char *ktype = sshkey_ssh_name(key);
const char *hostkeyalgs = options.hostkeyalgorithms != NULL ?
options.hostkeyalgorithms : KEX_DEFAULT_PK_ALG;
if (key == NULL || key->type == KEY_UNSPEC)
return 0;
if (key->type == KEY_RSA &&
(match_pattern_list("rsa-sha2-256", hostkeyalgs, 0) == 1 ||
match_pattern_list("rsa-sha2-512", hostkeyalgs, 0) == 1))
return 1;
return match_pattern_list(ktype, hostkeyalgs, 0) == 1;
}
/* /*
* Handle hostkeys-00@openssh.com global request to inform the client of all * Handle hostkeys-00@openssh.com global request to inform the client of all
* the server's hostkeys. The keys are checked against the user's * the server's hostkeys. The keys are checked against the user's
@ -2440,10 +2460,7 @@ client_input_hostkeys(void)
sshkey_type(key), fp); sshkey_type(key), fp);
free(fp); free(fp);
/* Check that the key is accepted in HostkeyAlgorithms */ if (!key_accepted_by_hostkeyalgs(key)) {
if (match_pattern_list(sshkey_ssh_name(key),
options.hostkeyalgorithms ? options.hostkeyalgorithms :
KEX_DEFAULT_PK_ALG, 0) != 1) {
debug3("%s: %s key not permitted by HostkeyAlgorithms", debug3("%s: %s key not permitted by HostkeyAlgorithms",
__func__, sshkey_ssh_name(key)); __func__, sshkey_ssh_name(key));
continue; continue;

View File

@ -499,14 +499,14 @@ function Deploy-OpenSSHTests
$RealConfiguration = $Configuration $RealConfiguration = $Configuration
} }
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot [System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
#copy all pester tests #copy all pester tests
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "regress\pesterTests" $sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "regress\pesterTests"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Include *.ps1,*.psm1, sshd_config -Force -ErrorAction Stop Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Include *.ps1,*.psm1, sshd_config -Force -ErrorAction Stop
#copy all unit tests. #copy all unit tests.
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration" $sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
Copy-Item -Path "$sourceDir\unittest-*" -Destination $OpenSSHTestDir -Force -ErrorAction Stop Copy-Item -Path "$sourceDir\*" -Destination "$OpenSSHTestDir\" -Container -Include unittest-* -Recurse -Force -ErrorAction Stop
#restart the service to use the test copy of sshd_config #restart the service to use the test copy of sshd_config
Restart-Service sshd Restart-Service sshd
} }
@ -668,14 +668,18 @@ function Run-OpenSSHUnitTest
{ {
Remove-Item -Path $unitTestOutputFile -Force -ErrorAction SilentlyContinue Remove-Item -Path $unitTestOutputFile -Force -ErrorAction SilentlyContinue
} }
$testFolders = Get-ChildItem unittest-*.exe -Recurse -Exclude unittest-sshkey.exe,unittest-kex.exe |
$unitTestFiles = Get-ChildItem -Path "$testRoot\unittest*.exe" -Exclude unittest-kex.exe,unittest-hostkeys.exe ForEach-Object{ Split-Path $_.FullName} |
Sort-Object -Unique
$testfailed = $false $testfailed = $false
if ($unitTestFiles -ne $null) if ($testFolders -ne $null)
{ {
$unitTestFiles | % { $testFolders | % {
Write-Output "Running OpenSSH unit $($_.FullName)..." Push-Location $_
& $_.FullName >> $unitTestOutputFile $unittestFile = "$(Split-Path $_ -Leaf).exe"
Write-Output "Running OpenSSH unit $unittestFile ..."
& .\$unittestFile >> $unitTestOutputFile
$errorCode = $LASTEXITCODE $errorCode = $LASTEXITCODE
if ($errorCode -ne 0) if ($errorCode -ne 0)
{ {
@ -685,6 +689,7 @@ function Run-OpenSSHUnitTest
Write-BuildMessage -Message $errorMessage -Category Error Write-BuildMessage -Message $errorMessage -Category Error
Set-BuildVariable TestPassed False Set-BuildVariable TestPassed False
} }
Pop-Location
} }
if(-not $testfailed) if(-not $testfailed)
{ {
@ -747,7 +752,7 @@ function Upload-OpenSSHTestResults
if($env:TestPassed -ieq 'True') if($env:TestPassed -ieq 'True')
{ {
Write-BuildMessage -Message "The checkin validation success!" Write-BuildMessage -Message "The checkin validation success!" -Category Information
} }
else else
{ {

View File

@ -1080,7 +1080,7 @@
#define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/un.h> header file. */ /* Define to 1 if you have the <sys/un.h> header file. */
/* #undef HAVE_SYS_UN_H */ #define HAVE_SYS_UN_H 1
/* Define to 1 if you have the `tcgetpgrp' function. */ /* Define to 1 if you have the `tcgetpgrp' function. */
/* #undef HAVE_TCGETPGRP */ /* #undef HAVE_TCGETPGRP */
@ -1641,7 +1641,6 @@
#undef HAVE_SYS_CDEFS_H #undef HAVE_SYS_CDEFS_H
#undef HAVE_SYS_SYSMACROS_H #undef HAVE_SYS_SYSMACROS_H
#undef HAVE_SYS_MMAN_H #undef HAVE_SYS_MMAN_H
#undef HAVE_SYS_UN_H
#define _STRUCT_WINSIZE 1 #define _STRUCT_WINSIZE 1
#define HAVE_TCGETPGRP 1 #define HAVE_TCGETPGRP 1

View File

@ -115,7 +115,7 @@
<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> <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>
<PreBuildEvent> <PreBuildEvent>
<Message>Setup config.h in openssh source path for visual studio</Message> <Message>Generate crtheaders.h and config.h</Message>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -139,7 +139,7 @@
<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> <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>
<PreBuildEvent> <PreBuildEvent>
<Message>Setup config.h in openssh source path for visual studio</Message> <Message>Generate crtheaders.h and config.h</Message>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -167,7 +167,7 @@
<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> <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>
<PreBuildEvent> <PreBuildEvent>
<Message>Setup config.h in openssh source path for visual studio</Message> <Message>Generate crtheaders.h and config.h</Message>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -195,7 +195,7 @@
<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> <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>
<PreBuildEvent> <PreBuildEvent>
<Message>Setup config.h in openssh source path for visual studio</Message> <Message>Generate crtheaders.h and config.h</Message>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -157,7 +157,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -182,7 +181,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -283,7 +283,6 @@
<ClCompile Include="$(OpenSSH-Src-Path)platform-tracing.c" /> <ClCompile Include="$(OpenSSH-Src-Path)platform-tracing.c" />
<ClCompile Include="$(OpenSSH-Src-Path)platform.c" /> <ClCompile Include="$(OpenSSH-Src-Path)platform.c" />
<ClCompile Include="$(OpenSSH-Src-Path)sandbox-pledge.c" /> <ClCompile Include="$(OpenSSH-Src-Path)sandbox-pledge.c" />
<ClCompile Include="$(OpenSSH-Src-Path)utf8.c" />
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\ttymodes_windows.c" /> <ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\ttymodes_windows.c" />
<ClCompile Include="$(OpenSSH-Src-Path)digest-openssl.c"> <ClCompile Include="$(OpenSSH-Src-Path)digest-openssl.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild> <ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>

View File

@ -282,9 +282,6 @@
<ClCompile Include="$(OpenSSH-Src-Path)sandbox-pledge.c"> <ClCompile Include="$(OpenSSH-Src-Path)sandbox-pledge.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)utf8.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\ttymodes_windows.c"> <ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\ttymodes_windows.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>

View File

@ -162,7 +162,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -187,7 +186,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -166,7 +166,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -191,7 +190,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -168,7 +168,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -193,7 +192,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -167,7 +167,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -192,7 +191,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -164,7 +164,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <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> <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> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
<Manifest> <Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
@ -191,7 +190,6 @@
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <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> <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> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
<Manifest> <Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>

View File

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

View File

@ -160,7 +160,6 @@
<AdditionalDependencies>openbsd_compat.lib;kernel32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>openbsd_compat.lib;kernel32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -184,7 +183,6 @@
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>openbsd_compat.lib;kernel32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>openbsd_compat.lib;kernel32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>

View File

@ -167,7 +167,6 @@
<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> <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> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
<Manifest> <Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
@ -195,7 +194,6 @@
<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> <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> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
<Manifest> <Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>

View File

@ -166,7 +166,6 @@
<ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput> <ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
<Manifest> <Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
@ -196,7 +195,6 @@
<ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput> <ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile> <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<StripPrivateSymbols>No</StripPrivateSymbols>
</Link> </Link>
<Manifest> <Manifest>
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>

View File

@ -87,14 +87,14 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-bitmap</TargetName> <TargetName>unittest-bitmap</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-bitmap</TargetName> <TargetName>unittest-bitmap</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
@ -160,7 +160,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -186,7 +186,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -199,13 +199,13 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\bitmap\tests.c"> <ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\bitmap\tests.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild> <ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\test_helper\test_helper.c"> <ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\test_helper\test_helper.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild> <ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\wmain_common.c"> <ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\wmain_common.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild> <ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -87,14 +87,14 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-hostkeys</TargetName> <TargetName>unittest-hostkeys</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-hostkeys</TargetName> <TargetName>unittest-hostkeys</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
@ -123,7 +123,7 @@
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest> </Manifest>
<PostBuildEvent> <PostBuildEvent>
<Command>copy /Y $(ProjectDir)..\..\..\regress\unittests\hostkeys\testdata\* $(OutDir)</Command> <Command>xcopy /Y $(ProjectDir)..\..\..\regress\unittests\hostkeys\testdata\* $(OutDir)hostkeys\</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -149,7 +149,7 @@
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest> </Manifest>
<PostBuildEvent> <PostBuildEvent>
<Command>copy /Y $(ProjectDir)..\..\..\regress\unittests\hostkeys\testdata\* $(OutDir)</Command> <Command>xcopy /Y $(ProjectDir)..\..\..\regress\unittests\hostkeys\testdata\* $(OutDir)hostkeys\</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -166,7 +166,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -177,7 +177,7 @@
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest> </Manifest>
<PostBuildEvent> <PostBuildEvent>
<Command>copy /Y $(ProjectDir)..\..\..\regress\unittests\hostkeys\testdata\* $(OutDir)</Command> <Command>xcopy /Y $(ProjectDir)..\..\..\regress\unittests\hostkeys\testdata\* $(OutDir)</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -195,7 +195,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -206,7 +206,7 @@
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest> </Manifest>
<PostBuildEvent> <PostBuildEvent>
<Command>copy /Y $(ProjectDir)..\..\..\regress\unittests\hostkeys\testdata\* $(OutDir)</Command> <Command>xcopy /Y $(ProjectDir)..\..\..\regress\unittests\hostkeys\testdata\* $(OutDir)</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -87,14 +87,14 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-kex</TargetName> <TargetName>unittest-kex</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-kex</TargetName> <TargetName>unittest-kex</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
@ -160,7 +160,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -186,7 +186,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

View File

@ -87,14 +87,14 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-match</TargetName> <TargetName>unittest-match</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-match</TargetName> <TargetName>unittest-match</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
@ -160,7 +160,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -186,7 +186,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

View File

@ -87,14 +87,14 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-sshbuf</TargetName> <TargetName>unittest-sshbuf</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-sshbuf</TargetName> <TargetName>unittest-sshbuf</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
@ -160,7 +160,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -186,7 +186,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -204,10 +204,10 @@
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_fuzz.c" /> <ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_fuzz.c" />
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_getput_basic.c" /> <ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_getput_basic.c" />
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_getput_crypto.c"> <ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_getput_crypto.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild> <ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_getput_fuzz.c"> <ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_getput_fuzz.c">
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild> <ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_misc.c" /> <ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\sshbuf\test_sshbuf_misc.c" />
<ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\test_helper\fuzz.c" /> <ClCompile Include="$(OpenSSH-Src-Path)regress\unittests\test_helper\fuzz.c" />

View File

@ -87,14 +87,14 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-sshkey</TargetName> <TargetName>unittest-sshkey</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-sshkey</TargetName> <TargetName>unittest-sshkey</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
@ -123,7 +123,7 @@
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest> </Manifest>
<PostBuildEvent> <PostBuildEvent>
<Command>copy /Y $(ProjectDir)..\..\..\regress\unittests\sshkey\testdata\* $(OutDir)</Command> <Command>xcopy /Y $(ProjectDir)..\..\..\regress\unittests\sshkey\testdata\* $(OutDir)sshkey\</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -149,7 +149,7 @@
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest> </Manifest>
<PostBuildEvent> <PostBuildEvent>
<Command>copy /Y $(ProjectDir)..\..\..\regress\unittests\sshkey\testdata\* $(OutDir)</Command> <Command>xcopy /Y $(ProjectDir)..\..\..\regress\unittests\sshkey\testdata\* $(OutDir)sshkey\</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -166,7 +166,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -177,7 +177,7 @@
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest> </Manifest>
<PostBuildEvent> <PostBuildEvent>
<Command>copy /Y $(ProjectDir)..\..\..\regress\unittests\sshkey\testdata\* $(OutDir)</Command> <Command>xcopy /Y $(ProjectDir)..\..\..\regress\unittests\sshkey\testdata\* $(OutDir)</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -195,7 +195,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -206,7 +206,7 @@
<AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles> <AdditionalManifestFiles>targetos.manifest</AdditionalManifestFiles>
</Manifest> </Manifest>
<PostBuildEvent> <PostBuildEvent>
<Command>copy /Y $(ProjectDir)..\..\..\regress\unittests\sshkey\testdata\* $(OutDir)</Command> <Command>xcopy /Y $(ProjectDir)..\..\..\regress\unittests\sshkey\testdata\* $(OutDir)</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -87,14 +87,14 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-utf8</TargetName> <TargetName>unittest-utf8</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-utf8</TargetName> <TargetName>unittest-utf8</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
@ -160,7 +160,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -186,7 +186,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

View File

@ -94,14 +94,14 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-win32compat</TargetName> <TargetName>unittest-win32compat</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir> <OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir> <IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
<TargetName>unittest-win32compat</TargetName> <TargetName>unittest-win32compat</TargetName>
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> <IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
@ -167,7 +167,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -193,7 +193,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

Binary file not shown.

View File

@ -160,6 +160,7 @@
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tncon.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tncon.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tnnet.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tnnet.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\utf.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\utf.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\win32-utf8.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" />
@ -203,6 +204,8 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\types.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\ctype.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\stdlib.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\stdlib.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\console.h" />
<ClInclude Include="..\win32compat\tnnet.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -19,6 +19,7 @@
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tncon.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tncon.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tnnet.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tnnet.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\utf.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\utf.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\win32-utf8.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" />
@ -138,6 +139,8 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\ctype.h"> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\ctype.h">
<Filter>inc</Filter> <Filter>inc</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\console.h" />
<ClInclude Include="..\win32compat\tnnet.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="inc"> <Filter Include="inc">

View File

@ -48,14 +48,12 @@ extern int ScreenX;
extern int ScreenY; extern int ScreenY;
extern int ScrollTop; extern int ScrollTop;
extern int ScrollBottom; extern int ScrollBottom;
extern BOOL bAnsiParsing;
bool gbVTAppMode = false; bool gbVTAppMode = false;
/* private message for port printing to */ /* private message for port printing to */
unsigned char VT_ST[] = { 0x1b, '/', '\0' }; unsigned char VT_ST[] = { 0x1b, '/', '\0' };
static int AutoWrap = 1; static int AutoWrap = 1;
BOOL bAtEOLN = FALSE; BOOL bAtEOLN = FALSE;
static int term_mode = TERM_ANSI;
/* /*
* ParseANSI globals - these need to be here, because sometimes blocks are sent * ParseANSI globals - these need to be here, because sometimes blocks are sent
@ -142,12 +140,24 @@ BufConvertToG2(char * pszBuffer, int length)
void void
GoToNextLine() GoToNextLine()
{ {
if (ConGetCursorY() >= (ConWindowSizeY() - 1)) { int currentX = 0;
ConScrollDown(ScrollTop, ScrollBottom); int currentY = 0;
ConMoveCursorPosition(-ConGetCursorX(), 0);
} ConGetCursorPosition(&currentX, &currentY);
else
ConMoveCursorPosition(-ConGetCursorX(), 1); /* If the cursor is the last line of the visible window */
if (is_cursor_at_lastline_of_visible_window()) {
if (currentY >= ConGetBufferHeight()) {
/* handle the max window buffer size */
ConScrollDown(0, currentY);
ConMoveCursorPosition(-currentX, 0);
} else {
/* max window buffer is not breached */
ConMoveVisibleWindow(1);
ConMoveCursorPosition(-currentX, 1);
}
} else /* If the cursor is NOT the last line of the visible window */
ConMoveCursorPosition(-currentX, 1);
bAtEOLN = FALSE; bAtEOLN = FALSE;
} }
@ -155,8 +165,8 @@ GoToNextLine()
unsigned char* unsigned char*
ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char **respbuf, size_t *resplen) ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char **respbuf, size_t *resplen)
{ {
int CurrentX; int currentX;
int CurrentY; int currentY;
int bufLen, cmpLen, i; int bufLen, cmpLen, i;
if (!fcompletion) { if (!fcompletion) {
@ -164,8 +174,7 @@ ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char
unsigned char * pszCurrent = pszBuffer + 1; unsigned char * pszCurrent = pszBuffer + 1;
unsigned char * pszNewCurrent = pszCurrent; unsigned char * pszNewCurrent = pszCurrent;
if (term_mode == TERM_ANSI && bAnsiParsing) pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
/* Pointer didn't move inside Parse function */ /* Pointer didn't move inside Parse function */
if (pszCurrent == pszNewCurrent) { if (pszCurrent == pszNewCurrent) {
@ -200,8 +209,8 @@ ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char
case 8: case 8:
pszBuffer++; pszBuffer++;
if (!bAtEOLN) { if (!bAtEOLN) {
CurrentX = ConGetCursorX(); currentX = ConGetCursorX();
if (CurrentX == 0) { if (currentX == 0) {
ConMoveCursorPosition(ScreenX - 1, -1); ConMoveCursorPosition(ScreenX - 1, -1);
ConWriteString(" ", 1); ConWriteString(" ", 1);
} else { } else {
@ -263,10 +272,8 @@ ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char
if (*pszCurrent == 27) { if (*pszCurrent == 27) {
pszNewCurrent += ConWriteString((char *)pszCurrent, 1); pszNewCurrent += ConWriteString((char *)pszCurrent, 1);
return pszBuffer + 1; return pszBuffer + 1;
} else { } else
if (term_mode == TERM_ANSI) pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
}
if (pszNewCurrent > pszCurrent) if (pszNewCurrent > pszCurrent)
pszBuffer = pszNewCurrent; pszBuffer = pszNewCurrent;
@ -278,12 +285,12 @@ ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char
if (bAtEOLN) GoToNextLine(); if (bAtEOLN) GoToNextLine();
unsigned char* pszCurrent = pszBuffer; unsigned char* pszCurrent = pszBuffer;
CurrentX = ConGetCursorX(); currentX = ConGetCursorX();
int nCharCount = 0; int nCharCount = 0;
while ((pszCurrent < pszBufferEnd) && (*pszCurrent != (unsigned char)27) while ((pszCurrent < pszBufferEnd) && (*pszCurrent != (unsigned char)27)
&& (*pszCurrent > (unsigned char)15) && (*pszCurrent != (unsigned char)255) && (*pszCurrent > (unsigned char)15) && (*pszCurrent != (unsigned char)255)
&& (CurrentX++ < ScreenX)) { && (currentX++ < ScreenX)) {
if (*pszCurrent > 127) { if (*pszCurrent > 127) {
unsigned char nLead = *pszCurrent; unsigned char nLead = *pszCurrent;
nCharCount++; nCharCount++;
@ -305,7 +312,7 @@ ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char
pszBuffer += ConWriteString((char *)pszBuffer, (int)(pszCurrent - pszBuffer)); pszBuffer += ConWriteString((char *)pszBuffer, (int)(pszCurrent - pszBuffer));
if ((CurrentX >= ScreenX) && AutoWrap && !(VTMode & MODE_CURSORAPP)) if ((currentX >= ScreenX) && AutoWrap && !(VTMode & MODE_CURSORAPP))
bAtEOLN = TRUE; bAtEOLN = TRUE;
} }
break; break;
@ -561,10 +568,10 @@ ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char
if (iParam[0]) { if (iParam[0]) {
int i; int i;
for (i = 0; i < iParam[0]; i++) for (i = 0; i < iParam[0]; i++)
ConScrollUp(ConGetCursorY() - 1, ScrollTop + ConWindowSizeY() - 2); ConScrollUp(ConGetCursorY() - 1, ScrollTop + ConVisibleWindowHeight() - 2);
} else { } else {
if (ConGetCursorY() <= ScrollTop + ConWindowSizeY() - 2) if (ConGetCursorY() <= ScrollTop + ConVisibleWindowHeight() - 2)
ConScrollUp(ConGetCursorY() - 1, ScrollTop + ConWindowSizeY() - 2); ConScrollUp(ConGetCursorY() - 1, ScrollTop + ConVisibleWindowHeight() - 2);
} }
fcompletion = 1; fcompletion = 1;
bAtEOLN = FALSE; bAtEOLN = FALSE;
@ -600,7 +607,7 @@ ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char
for (i = 0; i < iParam[0]; i++) for (i = 0; i < iParam[0]; i++)
ConScrollUp(ConGetCursorY(), ScrollTop - ConGetCursorY()); ConScrollUp(ConGetCursorY(), ScrollTop - ConGetCursorY());
} else { } else {
if (ConGetCursorY() <= ScrollTop + ConWindowSizeY() - 2) if (ConGetCursorY() <= ScrollTop + ConVisibleWindowHeight() - 2)
ConScrollUp(ConGetCursorY(), ScrollTop - ConGetCursorY()); ConScrollUp(ConGetCursorY(), ScrollTop - ConGetCursorY());
} }
fcompletion = 1; fcompletion = 1;

View File

@ -52,13 +52,14 @@ int ScrollTop;
int ScrollBottom; int ScrollBottom;
int LastCursorX; int LastCursorX;
int LastCursorY; int LastCursorY;
BOOL bAnsiParsing = FALSE; BOOL isAnsiParsingRequired = FALSE;
char *pSavedScreen = NULL; char *pSavedScreen = NULL;
static COORD ZeroCoord = { 0,0 }; static COORD ZeroCoord = { 0,0 };
COORD SavedScreenSize = { 0,0 }; COORD SavedScreenSize = { 0,0 };
COORD SavedScreenCursor = { 0, 0 }; COORD SavedScreenCursor = { 0, 0 };
SMALL_RECT SavedViewRect = { 0,0,0,0 }; SMALL_RECT SavedViewRect = { 0,0,0,0 };
CONSOLE_SCREEN_BUFFER_INFOEX SavedWindowState; CONSOLE_SCREEN_BUFFER_INFOEX SavedWindowState;
BOOL isConHostParserEnabled = TRUE;
typedef struct _SCREEN_RECORD { typedef struct _SCREEN_RECORD {
PCHAR_INFO pScreenBuf; PCHAR_INFO pScreenBuf;
@ -69,10 +70,11 @@ typedef struct _SCREEN_RECORD {
PSCREEN_RECORD pSavedScreenRec = NULL; PSCREEN_RECORD pSavedScreenRec = NULL;
int in_raw_mode = 0; int in_raw_mode = 0;
char *consoleTitle = "Microsoft openSSH client";
/* Used to Initialize the Console for output */ /* Used to enter the raw mode */
int int
ConInit(DWORD OutputHandle, BOOL fSmartInit) ConEnterRawMode(DWORD OutputHandle, BOOL fSmartInit)
{ {
OSVERSIONINFO os; OSVERSIONINFO os;
DWORD dwAttributes = 0; DWORD dwAttributes = 0;
@ -87,16 +89,18 @@ ConInit(DWORD OutputHandle, BOOL fSmartInit)
hOutputConsole = GetStdHandle(OutputHandle); hOutputConsole = GetStdHandle(OutputHandle);
if (hOutputConsole == INVALID_HANDLE_VALUE) { if (hOutputConsole == INVALID_HANDLE_VALUE) {
dwRet = GetLastError(); dwRet = GetLastError();
printf("GetStdHandle on OutputHandle failed with %d\n", dwRet); error("GetStdHandle on OutputHandle failed with %d\n", dwRet);
return dwRet; return dwRet;
} }
if (!GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwSavedAttributes)) { if (!GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwSavedAttributes)) {
dwRet = GetLastError(); dwRet = GetLastError();
printf("GetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet); error("GetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet);
return dwRet; return dwRet;
} }
SetConsoleTitle(consoleTitle);
dwAttributes = dwSavedAttributes; dwAttributes = dwSavedAttributes;
dwAttributes &= ~(ENABLE_LINE_INPUT | dwAttributes &= ~(ENABLE_LINE_INPUT |
ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT); ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
@ -104,43 +108,59 @@ ConInit(DWORD OutputHandle, BOOL fSmartInit)
if (!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes)) { /* Windows NT */ if (!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes)) { /* Windows NT */
dwRet = GetLastError(); dwRet = GetLastError();
printf("SetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet); error("SetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet);
return dwRet; return dwRet;
} }
if (!GetConsoleMode(hOutputConsole, &dwAttributes)) { if (!GetConsoleMode(hOutputConsole, &dwAttributes)) {
dwRet = GetLastError(); dwRet = GetLastError();
printf("GetConsoleMode on hOutputConsole failed with %d\n", dwRet); error("GetConsoleMode on hOutputConsole failed with %d\n", dwRet);
return dwRet; return dwRet;
} }
dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING; dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if (!SetConsoleMode(hOutputConsole, dwAttributes)) /* Windows NT */ if (NULL != getenv("SSH_TERM_CONHOST_PARSER"))
bAnsiParsing = TRUE; isConHostParserEnabled = atoi(getenv("SSH_TERM_CONHOST_PARSER"));
/* We use our custom ANSI parser when
* a) User sets the environment variable "SSH_TERM_CONHOST_PARSER" to 0
* b) or when the console doesn't have the inbuilt capability to parse the ANSI/Xterm raw buffer.
*/
if (FALSE == isConHostParserEnabled || !SetConsoleMode(hOutputConsole, dwAttributes)) /* Windows NT */
isAnsiParsingRequired = TRUE;
GetConsoleScreenBufferInfo(hOutputConsole, &csbi);
/* if we are passing rawbuffer to console then we need to move the cursor to top
* so that the clearscreen will not erase any lines.
*/
if (TRUE == isAnsiParsingRequired) {
SavedViewRect = csbi.srWindow;
debug("console doesn't support the ansi parsing");
} else {
ConMoveCurosorTop(csbi);
debug("console supports the ansi parsing");
}
ConSetScreenX(); ConSetScreenX();
ConSetScreenY(); ConSetScreenY();
ScrollTop = 0; ScrollTop = 0;
ScrollBottom = ConWindowSizeY(); ScrollBottom = ConVisibleWindowHeight();
if (GetConsoleScreenBufferInfo(hOutputConsole, &csbi))
SavedViewRect = csbi.srWindow;
in_raw_mode = 1; in_raw_mode = 1;
return 0; return 0;
} }
/* Used to Uninitialize the Console */ /* Used to Uninitialize the Console */
int int
ConUnInit(void) ConExitRawMode()
{ {
CONSOLE_SCREEN_BUFFER_INFO consoleInfo; CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
in_raw_mode = 0; in_raw_mode = 0;
if (hOutputConsole == NULL) if (hOutputConsole == NULL || !GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo))
return 0;
if (!GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo))
return 0; return 0;
SetConsoleMode(hOutputConsole, dwSavedAttributes); SetConsoleMode(hOutputConsole, dwSavedAttributes);
@ -148,9 +168,9 @@ ConUnInit(void)
return 0; return 0;
} }
/* Used to Uninitialize the Console */ /* Used to exit the raw mode */
int int
ConUnInitWithRestore(void) ConUnInitWithRestore()
{ {
DWORD dwWritten; DWORD dwWritten;
COORD Coord; COORD Coord;
@ -446,9 +466,9 @@ ConScreenSizeY()
return (consoleInfo.srWindow.Bottom - consoleInfo.srWindow.Top + 1); return (consoleInfo.srWindow.Bottom - consoleInfo.srWindow.Top + 1);
} }
/* returns visible size of screen window */ /* returns width of visible window */
int int
ConWindowSizeX() ConVisibleWindowWidth()
{ {
CONSOLE_SCREEN_BUFFER_INFO consoleInfo; CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
@ -458,9 +478,9 @@ ConWindowSizeX()
return (consoleInfo.srWindow.Right - consoleInfo.srWindow.Left + 1); return (consoleInfo.srWindow.Right - consoleInfo.srWindow.Left + 1);
} }
/* returns visible size of screen window */ /* returns height of visible window */
int int
ConWindowSizeY() ConVisibleWindowHeight()
{ {
CONSOLE_SCREEN_BUFFER_INFO consoleInfo; CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
@ -837,7 +857,7 @@ ConDisplayCursor(BOOL bVisible)
} }
void void
ConClearScreen(void) ConClearScreen()
{ {
DWORD dwWritten; DWORD dwWritten;
COORD Coord; COORD Coord;
@ -850,7 +870,7 @@ ConClearScreen(void)
Coord.X = 0; Coord.X = 0;
Coord.Y = 0; Coord.Y = 0;
DWORD dwNumChar = (consoleInfo.srWindow.Bottom + 1) * (consoleInfo.srWindow.Right + 1); DWORD dwNumChar = (consoleInfo.dwSize.Y) * (consoleInfo.dwSize.X);
FillConsoleOutputCharacter(hOutputConsole, ' ', dwNumChar, Coord, &dwWritten); FillConsoleOutputCharacter(hOutputConsole, ' ', dwNumChar, Coord, &dwWritten);
FillConsoleOutputAttribute(hOutputConsole, consoleInfo.wAttributes, dwNumChar, Coord, &dwWritten); FillConsoleOutputAttribute(hOutputConsole, consoleInfo.wAttributes, dwNumChar, Coord, &dwWritten);
srcWindow = consoleInfo.srWindow; srcWindow = consoleInfo.srWindow;
@ -1055,11 +1075,25 @@ ConScrollUp(int topline, int botline)
); );
} }
void
ConMoveVisibleWindow(int offset)
{
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
SMALL_RECT visibleWindowRect;
if (GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo)) {
memcpy(&visibleWindowRect, &consoleInfo.srWindow, sizeof(visibleWindowRect));
visibleWindowRect.Top += offset;
visibleWindowRect.Bottom += offset;
SetConsoleWindowInfo(hOutputConsole, TRUE, &visibleWindowRect);
}
}
void void
ConScrollDown(int topline, int botline) ConScrollDown(int topline, int botline)
{ {
SMALL_RECT ScrollRect; SMALL_RECT ScrollRect;
SMALL_RECT ClipRect;
COORD destination; COORD destination;
CHAR_INFO Fill; CHAR_INFO Fill;
CONSOLE_SCREEN_BUFFER_INFO consoleInfo; CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
@ -1078,11 +1112,6 @@ ConScrollDown(int topline, int botline)
ScrollRect.Left = 0; ScrollRect.Left = 0;
ScrollRect.Right = ConScreenSizeX() - 1; ScrollRect.Right = ConScreenSizeX() - 1;
ClipRect.Top = ScrollRect.Top;
ClipRect.Bottom = ScrollRect.Bottom;
ClipRect.Left = ScrollRect.Left;
ClipRect.Right = ScrollRect.Right;
destination.X = 0; destination.X = 0;
destination.Y = ScrollRect.Top - 1; destination.Y = ScrollRect.Top - 1;
@ -1152,6 +1181,17 @@ ConChangeCursor(CONSOLE_CURSOR_INFO *pCursorInfo)
return SetConsoleCursorInfo(hOutputConsole, pCursorInfo); return SetConsoleCursorInfo(hOutputConsole, pCursorInfo);
} }
void
ConGetCursorPosition(int *x, int *y)
{
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
if (GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo)) {
*x = consoleInfo.dwCursorPosition.X;
*y = consoleInfo.dwCursorPosition.Y;
}
}
int int
ConGetCursorX() ConGetCursorX()
{ {
@ -1163,6 +1203,21 @@ ConGetCursorX()
return consoleInfo.dwCursorPosition.X; return consoleInfo.dwCursorPosition.X;
} }
int
is_cursor_at_lastline_of_visible_window()
{
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
int return_val = 0;
if (GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo)) {
int cursor_linenum_in_visible_window = consoleInfo.dwCursorPosition.Y - consoleInfo.srWindow.Top;
if (cursor_linenum_in_visible_window >= ConVisibleWindowHeight() - 1)
return_val = 1;
}
return return_val;
}
int int
ConGetCursorY() ConGetCursorY()
{ {
@ -1175,14 +1230,14 @@ ConGetCursorY()
} }
int int
ConGetCursorInBufferY() ConGetBufferHeight()
{ {
CONSOLE_SCREEN_BUFFER_INFO consoleInfo; CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
if (!GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo)) if (!GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo))
return 0; return 0;
return (consoleInfo.dwCursorPosition.Y); return (consoleInfo.dwSize.Y - 1);
} }
void void
@ -1390,28 +1445,53 @@ ConDeleteScreenHandle(SCREEN_HANDLE hScreen)
/* Restores Previous Saved screen info and buffer */ /* Restores Previous Saved screen info and buffer */
BOOL BOOL
ConRestoreScreen(void) ConRestoreScreen()
{ {
return ConRestoreScreenHandle(pSavedScreenRec); return ConRestoreScreenHandle(pSavedScreenRec);
} }
/* Saves current screen info and buffer */ /* Saves current screen info and buffer */
BOOL void
ConSaveScreen(void) ConSaveScreen()
{ {
pSavedScreenRec = (PSCREEN_RECORD)ConSaveScreenHandle(pSavedScreenRec); pSavedScreenRec = (PSCREEN_RECORD)ConSaveScreenHandle(pSavedScreenRec);
return TRUE;
} }
void void
ConSaveViewRect(void) ConSaveViewRect()
{ {
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
if (!GetConsoleScreenBufferInfo(hOutputConsole, &csbi)) if (GetConsoleScreenBufferInfo(hOutputConsole, &csbi))
return; SavedViewRect = csbi.srWindow;
}
SavedViewRect = csbi.srWindow; void
ConRestoreViewRect()
{
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
HWND hwnd = FindWindow(NULL, consoleTitle);
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hwnd, &wp);
if (GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo) &&
((consoleInfo.srWindow.Top != SavedViewRect.Top ||
consoleInfo.srWindow.Bottom != SavedViewRect.Bottom))) {
if ((SavedViewRect.Right - SavedViewRect.Left > consoleInfo.dwSize.X) ||
(wp.showCmd == SW_SHOWMAXIMIZED)) {
COORD coordScreen;
coordScreen.X = SavedViewRect.Right - SavedViewRect.Left;
coordScreen.Y = consoleInfo.dwSize.Y;
SetConsoleScreenBufferSize(hOutputConsole, coordScreen);
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
} else
ShowWindow(hwnd, SW_RESTORE);
SetConsoleWindowInfo(hOutputConsole, TRUE, &SavedViewRect);
}
} }
BOOL BOOL
@ -1460,7 +1540,7 @@ GetConsoleInputHandle()
} }
void void
ConSaveWindowsState(void) ConSaveWindowsState()
{ {
CONSOLE_SCREEN_BUFFER_INFOEX csbiex; CONSOLE_SCREEN_BUFFER_INFOEX csbiex;
csbiex.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX); csbiex.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
@ -1470,3 +1550,12 @@ ConSaveWindowsState(void)
SavedWindowState = csbiex; SavedWindowState = csbiex;
} }
void
ConMoveCurosorTop(CONSOLE_SCREEN_BUFFER_INFO csbi)
{
int offset = csbi.dwCursorPosition.Y - csbi.srWindow.Top;
ConMoveVisibleWindow(offset);
ConSaveViewRect();
}

View File

@ -42,38 +42,38 @@
#define __PRAGMA_CONSOLE_h #define __PRAGMA_CONSOLE_h
#define ANSI_ATTR_RESET 0 #define ANSI_ATTR_RESET 0
#define ANSI_BRIGHT 1 #define ANSI_BRIGHT 1
#define ANSI_DIM 2 #define ANSI_DIM 2
#define ANSI_UNDERSCORE 4 #define ANSI_UNDERSCORE 4
#define ANSI_BLINK 5 #define ANSI_BLINK 5
#define ANSI_REVERSE 7 #define ANSI_REVERSE 7
#define ANSI_HIDDEN 8 #define ANSI_HIDDEN 8
#define ANSI_NOUNDERSCORE 24 #define ANSI_NOUNDERSCORE 24
#define ANSI_NOREVERSE 27 #define ANSI_NOREVERSE 27
#define ANSI_FOREGROUND_BLACK 30 #define ANSI_FOREGROUND_BLACK 30
#define ANSI_FOREGROUND_RED 31 #define ANSI_FOREGROUND_RED 31
#define ANSI_FOREGROUND_GREEN 32 #define ANSI_FOREGROUND_GREEN 32
#define ANSI_FOREGROUND_YELLOW 33 #define ANSI_FOREGROUND_YELLOW 33
#define ANSI_FOREGROUND_BLUE 34 #define ANSI_FOREGROUND_BLUE 34
#define ANSI_FOREGROUND_MAGENTA 35 #define ANSI_FOREGROUND_MAGENTA 35
#define ANSI_FOREGROUND_CYAN 36 #define ANSI_FOREGROUND_CYAN 36
#define ANSI_FOREGROUND_WHITE 37 #define ANSI_FOREGROUND_WHITE 37
#define ANSI_DEFAULT_FOREGROUND 39 #define ANSI_DEFAULT_FOREGROUND 39
#define ANSI_BACKGROUND_BLACK 40 #define ANSI_BACKGROUND_BLACK 40
#define ANSI_BACKGROUND_RED 41 #define ANSI_BACKGROUND_RED 41
#define ANSI_BACKGROUND_GREEN 42 #define ANSI_BACKGROUND_GREEN 42
#define ANSI_BACKGROUND_YELLOW 43 #define ANSI_BACKGROUND_YELLOW 43
#define ANSI_BACKGROUND_BLUE 44 #define ANSI_BACKGROUND_BLUE 44
#define ANSI_BACKGROUND_MAGENTA 45 #define ANSI_BACKGROUND_MAGENTA 45
#define ANSI_BACKGROUND_CYAN 46 #define ANSI_BACKGROUND_CYAN 46
#define ANSI_BACKGROUND_WHITE 47 #define ANSI_BACKGROUND_WHITE 47
#define ANSI_DEFAULT_BACKGROUND 49 #define ANSI_DEFAULT_BACKGROUND 49
#define ANSI_BACKGROUND_BRIGHT 128 #define ANSI_BACKGROUND_BRIGHT 128
#define TAB_LENGTH 4 #define TAB_LENGTH 4
#define TAB_CHAR '\t' #define TAB_CHAR '\t'
#define TAB_SPACE " " #define TAB_SPACE " "
#define true TRUE #define true TRUE
#define false FALSE #define false FALSE
@ -81,30 +81,30 @@
typedef void * SCREEN_HANDLE; typedef void * SCREEN_HANDLE;
int ConInit( DWORD OutputHandle, BOOL fSmartInit); int ConEnterRawMode(DWORD OutputHandle, BOOL fSmartInit);
int ConUnInitWithRestore( void ); int ConUnInitWithRestore();
int ConUnInit( void ); int ConExitRawMode();
BOOL ConIsRedirected(HANDLE hInput); BOOL ConIsRedirected(HANDLE hInput);
HANDLE GetConsoleOutputHandle(); HANDLE GetConsoleOutputHandle();
HANDLE GetConsoleInputHandle(); HANDLE GetConsoleInputHandle();
BOOL ConSetScreenRect( int xSize, int ySize ); BOOL ConSetScreenRect(int xSize, int ySize);
BOOL ConSetScreenSize( int X, int Y ); BOOL ConSetScreenSize(int X, int Y);
BOOL ConRestoreScreen( void ); BOOL ConRestoreScreen();
BOOL ConSaveScreen( void ); void ConSaveScreen();
void ConSetAttribute( int *iParam, int iParamCount ); void ConSetAttribute(int *iParam, int iParamCount);
int ConScreenSizeX(); int ConScreenSizeX();
int ConSetScreenX(); int ConSetScreenX();
int ConScreenSizeY(); int ConScreenSizeY();
int ConWindowSizeX(); int ConVisibleWindowWidth();
int ConWindowSizeY(); int ConVisibleWindowHeight();
int ConSetScreenY(); int ConSetScreenY();
void ConFillToEndOfLine(); void ConFillToEndOfLine();
int ConWriteString(char* pszString, int cbString); int ConWriteString(char* pszString, int cbString);
BOOL ConWriteChar( CHAR ch ); BOOL ConWriteChar(CHAR ch);
int ConWriteConsole( char *pData, int NumChars ); int ConWriteConsole(char *pData, int NumChars);
PCHAR ConDisplayData(char* pData, int NumLines); PCHAR ConDisplayData(char* pData, int NumLines);
PCHAR ConWriteLine(char* pData); PCHAR ConWriteLine(char* pData);
int Con_printf( const char *Format, ... ); int Con_printf(const char *Format, ...);
void ConClearScrollRegion(); void ConClearScrollRegion();
void ConClearScreen(); void ConClearScreen();
void ConClearEOScreen(); void ConClearEOScreen();
@ -115,25 +115,27 @@ void ConClearNFromCursorRight(int n);
void ConClearNFromCursorLeft(int n); void ConClearNFromCursorLeft(int n);
void ConScrollUpEntireBuffer(); void ConScrollUpEntireBuffer();
void ConScrollDownEntireBuffer(); void ConScrollDownEntireBuffer();
void ConScrollUp(int topline,int botline); void ConScrollUp(int topline,int botline);
void ConScrollDown(int topline,int botline); void ConScrollDown(int topline,int botline);
void ConClearBOLine(); void ConClearBOLine();
BOOL ConChangeCursor( CONSOLE_CURSOR_INFO *pCursorInfo ); BOOL ConChangeCursor(CONSOLE_CURSOR_INFO *pCursorInfo);
void ConSetCursorPosition(int x, int y); void ConSetCursorPosition(int x, int y);
int ConGetCursorX(); int ConGetCursorX();
int ConGetCursorY(); int ConGetCursorY();
int ConGetCursorInBufferY(void); int ConGetBufferHeight();
BOOL ConDisplayCursor( BOOL bVisible ); BOOL ConDisplayCursor(BOOL bVisible);
void ConMoveCursorPosition(int x, int y); void ConMoveCursorPosition(int x, int y);
void ConGetRelativeCursorPosition(int *x, int *y); void ConGetRelativeCursorPosition(int *x, int *y);
BOOL ConRestoreScreenHandle( SCREEN_HANDLE hScreen ); BOOL ConRestoreScreenHandle(SCREEN_HANDLE hScreen);
BOOL ConRestoreScreenColors( void ); BOOL ConRestoreScreenColors();
SCREEN_HANDLE ConSaveScreenHandle( SCREEN_HANDLE); SCREEN_HANDLE ConSaveScreenHandle(SCREEN_HANDLE);
void ConDeleteScreenHandle( SCREEN_HANDLE hScreen ); void ConDeleteScreenHandle(SCREEN_HANDLE hScreen);
void ConSaveViewRect( void ); void ConSaveViewRect();
void ConRestoreViewRect( void ); void ConRestoreViewRect();
void ConDeleteChars(int n); void ConDeleteChars(int n);
void ConSaveWindowsState(void); void ConSaveWindowsState();
void ConMoveVisibleWindow(int offset);
int is_cursor_at_lastline_of_visible_window();
void ConGetCursorPosition(int *x, int *y);
void ConMoveCurosorTop(CONSOLE_SCREEN_BUFFER_INFO csbi);
#endif #endif

View File

@ -37,6 +37,7 @@
#include "w32fd.h" #include "w32fd.h"
#include "inc\utf.h" #include "inc\utf.h"
#include "inc\fcntl.h"
#include "misc_internal.h" #include "misc_internal.h"
/* internal read buffer size */ /* internal read buffer size */
@ -74,6 +75,76 @@ errno_from_Win32Error(int win32_error)
} }
} }
struct w32_io*
fileio_afunix_socket()
{
struct w32_io* ret = (struct w32_io*)malloc(sizeof(struct w32_io));
if (ret == NULL) {
errno = ENOMEM;
return NULL;
}
memset(ret, 0, sizeof(struct w32_io));
return ret;
}
int
fileio_connect(struct w32_io* pio, char* name)
{
wchar_t* name_w = NULL;
wchar_t pipe_name[PATH_MAX];
HANDLE h = INVALID_HANDLE_VALUE;
int ret = 0;
if (pio->handle != 0 && pio->handle != INVALID_HANDLE_VALUE) {
debug("fileio_connect called in unexpected state, pio = %p", pio);
errno = EOTHER;
ret = -1;
goto cleanup;
}
if ((name_w = utf8_to_utf16(name)) == NULL) {
errno = ENOMEM;
return -1;
}
_snwprintf(pipe_name, PATH_MAX, L"\\\\.\\pipe\\%ls", name_w);
h = CreateFileW(pipe_name, GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
/* TODO - support nonblocking connect */
/* wait until we have a server pipe instance to connect */
while (h == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PIPE_BUSY) {
debug2("waiting for agent connection, retrying after 1 sec");
if ((ret = wait_for_any_event(NULL, 0, 1000) != 0) != 0)
goto cleanup;
}
if (h == INVALID_HANDLE_VALUE) {
debug("unable to connect to pipe %ls, error: %d", name_w, GetLastError());
errno = errno_from_Win32LastError();
ret = -1;
goto cleanup;
}
if (SetHandleInformation(h, HANDLE_FLAG_INHERIT,
pio->fd_flags & FD_CLOEXEC ? 0 : HANDLE_FLAG_INHERIT) == FALSE) {
errno = errno_from_Win32LastError();
debug("SetHandleInformation failed, error = %d, pio = %p", GetLastError(), pio);
ret = -1;
goto cleanup;
}
pio->handle = h;
h = NULL;
cleanup:
if (name_w)
free(name_w);
if (h != INVALID_HANDLE_VALUE)
CloseHandle(h);
return ret;
}
/* used to name named pipes used to implement pipe() */ /* used to name named pipes used to implement pipe() */
static int pipe_counter = 0; static int pipe_counter = 0;
@ -663,6 +734,12 @@ fileio_close(struct w32_io* pio)
{ {
debug2("fileclose - pio:%p", pio); debug2("fileclose - pio:%p", pio);
/* handle can be null on AF_UNIX sockets that are not yet connected */
if (WINHANDLE(pio) == 0 || WINHANDLE(pio) == INVALID_HANDLE_VALUE) {
free(pio);
return 0;
}
CancelIo(WINHANDLE(pio)); CancelIo(WINHANDLE(pio));
/* let queued APCs (if any) drain */ /* let queued APCs (if any) drain */
SleepEx(0, TRUE); SleepEx(0, TRUE);

View File

@ -5,6 +5,12 @@
FILE* w32_fopen_utf8(const char *, const char *); FILE* w32_fopen_utf8(const char *, const char *);
#define fopen w32_fopen_utf8 #define fopen w32_fopen_utf8
char* w32_fgets(char *str, int n, FILE *stream);
#define fgets w32_fgets
int w32_setvbuf(FILE *stream,char *buffer, int mode, size_t size);
#define setvbuf w32_setvbuf
/* stdio.h additional definitions */ /* stdio.h additional definitions */
#define popen _popen #define popen _popen
#define pclose _pclose #define pclose _pclose
@ -14,4 +20,3 @@ FILE* w32_fdopen(int fd, const char *mode);
int w32_rename(const char *old_name, const char *new_name); int w32_rename(const char *old_name, const char *new_name);
#define rename w32_rename #define rename w32_rename

View File

@ -1,7 +1,7 @@
#ifndef COMPAT_UN_H #pragma once
#define COMPAT_UN_H 1
struct sockaddr_un {
short sun_family; /* AF_UNIX */
char sun_path[108]; /* path name (gag) */
};
/* Compatibility header to avoid lots of #ifdef _WIN32's in includes.h */
#endif

View File

@ -276,6 +276,75 @@ w32_fopen_utf8(const char *path, const char *mode)
return f; return f;
} }
/* fgets to support Unicode input */
char*
w32_fgets(char *str, int n, FILE *stream) {
HANDLE h = (HANDLE)_get_osfhandle(_fileno(stream));
wchar_t* str_w = NULL;
char *ret = NULL, *str_tmp = NULL;
if (h != NULL && h != INVALID_HANDLE_VALUE
&& GetFileType(h) == FILE_TYPE_CHAR) {
/*
* read only n/4 wide chars from console
* each UTF-16 char may bloat upto 4 utf-8 chars when converted to utf-8
* so we can fit in str[n] provided as input
*/
if ((str_w = malloc((n/4) * sizeof(wchar_t))) == NULL) {
errno = ENOMEM;
goto cleanup;
}
/* prepare for Unicode input */
_setmode(_fileno(stream), O_U16TEXT);
if (fgetws(str_w, n/4, stream) == NULL)
goto cleanup;
if ((str_tmp = utf16_to_utf8(str_w)) == NULL) {
errno = ENOMEM;
goto cleanup;
}
if (strlen(str_tmp) > n - 1) {
/* shouldn't happen. but handling in case */
errno = EINVAL;
goto cleanup;
}
memcpy(str, str_tmp, strlen(str_tmp) + 1);
ret = str;
}
else
ret = fgets(str, n, stream);
cleanup:
if (str_w)
free(str_w);
if (str_tmp)
free(str_tmp);
return ret;
}
/* Account for differences between Unix's and Windows versions of setvbuf */
int
w32_setvbuf(FILE *stream, char *buffer, int mode, size_t size) {
/* BUG: setvbuf on console stream interferes with Unicode I/O */
HANDLE h = (HANDLE)_get_osfhandle(_fileno(stream));
if (h != NULL && h != INVALID_HANDLE_VALUE
&& GetFileType(h) == FILE_TYPE_CHAR)
return 0;
/* BUG: setvbuf on file stream is interfering with w32_fopen */
/* short circuit for now*/
return 0;
/*
* if size is 0, set no buffering.
* Windows does not differentiate __IOLBF and _IOFBF
*/
if (size == 0)
return setvbuf(stream, NULL, _IONBF, 0);
else
return setvbuf(stream, buffer, mode, size);
}
char * char *
w32_programdir() w32_programdir()
{ {
@ -319,10 +388,12 @@ w32_ioctl(int d, int request, ...)
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
wsize->ws_col = c_info.dwSize.X - 5;
wsize->ws_row = c_info.dwSize.Y; wsize->ws_col = c_info.dwSize.X;
wsize->ws_row = c_info.srWindow.Bottom - c_info.srWindow.Top + 1;
wsize->ws_xpixel = 640; wsize->ws_xpixel = 640;
wsize->ws_ypixel = 480; wsize->ws_ypixel = 480;
return 0; return 0;
} }
default: default:

View File

@ -1,3 +1,4 @@
#pragma once
#define PATH_MAX MAX_PATH #define PATH_MAX MAX_PATH
/* removes first '/' for Windows paths that are unix styled. Ex: /c:/ab.cd */ /* removes first '/' for Windows paths that are unix styled. Ex: /c:/ab.cd */

View File

@ -121,6 +121,9 @@ struct key_translation keys[] = {
{ "\x1b[24~", VK_F12, 0 } { "\x1b[24~", VK_F12, 0 }
}; };
static SHORT lastX = 0;
static SHORT lastY = 0;
consoleEvent* head = NULL; consoleEvent* head = NULL;
consoleEvent* tail = NULL; consoleEvent* tail = NULL;
@ -182,6 +185,17 @@ STARTUPINFO inputSi;
goto cleanup; \ goto cleanup; \
} while(0) } while(0)
int
ConSRWidth()
{
CONSOLE_SCREEN_BUFFER_INFOEX consoleBufferInfo;
ZeroMemory(&consoleBufferInfo, sizeof(consoleBufferInfo));
consoleBufferInfo.cbSize = sizeof(consoleBufferInfo);
GetConsoleScreenBufferInfoEx(child_out, &consoleBufferInfo);
return consoleBufferInfo.srWindow.Right;
}
/* /*
* This function will handle the console keystrokes. * This function will handle the console keystrokes.
*/ */
@ -426,7 +440,7 @@ SendBuffer(HANDLE hInput, CHAR_INFO *buffer, DWORD bufferSize)
} }
void void
CalculateAndSetCursor(HANDLE hInput, UINT aboveTopLine, UINT viewPortHeight, UINT x, UINT y) CalculateAndSetCursor(HANDLE hInput, UINT x, UINT y)
{ {
SendSetCursor(pipe_out, x + 1, y + 1); SendSetCursor(pipe_out, x + 1, y + 1);
@ -548,14 +562,13 @@ ProcessEvent(void *p)
case EVENT_CONSOLE_CARET: case EVENT_CONSOLE_CARET:
{ {
COORD co; COORD co;
co.X = LOWORD(idChild);
co.Y = HIWORD(idChild);
if (idObject == CONSOLE_CARET_SELECTION) { lastX = co.X;
co.X = HIWORD(idChild); lastY = co.Y;
co.Y = LOWORD(idChild);
} else { SendSetCursor(pipe_out, lastX + 1, lastY + 1);
co.X = HIWORD(idChild);
co.Y = LOWORD(idChild);
}
break; break;
} }
@ -568,6 +581,8 @@ ProcessEvent(void *p)
readRect.Bottom = HIWORD(idChild); readRect.Bottom = HIWORD(idChild);
readRect.Right = LOWORD(idChild); readRect.Right = LOWORD(idChild);
readRect.Right = max(readRect.Right, ConSRWidth());
/* Detect a "cls" (Windows) */ /* Detect a "cls" (Windows) */
if (!bStartup && if (!bStartup &&
(readRect.Top == consoleInfo.srWindow.Top || readRect.Top == nextConsoleInfo.srWindow.Top)) { (readRect.Top == consoleInfo.srWindow.Top || readRect.Top == nextConsoleInfo.srWindow.Top)) {
@ -632,7 +647,7 @@ ProcessEvent(void *p)
SendLF(pipe_out); SendLF(pipe_out);
/* Set cursor location based on the reported location from the message */ /* Set cursor location based on the reported location from the message */
CalculateAndSetCursor(pipe_out, ViewPortY, viewPortHeight, readRect.Left, readRect.Top); CalculateAndSetCursor(pipe_out, readRect.Left, readRect.Top);
/* Send the entire block */ /* Send the entire block */
SendBuffer(pipe_out, pBuffer, bufferSize); SendBuffer(pipe_out, pBuffer, bufferSize);
@ -650,11 +665,36 @@ ProcessEvent(void *p)
wX = LOWORD(idObject); wX = LOWORD(idObject);
wY = HIWORD(idObject); wY = HIWORD(idObject);
/* Set cursor location based on the reported location from the message */ SMALL_RECT readRect;
CalculateAndSetCursor(pipe_out, ViewPortY, viewPortHeight, wX, wY); readRect.Top = wY;
readRect.Bottom = wY;
readRect.Left = wX;
readRect.Right = ConSRWidth();
/* Set cursor location based on the reported location from the message */
CalculateAndSetCursor(pipe_out, wX, wY);
COORD coordBufSize;
coordBufSize.Y = readRect.Bottom - readRect.Top + 1;
coordBufSize.X = readRect.Right - readRect.Left + 1;
/* The top left destination cell of the temporary buffer is row 0, col 0 */
COORD coordBufCoord;
coordBufCoord.X = 0;
coordBufCoord.Y = 0;
int pBufferSize = coordBufSize.X * coordBufSize.Y;
/* Send the one character. Note that a CR doesn't end up here */ /* Send the one character. Note that a CR doesn't end up here */
SendCharacter(pipe_out, wAttributes, chUpdate); CHAR_INFO *pBuffer = (PCHAR_INFO)malloc(sizeof(CHAR_INFO) * pBufferSize);
/* Copy the block from the screen buffer to the temp. buffer */
if (!ReadConsoleOutput(child_out, pBuffer, coordBufSize, coordBufCoord, &readRect)) {
DWORD dwError = GetLastError();
free(pBuffer);
return dwError;
}
SendBuffer(pipe_out, pBuffer, pBufferSize);
free(pBuffer);
break; break;
} }
@ -699,18 +739,24 @@ ProcessEvent(void *p)
} }
} }
ZeroMemory(&consoleInfo, sizeof(consoleInfo));
consoleInfo.cbSize = sizeof(consoleInfo);
GetConsoleScreenBufferInfoEx(child_out, &consoleInfo);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
DWORD WINAPI DWORD WINAPI
ProcessEventQueue(LPVOID p) ProcessEventQueue(LPVOID p)
{ {
static SHORT lastX = 0; if (child_in != INVALID_HANDLE_VALUE && child_in != NULL &&
static SHORT lastY = 0; child_out != INVALID_HANDLE_VALUE && child_out != NULL) {
DWORD dwInputMode;
DWORD dwOutputMode;
if (GetConsoleMode(child_in, &dwInputMode) && GetConsoleMode(child_out, &dwOutputMode))
if (((dwOutputMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == ENABLE_VIRTUAL_TERMINAL_PROCESSING) &&
((dwInputMode & ENABLE_VIRTUAL_TERMINAL_INPUT) == ENABLE_VIRTUAL_TERMINAL_INPUT))
bAnsi = TRUE;
else
bAnsi = FALSE;
}
while (1) { while (1) {
while (head) { while (head) {
@ -738,14 +784,6 @@ ProcessEventQueue(LPVOID p)
DWORD dwInputMode; DWORD dwInputMode;
DWORD dwOutputMode; DWORD dwOutputMode;
if (GetConsoleMode(child_in, &dwInputMode) && GetConsoleMode(child_out, &dwOutputMode)) {
if (((dwOutputMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == ENABLE_VIRTUAL_TERMINAL_PROCESSING) &&
((dwInputMode & ENABLE_VIRTUAL_TERMINAL_INPUT) == ENABLE_VIRTUAL_TERMINAL_INPUT))
bAnsi = TRUE;
else
bAnsi = FALSE;
}
ZeroMemory(&consoleInfo, sizeof(consoleInfo)); ZeroMemory(&consoleInfo, sizeof(consoleInfo));
consoleInfo.cbSize = sizeof(consoleInfo); consoleInfo.cbSize = sizeof(consoleInfo);
@ -963,7 +1001,7 @@ start_with_pty(wchar_t *command)
hostThreadId = GetCurrentThreadId(); hostThreadId = GetCurrentThreadId();
hostProcessId = GetCurrentProcessId(); hostProcessId = GetCurrentProcessId();
InitializeCriticalSection(&criticalSection); InitializeCriticalSection(&criticalSection);
hEventHook = __SetWinEventHook(EVENT_CONSOLE_CARET, EVENT_CONSOLE_LAYOUT, NULL, hEventHook = __SetWinEventHook(EVENT_CONSOLE_CARET, EVENT_CONSOLE_END_APPLICATION, NULL,
ConsoleEventProc, 0, 0, WINEVENT_OUTOFCONTEXT); ConsoleEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
memset(&si, 0, sizeof(STARTUPINFO)); memset(&si, 0, sizeof(STARTUPINFO));
memset(&pi, 0, sizeof(PROCESS_INFORMATION)); memset(&pi, 0, sizeof(PROCESS_INFORMATION));
@ -1205,8 +1243,14 @@ wmain(int ac, wchar_t **av)
char *cmd_b64_utf8, *cmd_utf8; char *cmd_b64_utf8, *cmd_utf8;
if ((cmd_b64_utf8 = utf16_to_utf8(cmd_b64)) == NULL || if ((cmd_b64_utf8 = utf16_to_utf8(cmd_b64)) == NULL ||
/* strlen(b64) should be sufficient for decoded length */ /* strlen(b64) should be sufficient for decoded length */
(cmd_utf8 = malloc(strlen(cmd_b64_utf8))) == NULL || (cmd_utf8 = malloc(strlen(cmd_b64_utf8))) == NULL) {
b64_pton(cmd_b64_utf8, cmd_utf8, strlen(cmd_b64_utf8)) == -1 || printf("ssh-shellhost - out of memory");
return -1;
}
memset(cmd_utf8, 0, strlen(cmd_b64_utf8));
if (b64_pton(cmd_b64_utf8, cmd_utf8, strlen(cmd_b64_utf8)) == -1 ||
(cmd = utf8_to_utf16(cmd_utf8)) == NULL) { (cmd = utf8_to_utf16(cmd_utf8)) == NULL) {
printf("ssh-shellhost encountered an internal error while decoding base64 cmdline"); printf("ssh-shellhost encountered an internal error while decoding base64 cmdline");
return -1; return -1;

View File

@ -37,7 +37,7 @@ struct agent_connection {
}; };
void agent_connection_on_io(struct agent_connection*, DWORD, OVERLAPPED*); void agent_connection_on_io(struct agent_connection*, DWORD, OVERLAPPED*);
void agent_connection_on_error(struct agent_connection* , DWORD ); void agent_connection_on_error(struct agent_connection* , DWORD);
void agent_connection_disconnect(struct agent_connection*); void agent_connection_disconnect(struct agent_connection*);
void agent_start(BOOL, BOOL, HANDLE); void agent_start(BOOL, BOOL, HANDLE);

View File

@ -39,6 +39,7 @@
#include "w32fd.h" #include "w32fd.h"
#include "tncon.h" #include "tncon.h"
#include "inc\utf.h" #include "inc\utf.h"
#include "tnnet.h"
#define TERM_IO_BUF_SIZE 2048 #define TERM_IO_BUF_SIZE 2048
@ -136,6 +137,7 @@ WriteAPCProc(_In_ ULONG_PTR dwParam)
pio->write_overlapped.hEvent = 0; pio->write_overlapped.hEvent = 0;
} }
/* Write worker thread */ /* Write worker thread */
static DWORD WINAPI static DWORD WINAPI
WriteThread(_In_ LPVOID lpParameter) WriteThread(_In_ LPVOID lpParameter)
@ -146,26 +148,26 @@ WriteThread(_In_ LPVOID lpParameter)
DWORD dwSavedAttributes = ENABLE_PROCESSED_INPUT; DWORD dwSavedAttributes = ENABLE_PROCESSED_INPUT;
debug3("TermWrite thread, io:%p", pio); debug3("TermWrite thread, io:%p", pio);
if (in_raw_mode == 0) { pio->write_details.buf[write_status.to_transfer] = '\0';
/* convert stream to utf16 and dump on console */
pio->write_details.buf[write_status.to_transfer] = '\0'; if (0 == in_raw_mode) {
wchar_t* t = utf8_to_utf16(pio->write_details.buf); wchar_t* t = utf8_to_utf16(pio->write_details.buf);
WriteConsoleW(WINHANDLE(pio), t, wcslen(t), 0, 0); WriteConsoleW(WINHANDLE(pio), t, wcslen(t), 0, 0);
free(t); free(t);
write_status.transferred = write_status.to_transfer;
} else { } else {
/* console mode */ processBuffer(WINHANDLE(pio), pio->write_details.buf, write_status.to_transfer, &respbuf, &resplen);
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 */ /* TODO - respbuf is not null in some cases, this needs to be returned back via read stream */
write_status.transferred = write_status.to_transfer;
} }
write_status.transferred = write_status.to_transfer;
if (0 == QueueUserAPC(WriteAPCProc, main_thread, (ULONG_PTR)pio)) { if (0 == QueueUserAPC(WriteAPCProc, main_thread, (ULONG_PTR)pio)) {
debug("TermWrite thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio); debug("TermWrite thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio);
pio->write_details.pending = FALSE; pio->write_details.pending = FALSE;
pio->write_details.error = GetLastError(); pio->write_details.error = GetLastError();
DebugBreak(); DebugBreak();
} }
return 0; return 0;
} }

View File

@ -1,37 +1,37 @@
/* /*
* Author: Ray Hayes <ray.hayes@microsoft.com> * Author: Ray Hayes <ray.hayes@microsoft.com>
* ANSI TTY Reader - Maps Windows console input events to ANSI stream * ANSI TTY Reader - Maps Windows console input events to ANSI stream
* *
* Author: Balu <bagajjal@microsoft.com> * Author: Balu <bagajjal@microsoft.com>
* Misc fixes and code cleanup * Misc fixes and code cleanup
* *
* Copyright (c) 2017 Microsoft Corp. * Copyright (c) 2017 Microsoft Corp.
* All rights reserved * All rights reserved
* *
* This file is responsible for console reading calls for building an emulator * This file is responsible for console reading calls for building an emulator
* over Windows Console. * over Windows Console.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
@ -75,9 +75,9 @@ TelParams* pParams = &Parameters;
void queue_terminal_window_change_event(); void queue_terminal_window_change_event();
/* /*
* For our case, in NetWriteString2(), we do not use socket, but write the out going data to * For our case, in NetWriteString2(), we do not use socket, but write the out going data to
* a global buffer setup by ReadConsoleForTermEmul(). * a global buffer setup by ReadConsoleForTermEmul().
*/ */
int int
NetWriteString2(SOCKET sock, char* source, size_t len, int options) NetWriteString2(SOCKET sock, char* source, size_t len, int options)
{ {
@ -130,7 +130,7 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen)
break; break;
case FOCUS_EVENT: case FOCUS_EVENT:
/* FALLTHROUGH */ /* FALLTHROUGH */
case MENU_EVENT: case MENU_EVENT:
break; break;
@ -492,7 +492,7 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen)
NetWriteString2(pParams->Socket, (char *)ALT_PF10_KEY, strlen(ALT_PF10_KEY), 0); NetWriteString2(pParams->Socket, (char *)ALT_PF10_KEY, strlen(ALT_PF10_KEY), 0);
else if ((dwControlKeyState & SHIFT_PRESSED) && ((dwControlKeyState & RIGHT_ALT_PRESSED) || else if ((dwControlKeyState & SHIFT_PRESSED) && ((dwControlKeyState & RIGHT_ALT_PRESSED) ||
(dwControlKeyState & LEFT_ALT_PRESSED)) &&((dwControlKeyState & LEFT_CTRL_PRESSED) || (dwControlKeyState & LEFT_ALT_PRESSED)) && ((dwControlKeyState & LEFT_CTRL_PRESSED) ||
(dwControlKeyState & RIGHT_CTRL_PRESSED))) (dwControlKeyState & RIGHT_CTRL_PRESSED)))
NetWriteString2(pParams->Socket, (char *)SHIFT_ALT_CTRL_PF10_KEY, strlen(SHIFT_ALT_CTRL_PF10_KEY), 0); NetWriteString2(pParams->Socket, (char *)SHIFT_ALT_CTRL_PF10_KEY, strlen(SHIFT_ALT_CTRL_PF10_KEY), 0);
@ -521,7 +521,7 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen)
else if (dwControlKeyState == LEFT_ALT_PRESSED || dwControlKeyState == RIGHT_ALT_PRESSED) else if (dwControlKeyState == LEFT_ALT_PRESSED || dwControlKeyState == RIGHT_ALT_PRESSED)
NetWriteString2(pParams->Socket, (char *)ALT_PF11_KEY, strlen(ALT_PF11_KEY), 0); NetWriteString2(pParams->Socket, (char *)ALT_PF11_KEY, strlen(ALT_PF11_KEY), 0);
else if ((dwControlKeyState & SHIFT_PRESSED) &&((dwControlKeyState & RIGHT_ALT_PRESSED) || else if ((dwControlKeyState & SHIFT_PRESSED) && ((dwControlKeyState & RIGHT_ALT_PRESSED) ||
(dwControlKeyState & LEFT_ALT_PRESSED)) && ((dwControlKeyState & LEFT_CTRL_PRESSED) || (dwControlKeyState & LEFT_ALT_PRESSED)) && ((dwControlKeyState & LEFT_CTRL_PRESSED) ||
(dwControlKeyState & RIGHT_CTRL_PRESSED))) (dwControlKeyState & RIGHT_CTRL_PRESSED)))
NetWriteString2(pParams->Socket, (char *)SHIFT_ALT_CTRL_PF11_KEY, strlen(SHIFT_ALT_CTRL_PF11_KEY), 0); NetWriteString2(pParams->Socket, (char *)SHIFT_ALT_CTRL_PF11_KEY, strlen(SHIFT_ALT_CTRL_PF11_KEY), 0);

View File

@ -35,17 +35,20 @@
#include <string.h> #include <string.h>
#include <windows.h> #include <windows.h>
#include "ansiprsr.h" #include "ansiprsr.h"
#include "inc\utf.h"
#define dwBuffer 4096 #define dwBuffer 4096
extern BOOL isAnsiParsingRequired;
/* /*
* Server will always be returning a sequence of ANSI control characters which the client * Server will always be returning a sequence of ANSI control characters which the client
* protocol can either passthru directly to the console or transform based on an output terminal * protocol can either passthru directly to the console or transform based on an output terminal
* type. We're not using termcap so we're only supporting the ANSI (vt100) sequences that * type. We're not using termcap so we're only supporting the ANSI (vt100) sequences that
* are hardcoded in the server and will be transformed to Windows Console commands. * are hardcoded in the server and will be transformed to Windows Console commands.
*/ */
size_t void
telProcessNetwork(char *buf, size_t len, unsigned char **respbuf, size_t *resplen) processBuffer(HANDLE handle, char *buf, size_t len, unsigned char **respbuf, size_t *resplen)
{ {
unsigned char szBuffer[dwBuffer + 8]; unsigned char szBuffer[dwBuffer + 8];
unsigned char* pszNewHead = NULL; unsigned char* pszNewHead = NULL;
@ -53,7 +56,17 @@ telProcessNetwork(char *buf, size_t len, unsigned char **respbuf, size_t *resple
unsigned char* pszTail = NULL; unsigned char* pszTail = NULL;
if (len == 0) if (len == 0)
return len; return;
if (false == isAnsiParsingRequired) {
/* Console has the capability to parse so pass the raw buffer to console directly */
ConRestoreViewRect(); /* Restore the visible window, otherwise WriteConsoleW() gets messy */
wchar_t* t = utf8_to_utf16(buf);
WriteConsoleW(handle, t, wcslen(t), 0, 0);
free(t);
ConSaveViewRect();
return;
}
/* Transform a single carriage return into a single linefeed before continuing */ /* Transform a single carriage return into a single linefeed before continuing */
if ((len == 1) && (buf[0] == 13)) if ((len == 1) && (buf[0] == 13))
@ -74,6 +87,4 @@ telProcessNetwork(char *buf, size_t len, unsigned char **respbuf, size_t *resple
pszNewHead = ParseBuffer(pszHead, pszTail, respbuf, resplen); pszNewHead = ParseBuffer(pszHead, pszTail, respbuf, resplen);
} while ((pszNewHead != pszHead) && (pszNewHead < pszTail) && (resplen == NULL || (resplen != NULL && *resplen == 0))); } while ((pszNewHead != pszHead) && (pszNewHead < pszTail) && (resplen == NULL || (resplen != NULL && *resplen == 0)));
len = 0;
return len;
} }

View File

@ -35,8 +35,6 @@
#ifndef __TNNET_H #ifndef __TNNET_H
#define __TNNET_H #define __TNNET_H
void processBuffer(HANDLE handle, char *buf, size_t len, unsigned char **respbuf, size_t *resplen);
size_t telProcessNetwork (char *buf, size_t len, unsigned char **respbuf, size_t *resplen);
#endif #endif

View File

@ -35,6 +35,7 @@
#include "inc\sys\types.h" #include "inc\sys\types.h"
#include "inc\unistd.h" #include "inc\unistd.h"
#include "inc\fcntl.h" #include "inc\fcntl.h"
#include "inc\sys\un.h"
#include "w32fd.h" #include "w32fd.h"
#include "signal_internal.h" #include "signal_internal.h"
@ -207,13 +208,20 @@ w32_socket(int domain, int type, int protocol)
if (min_index == -1) if (min_index == -1)
return -1; return -1;
pio = socketio_socket(domain, type, protocol); if (domain == AF_UNIX && type == SOCK_STREAM) {
if (pio == NULL) pio = fileio_afunix_socket();
return -1; if (pio == NULL)
return -1;
pio->type = NONSOCK_FD;
} else {
pio = socketio_socket(domain, type, protocol);
if (pio == NULL)
return -1;
pio->type = SOCK_FD;
}
pio->type = SOCK_FD;
fd_table_set(pio, min_index); fd_table_set(pio, min_index);
debug("socket:%d, io:%p, fd:%d ", pio->sock, pio, min_index); debug("socket:%d, socktype:%d, io:%p, fd:%d ", pio->sock, type, pio, min_index);
return min_index; return min_index;
} }
@ -290,6 +298,12 @@ int
w32_connect(int fd, const struct sockaddr* name, int namelen) w32_connect(int fd, const struct sockaddr* name, int namelen)
{ {
CHECK_FD(fd); CHECK_FD(fd);
if (fd_table.w32_ios[fd]->type == NONSOCK_FD) {
struct sockaddr_un* addr = (struct sockaddr_un*)name;
return fileio_connect(fd_table.w32_ios[fd], addr->sun_path);
}
CHECK_SOCK_IO(fd_table.w32_ios[fd]); CHECK_SOCK_IO(fd_table.w32_ios[fd]);
return socketio_connect(fd_table.w32_ios[fd], name, namelen); return socketio_connect(fd_table.w32_ios[fd], name, namelen);
} }
@ -298,6 +312,7 @@ int
w32_recv(int fd, void *buf, size_t len, int flags) w32_recv(int fd, void *buf, size_t len, int flags)
{ {
CHECK_FD(fd); CHECK_FD(fd);
CHECK_SOCK_IO(fd_table.w32_ios[fd]); CHECK_SOCK_IO(fd_table.w32_ios[fd]);
return socketio_recv(fd_table.w32_ios[fd], buf, len, flags); return socketio_recv(fd_table.w32_ios[fd], buf, len, flags);
} }
@ -503,10 +518,16 @@ w32_io_process_fd_flags(struct w32_io* pio, int flags)
shi_flags = (flags & FD_CLOEXEC) ? 0 : HANDLE_FLAG_INHERIT; shi_flags = (flags & FD_CLOEXEC) ? 0 : HANDLE_FLAG_INHERIT;
if (SetHandleInformation(WINHANDLE(pio), HANDLE_FLAG_INHERIT, shi_flags) == FALSE) { if (SetHandleInformation(WINHANDLE(pio), HANDLE_FLAG_INHERIT, shi_flags) == FALSE) {
debug("fcntl - SetHandleInformation failed %d, io:%p", /*
GetLastError(), pio); * Ignore if handle is not valid yet. It will not be valid for
errno = EOTHER; * UF_UNIX sockets that are not connected yet
return -1; */
if (GetLastError() != ERROR_INVALID_HANDLE) {
debug("fcntl - SetHandleInformation failed %d, io:%p",
GetLastError(), pio);
errno = EOTHER;
return -1;
}
} }
pio->fd_flags = flags; pio->fd_flags = flags;

View File

@ -127,6 +127,8 @@ BOOL fileio_is_io_available(struct w32_io* pio, BOOL rd);
void fileio_on_select(struct w32_io* pio, BOOL rd); void fileio_on_select(struct w32_io* pio, BOOL rd);
int fileio_close(struct w32_io* pio); int fileio_close(struct w32_io* pio);
int fileio_pipe(struct w32_io* pio[2]); int fileio_pipe(struct w32_io* pio[2]);
struct w32_io* fileio_afunix_socket();
int fileio_connect(struct w32_io*, char*);
struct w32_io* fileio_open(const char *pathname, int flags, int mode); struct w32_io* fileio_open(const char *pathname, int flags, int mode);
int fileio_read(struct w32_io* pio, void *dst, unsigned int max); int fileio_read(struct w32_io* pio, void *dst, unsigned int max);
int fileio_write(struct w32_io* pio, const void *buf, unsigned int max); int fileio_write(struct w32_io* pio, const void *buf, unsigned int max);

View File

@ -0,0 +1,54 @@
/*
* Temporary Windows versions of functions implemented in utf8.c
*/
#include <stdio.h>
#include <stdarg.h>
int
vfmprintf(FILE *f, const char *fmt, va_list list)
{
return vfprintf(f, fmt, list);
}
int
mprintf(const char *fmt, ...)
{
int ret = 0;
va_list valist;
va_start(valist, fmt);
ret = vfmprintf(stdout, fmt, valist);
va_end(valist);
return ret;
}
int
fmprintf(FILE *f, const char *fmt, ...)
{
int ret = 0;
va_list valist;
va_start(valist, fmt);
ret = vfmprintf(f, fmt, valist);
va_end(valist);
return ret;
}
int
snmprintf(char *buf, size_t len, int *written, const char *fmt, ...)
{
int ret;
va_list valist;
va_start(valist, fmt);
if ((ret = vsnprintf(buf, len, fmt, valist)) >= len)
ret = len;
va_end(valist);
if (written != NULL && ret != -1)
*written = ret;
return ret;
}
void
msetlocale(void)
{
return;
}

View File

@ -34,7 +34,8 @@
#include "inc\utf.h" #include "inc\utf.h"
#include "misc_internal.h" #include "misc_internal.h"
int main(int, char **); int
main(int, char **);
int int
wmain(int argc, wchar_t **wargv) { wmain(int argc, wchar_t **wargv) {
@ -48,6 +49,9 @@ wmain(int argc, wchar_t **wargv) {
argv[i] = utf16_to_utf8(wargv[i]); argv[i] = utf16_to_utf8(wargv[i]);
} }
if (getenv("SSH_AUTH_SOCK") == NULL)
_putenv("SSH_AUTH_SOCK=ssh-agent");
w32posix_initialize(); w32posix_initialize();
r = main(argc, argv); r = main(argc, argv);
w32posix_done(); w32posix_done();

View File

@ -108,6 +108,9 @@ int sshd_main(int argc, wchar_t **wargv) {
argv[i] = utf16_to_utf8(wargv[i]); argv[i] = utf16_to_utf8(wargv[i]);
} }
if (getenv("SSH_AUTH_SOCK") == NULL)
_putenv("SSH_AUTH_SOCK=ssh-agent");
w32posix_initialize(); w32posix_initialize();
if (getenv("SSHD_REMSOC")) if (getenv("SSHD_REMSOC"))
is_child = 1; is_child = 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: digest-openssl.c,v 1.5 2014/12/21 22:27:56 djm Exp $ */ /* $OpenBSD: digest-openssl.c,v 1.6 2017/03/10 02:59:51 dtucker Exp $ */
/* /*
* Copyright (c) 2013 Damien Miller <djm@mindrot.org> * Copyright (c) 2013 Damien Miller <djm@mindrot.org>
* *
@ -158,7 +158,7 @@ ssh_digest_final(struct ssh_digest_ctx *ctx, u_char *d, size_t dlen)
const struct ssh_digest *digest = ssh_digest_by_alg(ctx->alg); const struct ssh_digest *digest = ssh_digest_by_alg(ctx->alg);
u_int l = dlen; u_int l = dlen;
if (dlen > UINT_MAX) if (digest == NULL || dlen > UINT_MAX)
return SSH_ERR_INVALID_ARGUMENT; return SSH_ERR_INVALID_ARGUMENT;
if (dlen < digest->digest_len) /* No truncation allowed */ if (dlen < digest->digest_len) /* No truncation allowed */
return SSH_ERR_INVALID_ARGUMENT; return SSH_ERR_INVALID_ARGUMENT;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hostfile.c,v 1.67 2016/09/17 18:00:27 tedu Exp $ */ /* $OpenBSD: hostfile.c,v 1.68 2017/03/10 04:26:06 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -419,19 +419,24 @@ write_host_entry(FILE *f, const char *host, const char *ip,
const struct sshkey *key, int store_hash) const struct sshkey *key, int store_hash)
{ {
int r, success = 0; int r, success = 0;
char *hashed_host = NULL; char *hashed_host = NULL, *lhost;
lhost = xstrdup(host);
lowercase(lhost);
if (store_hash) { if (store_hash) {
if ((hashed_host = host_hash(host, NULL, 0)) == NULL) { if ((hashed_host = host_hash(lhost, NULL, 0)) == NULL) {
error("%s: host_hash failed", __func__); error("%s: host_hash failed", __func__);
free(lhost);
return 0; return 0;
} }
fprintf(f, "%s ", hashed_host); fprintf(f, "%s ", hashed_host);
} else if (ip != NULL) } else if (ip != NULL)
fprintf(f, "%s,%s ", host, ip); fprintf(f, "%s,%s ", lhost, ip);
else else {
fprintf(f, "%s ", host); fprintf(f, "%s ", lhost);
}
free(lhost);
if ((r = sshkey_write(key, f)) == 0) if ((r = sshkey_write(key, f)) == 0)
success = 1; success = 1;
else else

19
kex.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: kex.c,v 1.128 2017/02/03 23:01:19 djm Exp $ */ /* $OpenBSD: kex.c,v 1.130 2017/03/10 04:07:20 djm Exp $ */
/* /*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
* *
@ -178,7 +178,7 @@ kex_names_valid(const char *names)
char * char *
kex_names_cat(const char *a, const char *b) kex_names_cat(const char *a, const char *b)
{ {
char *ret = NULL, *tmp = NULL, *cp, *p; char *ret = NULL, *tmp = NULL, *cp, *p, *m;
size_t len; size_t len;
if (a == NULL || *a == '\0') if (a == NULL || *a == '\0')
@ -195,8 +195,10 @@ kex_names_cat(const char *a, const char *b)
} }
strlcpy(ret, a, len); strlcpy(ret, a, len);
for ((p = strsep(&cp, ",")); p && *p != '\0'; (p = strsep(&cp, ","))) { for ((p = strsep(&cp, ",")); p && *p != '\0'; (p = strsep(&cp, ","))) {
if (match_list(ret, p, NULL) != NULL) if ((m = match_list(ret, p, NULL)) != NULL) {
free(m);
continue; /* Algorithm already present */ continue; /* Algorithm already present */
}
if (strlcat(ret, ",", len) >= len || if (strlcat(ret, ",", len) >= len ||
strlcat(ret, p, len) >= len) { strlcat(ret, p, len) >= len) {
free(tmp); free(tmp);
@ -348,7 +350,7 @@ kex_send_ext_info(struct ssh *ssh)
int r; int r;
char *algs; char *algs;
if ((algs = sshkey_alg_list(0, 1, ',')) == NULL) if ((algs = sshkey_alg_list(0, 1, 1, ',')) == NULL)
return SSH_ERR_ALLOC_FAIL; return SSH_ERR_ALLOC_FAIL;
if ((r = sshpkt_start(ssh, SSH2_MSG_EXT_INFO)) != 0 || if ((r = sshpkt_start(ssh, SSH2_MSG_EXT_INFO)) != 0 ||
(r = sshpkt_put_u32(ssh, 1)) != 0 || (r = sshpkt_put_u32(ssh, 1)) != 0 ||
@ -651,8 +653,10 @@ choose_enc(struct sshenc *enc, char *client, char *server)
if (name == NULL) if (name == NULL)
return SSH_ERR_NO_CIPHER_ALG_MATCH; return SSH_ERR_NO_CIPHER_ALG_MATCH;
if ((enc->cipher = cipher_by_name(name)) == NULL) if ((enc->cipher = cipher_by_name(name)) == NULL) {
free(name);
return SSH_ERR_INTERNAL_ERROR; return SSH_ERR_INTERNAL_ERROR;
}
enc->name = name; enc->name = name;
enc->enabled = 0; enc->enabled = 0;
enc->iv = NULL; enc->iv = NULL;
@ -670,8 +674,10 @@ choose_mac(struct ssh *ssh, struct sshmac *mac, char *client, char *server)
if (name == NULL) if (name == NULL)
return SSH_ERR_NO_MAC_ALG_MATCH; return SSH_ERR_NO_MAC_ALG_MATCH;
if (mac_setup(mac, name) < 0) if (mac_setup(mac, name) < 0) {
free(name);
return SSH_ERR_INTERNAL_ERROR; return SSH_ERR_INTERNAL_ERROR;
}
/* truncate the key */ /* truncate the key */
if (ssh->compat & SSH_BUG_HMAC) if (ssh->compat & SSH_BUG_HMAC)
mac->key_len = 16; mac->key_len = 16;
@ -695,6 +701,7 @@ choose_comp(struct sshcomp *comp, char *client, char *server)
} else if (strcmp(name, "none") == 0) { } else if (strcmp(name, "none") == 0) {
comp->type = COMP_NONE; comp->type = COMP_NONE;
} else { } else {
free(name);
return SSH_ERR_INTERNAL_ERROR; return SSH_ERR_INTERNAL_ERROR;
} }
comp->name = name; comp->name = name;

5
log.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.48 2016/07/15 05:01:58 dtucker Exp $ */ /* $OpenBSD: log.c,v 1.49 2017/03/10 03:15:58 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -453,7 +453,8 @@ do_log(LogLevel level, const char *fmt, va_list args)
tmp_handler(level, fmtbuf, log_handler_ctx); tmp_handler(level, fmtbuf, log_handler_ctx);
log_handler = tmp_handler; log_handler = tmp_handler;
} else if (log_on_stderr) { } else if (log_on_stderr) {
snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf); snprintf(msgbuf, sizeof msgbuf, "%.*s\r\n",
(int)sizeof msgbuf - 3, fmtbuf);
#ifdef WINDOWS #ifdef WINDOWS
/* /*
* In Windows, write is implemented as part of POSIX compat layer * In Windows, write is implemented as part of POSIX compat layer

19
match.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: match.c,v 1.34 2017/02/03 23:01:19 djm Exp $ */ /* $OpenBSD: match.c,v 1.37 2017/03/10 04:24:55 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -42,9 +42,11 @@
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include "xmalloc.h" #include "xmalloc.h"
#include "match.h" #include "match.h"
#include "misc.h"
/* /*
* Returns true if the given string matches the pattern (which may contain ? * Returns true if the given string matches the pattern (which may contain ?
@ -145,7 +147,7 @@ match_pattern_list(const char *string, const char *pattern, int dolower)
if (subi >= sizeof(sub) - 1) if (subi >= sizeof(sub) - 1)
return 0; return 0;
/* If the subpattern was terminated by a comma, skip the comma. */ /* If the subpattern was terminated by a comma, then skip it. */
if (i < len && pattern[i] == ',') if (i < len && pattern[i] == ',')
i++; i++;
@ -177,7 +179,13 @@ match_pattern_list(const char *string, const char *pattern, int dolower)
int int
match_hostname(const char *host, const char *pattern) match_hostname(const char *host, const char *pattern)
{ {
return match_pattern_list(host, pattern, 1); char *hostcopy = xstrdup(host);
int r;
lowercase(hostcopy);
r = match_pattern_list(hostcopy, pattern, 1);
free(hostcopy);
return r;
} }
/* /*
@ -297,8 +305,11 @@ match_filter_list(const char *proposal, const char *filter)
char *orig_prop = strdup(proposal); char *orig_prop = strdup(proposal);
char *cp, *tmp; char *cp, *tmp;
if (fix_prop == NULL || orig_prop == NULL) if (fix_prop == NULL || orig_prop == NULL) {
free(orig_prop);
free(fix_prop);
return NULL; return NULL;
}
tmp = orig_prop; tmp = orig_prop;
*fix_prop = '\0'; *fix_prop = '\0';

View File

@ -1,4 +1,4 @@
/* $OpenBSD: packet.c,v 1.245 2017/02/03 23:03:33 djm Exp $ */ /* $OpenBSD: packet.c,v 1.246 2017/02/28 06:10:08 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1466,8 +1466,10 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
break; break;
} }
} }
if (r == 0) if (r == 0) {
return SSH_ERR_CONN_TIMEOUT; r = SSH_ERR_CONN_TIMEOUT;
goto out;
}
/* Read data from the socket. */ /* Read data from the socket. */
len = read(state->connection_in, buf, sizeof(buf)); len = read(state->connection_in, buf, sizeof(buf));
if (len == 0) { if (len == 0) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: readconf.c,v 1.268 2017/02/03 23:01:19 djm Exp $ */ /* $OpenBSD: readconf.c,v 1.270 2017/03/10 04:27:32 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1505,6 +1505,7 @@ parse_keytypes:
if (r == GLOB_NOMATCH) { if (r == GLOB_NOMATCH) {
debug("%.200s line %d: include %s matched no " debug("%.200s line %d: include %s matched no "
"files",filename, linenum, arg2); "files",filename, linenum, arg2);
free(arg2);
continue; continue;
} else if (r != 0 || gl.gl_pathc < 0) } else if (r != 0 || gl.gl_pathc < 0)
fatal("%.200s line %d: glob failed for %s.", fatal("%.200s line %d: glob failed for %s.",
@ -1724,7 +1725,7 @@ read_config_file_depth(const char *filename, struct passwd *pw,
int flags, int *activep, int depth) int flags, int *activep, int depth)
{ {
FILE *f; FILE *f;
char line[1024]; char line[4096];
int linenum; int linenum;
int bad_options = 0; int bad_options = 0;
@ -1756,6 +1757,8 @@ read_config_file_depth(const char *filename, struct passwd *pw,
while (fgets(line, sizeof(line), f)) { while (fgets(line, sizeof(line), f)) {
/* Update line number counter. */ /* Update line number counter. */
linenum++; linenum++;
if (strlen(line) == sizeof(line) - 1)
fatal("%s line %d too long", filename, linenum);
if (process_config_line_depth(options, pw, host, original_host, if (process_config_line_depth(options, pw, host, original_host,
line, filename, linenum, activep, flags, depth) != 0) line, filename, linenum, activep, flags, depth) != 0)
bad_options++; bad_options++;

View File

@ -1,4 +1,4 @@
# $OpenBSD: test-exec.sh,v 1.58 2016/12/16 01:06:27 dtucker Exp $ # $OpenBSD: test-exec.sh,v 1.59 2017/02/07 23:03:11 dtucker Exp $
# Placed in the Public Domain. # Placed in the Public Domain.
#SUDO=sudo #SUDO=sudo
@ -444,12 +444,10 @@ Host *
User $USER User $USER
GlobalKnownHostsFile $OBJ/known_hosts GlobalKnownHostsFile $OBJ/known_hosts
UserKnownHostsFile $OBJ/known_hosts UserKnownHostsFile $OBJ/known_hosts
RSAAuthentication yes
PubkeyAuthentication yes PubkeyAuthentication yes
ChallengeResponseAuthentication no ChallengeResponseAuthentication no
HostbasedAuthentication no HostbasedAuthentication no
PasswordAuthentication no PasswordAuthentication no
RhostsRSAAuthentication no
BatchMode yes BatchMode yes
StrictHostKeyChecking yes StrictHostKeyChecking yes
LogLevel DEBUG3 LogLevel DEBUG3

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tests.c,v 1.3 2016/12/19 04:55:18 djm Exp $ */ /* $OpenBSD: tests.c,v 1.4 2017/02/19 00:11:29 djm Exp $ */
/* /*
* Regress test for the utf8.h *mprintf() API * Regress test for the utf8.h *mprintf() API
* *
@ -15,10 +15,7 @@
#include "utf8.h" #include "utf8.h"
void badarg(void); static void
void one(const char *, const char *, int, int, int, const char *);
void
badarg(void) badarg(void)
{ {
char buf[16]; char buf[16];
@ -33,8 +30,8 @@ badarg(void)
TEST_DONE(); TEST_DONE();
} }
void static void
one(const char *name, const char *mbs, int width, one(int utf8, const char *name, const char *mbs, int width,
int wantwidth, int wantlen, const char *wants) int wantwidth, int wantlen, const char *wants)
{ {
char buf[16]; char buf[16];
@ -43,7 +40,7 @@ one(const char *name, const char *mbs, int width,
if (wantlen == -2) if (wantlen == -2)
wantlen = strlen(wants); wantlen = strlen(wants);
(void)strlcpy(buf, "utf8_", sizeof(buf)); (void)strlcpy(buf, utf8 ? "utf8_" : "c_", sizeof(buf));
(void)strlcat(buf, name, sizeof(buf)); (void)strlcat(buf, name, sizeof(buf));
TEST_START(buf); TEST_START(buf);
wp = wantwidth == -2 ? NULL : &width; wp = wantwidth == -2 ? NULL : &width;
@ -70,19 +67,41 @@ tests(void)
TEST_DONE(); TEST_DONE();
badarg(); badarg();
one("empty", "", 2, 0, 0, ""); one(1, "empty", "", 2, 0, 0, "");
one("ascii", "x", -2, -2, -2, "x"); one(1, "ascii", "x", -2, -2, -2, "x");
one("newline", "a\nb", -2, -2, -2, "a\nb"); one(1, "newline", "a\nb", -2, -2, -2, "a\nb");
one("cr", "a\rb", -2, -2, -2, "a\rb"); one(1, "cr", "a\rb", -2, -2, -2, "a\rb");
one("tab", "a\tb", -2, -2, -2, "a\tb"); one(1, "tab", "a\tb", -2, -2, -2, "a\tb");
one("esc", "\033x", -2, -2, -2, "\\033x"); one(1, "esc", "\033x", -2, -2, -2, "\\033x");
one("inv_badbyte", "\377x", -2, -2, -2, "\\377x"); one(1, "inv_badbyte", "\377x", -2, -2, -2, "\\377x");
one("inv_nocont", "\341x", -2, -2, -2, "\\341x"); one(1, "inv_nocont", "\341x", -2, -2, -2, "\\341x");
one("inv_nolead", "a\200b", -2, -2, -2, "a\\200b"); one(1, "inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
one("sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345"); one(1, "sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
one("sz_esc", "123456789012\033", -2, -2, 16, "123456789012"); one(1, "sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
one("width_ascii", "123", 2, 2, -1, "12"); one(1, "width_ascii", "123", 2, 2, -1, "12");
one("width_double", "a\343\201\201", 2, 1, -1, "a"); one(1, "width_double", "a\343\201\201", 2, 1, -1, "a");
one("double_fit", "a\343\201\201", 3, 3, 4, "a\343\201\201"); one(1, "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"); one(1, "double_spc", "a\343\201\201", 4, 3, 4, "a\343\201\201");
TEST_START("C_setlocale");
loc = setlocale(LC_CTYPE, "C");
ASSERT_PTR_NE(loc, NULL);
TEST_DONE();
badarg();
one(0, "empty", "", 2, 0, 0, "");
one(0, "ascii", "x", -2, -2, -2, "x");
one(0, "newline", "a\nb", -2, -2, -2, "a\nb");
one(0, "cr", "a\rb", -2, -2, -2, "a\rb");
one(0, "tab", "a\tb", -2, -2, -2, "a\tb");
one(0, "esc", "\033x", -2, -2, -2, "\\033x");
one(0, "inv_badbyte", "\377x", -2, -2, -2, "\\377x");
one(0, "inv_nocont", "\341x", -2, -2, -2, "\\341x");
one(0, "inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
one(0, "sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
one(0, "sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
one(0, "width_ascii", "123", 2, 2, -1, "12");
one(0, "width_double", "a\343\201\201", 2, 1, -1, "a");
one(0, "double_fit", "a\343\201\201", 7, 5, -1, "a\\343");
one(0, "double_spc", "a\343\201\201", 13, 13, 13, "a\\343\\201\\201");
} }

20
scp.c
View File

@ -1034,17 +1034,7 @@ rsource(char *name, struct stat *statp)
(void) snprintf(path, sizeof path, "D%04o %d %.1024s\n", (void) snprintf(path, sizeof path, "D%04o %d %.1024s\n",
(u_int) (statp->st_mode & FILEMODEMASK), 0, last); (u_int) (statp->st_mode & FILEMODEMASK), 0, last);
if (verbose_mode) if (verbose_mode)
#ifdef WINDOWS
/* TODO - make fmprintf work for Windows */
{
printf("Entering directory: ");
wchar_t* wtmp = utf8_to_utf16(path);
WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), wtmp, wcslen(wtmp), 0, 0);
free(wtmp);
}
#else /* !WINDOWS */
fmprintf(stderr, "Entering directory: %s", path); fmprintf(stderr, "Entering directory: %s", path);
#endif /* !WINDOWS */
(void) atomicio(vwrite, remout, path, strlen(path)); (void) atomicio(vwrite, remout, path, strlen(path));
if (response() < 0) { if (response() < 0) {
closedir(dirp); closedir(dirp);
@ -1119,17 +1109,7 @@ sink(int argc, char **argv)
} while (cp < &buf[sizeof(buf) - 1] && ch != '\n'); } while (cp < &buf[sizeof(buf) - 1] && ch != '\n');
*cp = 0; *cp = 0;
if (verbose_mode) if (verbose_mode)
#ifdef WINDOWS
/* TODO - make fmprintf work for Windows */
{
printf("Sink: ");
wchar_t* wtmp = utf8_to_utf16(buf);
WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), wtmp, wcslen(wtmp), 0, 0);
free(wtmp);
}
#else /* !WINDOWS */
fmprintf(stderr, "Sink: %s", buf); fmprintf(stderr, "Sink: %s", buf);
#endif /* !WINDOWS */
if (buf[0] == '\01' || buf[0] == '\02') { if (buf[0] == '\01' || buf[0] == '\02') {
if (iamremote == 0) { if (iamremote == 0) {

View File

@ -1,5 +1,5 @@
/* $OpenBSD: servconf.c,v 1.304 2017/02/03 23:01:19 djm Exp $ */ /* $OpenBSD: servconf.c,v 1.305 2017/03/10 04:11:00 dtucker Exp $ */
/* /*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved * All rights reserved
@ -2164,8 +2164,6 @@ dump_cfg_fmtint(ServerOpCodes code, int val)
static void static void
dump_cfg_string(ServerOpCodes code, const char *val) dump_cfg_string(ServerOpCodes code, const char *val)
{ {
if (val == NULL)
return;
printf("%s %s\n", lookup_opcode_name(code), printf("%s %s\n", lookup_opcode_name(code),
val == NULL ? "none" : val); val == NULL ? "none" : val);
} }

View File

@ -482,6 +482,9 @@ int do_exec_windows(Session *s, const char *command, int pty) {
fcntl(pipeout[0], F_SETFD, FD_CLOEXEC); fcntl(pipeout[0], F_SETFD, FD_CLOEXEC);
fcntl(pipeerr[0], F_SETFD, FD_CLOEXEC); fcntl(pipeerr[0], F_SETFD, FD_CLOEXEC);
/* setup Environment varibles */
setup_session_vars(s);
/* prepare exec - path used with CreateProcess() */ /* prepare exec - path used with CreateProcess() */
if (s->is_subsystem || (command && memcmp(command, "scp", 3) == 0)) { if (s->is_subsystem || (command && memcmp(command, "scp", 3) == 0)) {
/* relative or absolute */ /* relative or absolute */
@ -530,17 +533,13 @@ int do_exec_windows(Session *s, const char *command, int pty) {
*c = '\0'; *c = '\0';
} }
/* setup Environment varibles */
setup_session_vars(s);
extern int debug_flag;
/* start the process */ /* start the process */
{ {
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFOW si; STARTUPINFOW si;
BOOL b; BOOL b;
HANDLE hToken = INVALID_HANDLE_VALUE; HANDLE hToken = INVALID_HANDLE_VALUE;
extern int debug_flag;
memset(&si, 0, sizeof(STARTUPINFO)); memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);

127
sftp.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: sftp.c,v 1.177 2016/10/18 12:41:22 millert Exp $ */ /* $OpenBSD: sftp.c,v 1.178 2017/02/15 01:46:47 djm Exp $ */
/* /*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
* *
@ -292,27 +292,6 @@ help(void)
"? Synonym for help\n"); "? Synonym for help\n");
} }
#ifdef WINDOWS
/* 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];
int length = 0;
va_list valist;
va_start(valist, fmt);
length = vsnprintf(buf, 1024, fmt, valist);
va_end(valist);
write(STDOUT_FILENO, buf, length);
}
/* override mprintf */
#define mprintf(a,...) printf_utf8((a), __VA_ARGS__)
#define printf(a,...) printf_utf8((a), __VA_ARGS__)
#endif /* WINDOWS */
static void static void
local_do_shell(const char *args) local_do_shell(const char *args)
{ {
@ -420,7 +399,7 @@ make_absolute(char *p, const char *pwd)
p = abs_str; p = abs_str;
} }
/* convert '\\' tp '/' */ /* convert '\\' to '/' */
convertToForwardslash(p); convertToForwardslash(p);
/* Append "/" if needed to the absolute windows path */ /* Append "/" if needed to the absolute windows path */
@ -925,23 +904,7 @@ do_ls_dir(struct sftp_conn *conn, const char *path,
} else } else
mprintf("%s\n", d[n]->longname); mprintf("%s\n", d[n]->longname);
} else { } else {
#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);
if ((p = utf16_to_utf8(buf)) == NULL)
continue;
write(STDOUT_FILENO, p, strlen(p));
free(wtmp);
free(p);
#else
mprintf("%-*s", colspace, fname); mprintf("%-*s", colspace, fname);
#endif
if (c >= columns) { if (c >= columns) {
printf("\n"); printf("\n");
c = 1; c = 1;
@ -1025,23 +988,7 @@ do_globbed_ls(struct sftp_conn *conn, const char *path,
mprintf("%s\n", lname); mprintf("%s\n", lname);
free(lname); free(lname);
} else { } else {
#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);
if ((p = utf16_to_utf8(buf)) == NULL)
continue;
write(STDOUT_FILENO, p, strlen(p));
free(wtmp);
free(p);
#else
mprintf("%-*s", colspace, fname); mprintf("%-*s", colspace, fname);
#endif
if (c >= columns) { if (c >= columns) {
printf("\n"); printf("\n");
c = 1; c = 1;
@ -1065,23 +1012,34 @@ static int
do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag) do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag)
{ {
struct sftp_statvfs st; struct sftp_statvfs st;
char s_used[FMT_SCALED_STRSIZE]; char s_used[FMT_SCALED_STRSIZE], s_avail[FMT_SCALED_STRSIZE];
char s_avail[FMT_SCALED_STRSIZE]; char s_root[FMT_SCALED_STRSIZE], s_total[FMT_SCALED_STRSIZE];
char s_root[FMT_SCALED_STRSIZE]; char s_icapacity[16], s_dcapacity[16];
char s_total[FMT_SCALED_STRSIZE];
unsigned long long ffree;
if (do_statvfs(conn, path, &st, 1) == -1) if (do_statvfs(conn, path, &st, 1) == -1)
return -1; return -1;
if (st.f_files == 0)
strlcpy(s_icapacity, "ERR", sizeof(s_icapacity));
else {
snprintf(s_icapacity, sizeof(s_icapacity), "%3llu%%",
(unsigned long long)(100 * (st.f_files - st.f_ffree) /
st.f_files));
}
if (st.f_blocks == 0)
strlcpy(s_dcapacity, "ERR", sizeof(s_dcapacity));
else {
snprintf(s_dcapacity, sizeof(s_dcapacity), "%3llu%%",
(unsigned long long)(100 * (st.f_blocks - st.f_bfree) /
st.f_blocks));
}
if (iflag) { if (iflag) {
ffree = st.f_files ? (100 * (st.f_files - st.f_ffree) / st.f_files) : 0;
printf(" Inodes Used Avail " printf(" Inodes Used Avail "
"(root) %%Capacity\n"); "(root) %%Capacity\n");
printf("%11llu %11llu %11llu %11llu %3llu%%\n", printf("%11llu %11llu %11llu %11llu %s\n",
(unsigned long long)st.f_files, (unsigned long long)st.f_files,
(unsigned long long)(st.f_files - st.f_ffree), (unsigned long long)(st.f_files - st.f_ffree),
(unsigned long long)st.f_favail, (unsigned long long)st.f_favail,
(unsigned long long)st.f_ffree, ffree); (unsigned long long)st.f_ffree, s_icapacity);
} else if (hflag) { } else if (hflag) {
strlcpy(s_used, "error", sizeof(s_used)); strlcpy(s_used, "error", sizeof(s_used));
strlcpy(s_avail, "error", sizeof(s_avail)); strlcpy(s_avail, "error", sizeof(s_avail));
@ -1092,21 +1050,18 @@ do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag)
fmt_scaled(st.f_bfree * st.f_frsize, s_root); fmt_scaled(st.f_bfree * st.f_frsize, s_root);
fmt_scaled(st.f_blocks * st.f_frsize, s_total); fmt_scaled(st.f_blocks * st.f_frsize, s_total);
printf(" Size Used Avail (root) %%Capacity\n"); printf(" Size Used Avail (root) %%Capacity\n");
printf("%7sB %7sB %7sB %7sB %3llu%%\n", printf("%7sB %7sB %7sB %7sB %s\n",
s_total, s_used, s_avail, s_root, s_total, s_used, s_avail, s_root, s_dcapacity);
(unsigned long long)(100 * (st.f_blocks - st.f_bfree) /
st.f_blocks));
} else { } else {
printf(" Size Used Avail " printf(" Size Used Avail "
"(root) %%Capacity\n"); "(root) %%Capacity\n");
printf("%12llu %12llu %12llu %12llu %3llu%%\n", printf("%12llu %12llu %12llu %12llu %s\n",
(unsigned long long)(st.f_frsize * st.f_blocks / 1024), (unsigned long long)(st.f_frsize * st.f_blocks / 1024),
(unsigned long long)(st.f_frsize * (unsigned long long)(st.f_frsize *
(st.f_blocks - st.f_bfree) / 1024), (st.f_blocks - st.f_bfree) / 1024),
(unsigned long long)(st.f_frsize * st.f_bavail / 1024), (unsigned long long)(st.f_frsize * st.f_bavail / 1024),
(unsigned long long)(st.f_frsize * st.f_bfree / 1024), (unsigned long long)(st.f_frsize * st.f_bfree / 1024),
(unsigned long long)(100 * (st.f_blocks - st.f_bfree) / s_dcapacity);
st.f_blocks));
} }
return 0; return 0;
} }
@ -2211,20 +2166,8 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
interactive = !batchmode && isatty(STDIN_FILENO); interactive = !batchmode && isatty(STDIN_FILENO);
err = 0; err = 0;
#ifdef WINDOWS
/* Min buffer size allowed in Windows is 2*/
setvbuf(stdout, 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);
_setmode(_fileno(stdin), O_U16TEXT); /* prepare for Unicode input */
}
#else /* !WINDOWS */
setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf(infile, NULL, _IOLBF, 0); setvbuf(infile, NULL, _IOLBF, 0);
#endif /* !WINDOWS */
for (;;) { for (;;) {
char *cp; char *cp;
@ -2232,25 +2175,6 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
if (el == NULL) { if (el == NULL) {
#ifdef WINDOWS
/* fgets on Windows does not support Unicode input*/
if (interactive) {
wchar_t wcmd[2048];
printf("sftp> ");
if (fgetws(wcmd, sizeof(cmd)/sizeof(wchar_t), infile) == NULL) {
printf("\n");
break;
}
else {
char *pcmd = NULL;
if ((pcmd = utf16_to_utf8(wcmd)) == NULL)
fatal("failed to convert input arguments");
strcpy(cmd, pcmd);
free(pcmd);
}
} else if (fgets(cmd, sizeof(cmd), infile) == NULL)
break;
#else /* !WINDOWS */
if (interactive) if (interactive)
printf("sftp> "); printf("sftp> ");
if (fgets(cmd, sizeof(cmd), infile) == NULL) { if (fgets(cmd, sizeof(cmd), infile) == NULL) {
@ -2258,7 +2182,6 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
printf("\n"); printf("\n");
break; break;
} }
#endif/* !WINDOWS */
if (!interactive) { /* Echo command */ if (!interactive) { /* Echo command */
mprintf("sftp> %s", cmd); mprintf("sftp> %s", cmd);
if (strlen(cmd) > 0 && if (strlen(cmd) > 0 &&

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-keygen.c,v 1.292 2016/09/12 03:29:16 dtucker Exp $ */ /* $OpenBSD: ssh-keygen.c,v 1.299 2017/03/10 04:26:06 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -37,6 +37,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h> #include <limits.h>
#include <locale.h>
#include "xmalloc.h" #include "xmalloc.h"
#include "sshkey.h" #include "sshkey.h"
@ -57,6 +58,7 @@
#include "atomicio.h" #include "atomicio.h"
#include "krl.h" #include "krl.h"
#include "digest.h" #include "digest.h"
#include "utf8.h"
#ifdef WITH_OPENSSL #ifdef WITH_OPENSSL
# define DEFAULT_KEY_TYPE_NAME "rsa" # define DEFAULT_KEY_TYPE_NAME "rsa"
@ -847,7 +849,7 @@ fingerprint_one_key(const struct sshkey *public, const char *comment)
ra = sshkey_fingerprint(public, fingerprint_hash, SSH_FP_RANDOMART); ra = sshkey_fingerprint(public, fingerprint_hash, SSH_FP_RANDOMART);
if (fp == NULL || ra == NULL) if (fp == NULL || ra == NULL)
fatal("%s: sshkey_fingerprint failed", __func__); fatal("%s: sshkey_fingerprint failed", __func__);
printf("%u %s %s (%s)\n", sshkey_size(public), fp, mprintf("%u %s %s (%s)\n", sshkey_size(public), fp,
comment ? comment : "no comment", sshkey_type(public)); comment ? comment : "no comment", sshkey_type(public));
if (log_level >= SYSLOG_LEVEL_VERBOSE) if (log_level >= SYSLOG_LEVEL_VERBOSE)
printf("%s\n", ra); printf("%s\n", ra);
@ -1093,6 +1095,7 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx)
struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx; struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx;
char *hashed, *cp, *hosts, *ohosts; char *hashed, *cp, *hosts, *ohosts;
int has_wild = l->hosts && strcspn(l->hosts, "*?!") != strlen(l->hosts); int has_wild = l->hosts && strcspn(l->hosts, "*?!") != strlen(l->hosts);
int was_hashed = l->hosts && l->hosts[0] == HASH_DELIM;
switch (l->status) { switch (l->status) {
case HKF_STATUS_OK: case HKF_STATUS_OK:
@ -1101,11 +1104,10 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx)
* Don't hash hosts already already hashed, with wildcard * Don't hash hosts already already hashed, with wildcard
* characters or a CA/revocation marker. * characters or a CA/revocation marker.
*/ */
if ((l->match & HKF_MATCH_HOST_HASHED) != 0 || if (was_hashed || has_wild || l->marker != MRK_NONE) {
has_wild || l->marker != MRK_NONE) {
fprintf(ctx->out, "%s\n", l->line); fprintf(ctx->out, "%s\n", l->line);
if (has_wild && !find_host) { if (has_wild && !find_host) {
logit("%s:%ld: ignoring host name " logit("%s:%lu: ignoring host name "
"with wildcard: %.64s", l->path, "with wildcard: %.64s", l->path,
l->linenum, l->hosts); l->linenum, l->hosts);
} }
@ -1117,6 +1119,7 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx)
*/ */
ohosts = hosts = xstrdup(l->hosts); ohosts = hosts = xstrdup(l->hosts);
while ((cp = strsep(&hosts, ",")) != NULL && *cp != '\0') { while ((cp = strsep(&hosts, ",")) != NULL && *cp != '\0') {
lowercase(cp);
if ((hashed = host_hash(cp, NULL, 0)) == NULL) if ((hashed = host_hash(cp, NULL, 0)) == NULL)
fatal("hash_host failed"); fatal("hash_host failed");
fprintf(ctx->out, "%s %s\n", hashed, l->rawkey); fprintf(ctx->out, "%s %s\n", hashed, l->rawkey);
@ -1127,7 +1130,7 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx)
case HKF_STATUS_INVALID: case HKF_STATUS_INVALID:
/* Retain invalid lines, but mark file as invalid. */ /* Retain invalid lines, but mark file as invalid. */
ctx->invalid = 1; ctx->invalid = 1;
logit("%s:%ld: invalid line", l->path, l->linenum); logit("%s:%lu: invalid line", l->path, l->linenum);
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
fprintf(ctx->out, "%s\n", l->line); fprintf(ctx->out, "%s\n", l->line);
@ -1161,14 +1164,14 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
*/ */
ctx->found_key = 1; ctx->found_key = 1;
if (!quiet) if (!quiet)
printf("# Host %s found: line %ld\n", printf("# Host %s found: line %lu\n",
ctx->host, l->linenum); ctx->host, l->linenum);
} }
return 0; return 0;
} else if (find_host) { } else if (find_host) {
ctx->found_key = 1; ctx->found_key = 1;
if (!quiet) { if (!quiet) {
printf("# Host %s found: line %ld %s\n", printf("# Host %s found: line %lu %s\n",
ctx->host, ctx->host,
l->linenum, l->marker == MRK_CA ? "CA" : l->linenum, l->marker == MRK_CA ? "CA" :
(l->marker == MRK_REVOKE ? "REVOKED" : "")); (l->marker == MRK_REVOKE ? "REVOKED" : ""));
@ -1177,7 +1180,7 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
known_hosts_hash(l, ctx); known_hosts_hash(l, ctx);
else if (print_fingerprint) { else if (print_fingerprint) {
fp = sshkey_fingerprint(l->key, fptype, rep); fp = sshkey_fingerprint(l->key, fptype, rep);
printf("%s %s %s %s\n", ctx->host, mprintf("%s %s %s %s\n", ctx->host,
sshkey_type(l->key), fp, l->comment); sshkey_type(l->key), fp, l->comment);
free(fp); free(fp);
} else } else
@ -1188,7 +1191,7 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
/* Retain non-matching hosts when deleting */ /* Retain non-matching hosts when deleting */
if (l->status == HKF_STATUS_INVALID) { if (l->status == HKF_STATUS_INVALID) {
ctx->invalid = 1; ctx->invalid = 1;
logit("%s:%ld: invalid line", l->path, l->linenum); logit("%s:%lu: invalid line", l->path, l->linenum);
} }
fprintf(ctx->out, "%s\n", l->line); fprintf(ctx->out, "%s\n", l->line);
} }
@ -1333,7 +1336,7 @@ do_change_passphrase(struct passwd *pw)
fatal("Failed to load key %s: %s", identity_file, ssh_err(r)); fatal("Failed to load key %s: %s", identity_file, ssh_err(r));
} }
if (comment) if (comment)
printf("Key has comment '%s'\n", comment); mprintf("Key has comment '%s'\n", comment);
/* Ask the new passphrase (twice). */ /* Ask the new passphrase (twice). */
if (identity_new_passphrase) { if (identity_new_passphrase) {
@ -1457,7 +1460,10 @@ do_change_comment(struct passwd *pw)
sshkey_free(private); sshkey_free(private);
exit(1); exit(1);
} }
printf("Key now has comment '%s'\n", comment); if (comment)
printf("Key now has comment '%s'\n", comment);
else
printf("Key now has no comment\n");
if (identity_comment) { if (identity_comment) {
strlcpy(new_comment, identity_comment, sizeof(new_comment)); strlcpy(new_comment, identity_comment, sizeof(new_comment));
@ -2220,11 +2226,17 @@ do_check_krl(struct passwd *pw, int argc, char **argv)
exit(ret); exit(ret);
} }
#ifdef WITH_SSH1
# define RSA1_USAGE " | rsa1"
#else
# define RSA1_USAGE ""
#endif
static void static void
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"usage: ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa | rsa1]\n" "usage: ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa%s]\n"
" [-N new_passphrase] [-C comment] [-f output_keyfile]\n" " [-N new_passphrase] [-C comment] [-f output_keyfile]\n"
" ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]\n" " ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]\n"
" ssh-keygen -i [-m key_format] [-f input_keyfile]\n" " ssh-keygen -i [-m key_format] [-f input_keyfile]\n"
@ -2232,7 +2244,7 @@ usage(void)
" ssh-keygen -y [-f input_keyfile]\n" " ssh-keygen -y [-f input_keyfile]\n"
" ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]\n" " ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]\n"
" ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile]\n" " ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile]\n"
" ssh-keygen -B [-f input_keyfile]\n"); " ssh-keygen -B [-f input_keyfile]\n", RSA1_USAGE);
#ifdef ENABLE_PKCS11 #ifdef ENABLE_PKCS11
fprintf(stderr, fprintf(stderr,
" ssh-keygen -D pkcs11\n"); " ssh-keygen -D pkcs11\n");
@ -2297,6 +2309,8 @@ main(int argc, char **argv)
seed_rng(); seed_rng();
msetlocale();
/* we need this for the home * directory. */ /* we need this for the home * directory. */
pw = getpwuid(getuid()); pw = getpwuid(getuid());
if (!pw) if (!pw)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-keyscan.c,v 1.107 2017/01/06 03:41:58 djm Exp $ */ /* $OpenBSD: ssh-keyscan.c,v 1.109 2017/03/10 04:26:06 djm Exp $ */
/* /*
* Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
* *
@ -321,16 +321,18 @@ keygrab_ssh2(con *c)
} }
static void static void
keyprint_one(char *host, struct sshkey *key) keyprint_one(const char *host, struct sshkey *key)
{ {
char *hostport; char *hostport;
const char *known_host, *hashed;
if (hash_hosts && (host = host_hash(host, NULL, 0)) == NULL)
fatal("host_hash failed");
hostport = put_host_port(host, ssh_port); hostport = put_host_port(host, ssh_port);
lowercase(hostport);
if (hash_hosts && (hashed = host_hash(host, NULL, 0)) == NULL)
fatal("host_hash failed");
known_host = hash_hosts ? hashed : hostport;
if (!get_cert) if (!get_cert)
fprintf(stdout, "%s ", hostport); fprintf(stdout, "%s ", known_host);
sshkey_write(key, stdout); sshkey_write(key, stdout);
fputs("\n", stdout); fputs("\n", stdout);
free(hostport); free(hostport);

10
ssh.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: ssh.c,v 1.448 2016/12/06 07:48:01 djm Exp $ */ /* $OpenBSD: ssh.c,v 1.451 2017/03/10 04:07:20 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -684,11 +684,11 @@ main(int ac, char **av)
else if (strcmp(optarg, "kex") == 0) else if (strcmp(optarg, "kex") == 0)
cp = kex_alg_list('\n'); cp = kex_alg_list('\n');
else if (strcmp(optarg, "key") == 0) else if (strcmp(optarg, "key") == 0)
cp = sshkey_alg_list(0, 0, '\n'); cp = sshkey_alg_list(0, 0, 0, '\n');
else if (strcmp(optarg, "key-cert") == 0) else if (strcmp(optarg, "key-cert") == 0)
cp = sshkey_alg_list(1, 0, '\n'); cp = sshkey_alg_list(1, 0, 0, '\n');
else if (strcmp(optarg, "key-plain") == 0) else if (strcmp(optarg, "key-plain") == 0)
cp = sshkey_alg_list(0, 1, '\n'); cp = sshkey_alg_list(0, 1, 0, '\n');
else if (strcmp(optarg, "protocol-version") == 0) { else if (strcmp(optarg, "protocol-version") == 0) {
#ifdef WITH_SSH1 #ifdef WITH_SSH1
cp = xstrdup("1\n2"); cp = xstrdup("1\n2");
@ -1103,7 +1103,7 @@ main(int ac, char **av)
options.proxy_use_fdpass = 0; options.proxy_use_fdpass = 0;
snprintf(port_s, sizeof(port_s), "%d", options.jump_port); snprintf(port_s, sizeof(port_s), "%d", options.jump_port);
xasprintf(&options.proxy_command, xasprintf(&options.proxy_command,
"ssh%s%s%s%s%s%s%s%s%s%.*s -W %%h:%%p %s", "ssh%s%s%s%s%s%s%s%s%s%.*s -W '[%%h]:%%p' %s",
/* Optional "-l user" argument if jump_user set */ /* Optional "-l user" argument if jump_user set */
options.jump_user == NULL ? "" : " -l ", options.jump_user == NULL ? "" : " -l ",
options.jump_user == NULL ? "" : options.jump_user, options.jump_user == NULL ? "" : options.jump_user,

View File

@ -33,8 +33,8 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: ssh_config.5,v 1.241 2017/02/03 23:01:19 djm Exp $ .\" $OpenBSD: ssh_config.5,v 1.242 2017/02/27 14:30:33 jmc Exp $
.Dd $Mdocdate: February 3 2017 $ .Dd $Mdocdate: February 27 2017 $
.Dt SSH_CONFIG 5 .Dt SSH_CONFIG 5
.Os .Os
.Sh NAME .Sh NAME
@ -1147,7 +1147,7 @@ However, this option disables host authentication for localhost.
The argument to this keyword must be The argument to this keyword must be
.Cm yes .Cm yes
or or
.Cm no . .Cm no
(the default). (the default).
.It Cm NumberOfPasswordPrompts .It Cm NumberOfPasswordPrompts
Specifies the number of password prompts before giving up. Specifies the number of password prompts before giving up.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sshconnect.c,v 1.272 2016/09/12 01:22:38 deraadt Exp $ */ /* $OpenBSD: sshconnect.c,v 1.273 2017/03/10 03:22:40 dtucker Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1553,6 +1553,7 @@ maybe_add_key_to_agent(char *authfile, Key *private, char *comment,
if (options.add_keys_to_agent == 2 && if (options.add_keys_to_agent == 2 &&
!ask_permission("Add key %s (%s) to agent?", authfile, comment)) { !ask_permission("Add key %s (%s) to agent?", authfile, comment)) {
debug3("user denied adding this key"); debug3("user denied adding this key");
close(auth_sock);
return; return;
} }
@ -1561,4 +1562,5 @@ maybe_add_key_to_agent(char *authfile, Key *private, char *comment,
debug("identity added to agent: %s", authfile); debug("identity added to agent: %s", authfile);
else else
debug("could not add identity to agent: %s (%d)", authfile, r); debug("could not add identity to agent: %s (%d)", authfile, r);
close(auth_sock);
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sshconnect1.c,v 1.79 2016/09/19 07:52:42 natano Exp $ */ /* $OpenBSD: sshconnect1.c,v 1.80 2017/03/10 03:53:11 dtucker Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -520,7 +520,8 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
cookie[i] = packet_get_char(); cookie[i] = packet_get_char();
/* Get the public key. */ /* Get the public key. */
server_key = key_new(KEY_RSA1); if ((server_key = key_new(KEY_RSA1)) == NULL)
fatal("%s: key_new(KEY_RSA1) failed", __func__);
bits = packet_get_int(); bits = packet_get_int();
packet_get_bignum(server_key->rsa->e); packet_get_bignum(server_key->rsa->e);
packet_get_bignum(server_key->rsa->n); packet_get_bignum(server_key->rsa->n);
@ -532,7 +533,8 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
logit("Warning: This may be due to an old implementation of ssh."); logit("Warning: This may be due to an old implementation of ssh.");
} }
/* Get the host key. */ /* Get the host key. */
host_key = key_new(KEY_RSA1); if ((host_key = key_new(KEY_RSA1)) == NULL)
fatal("%s: key_new(KEY_RSA1) failed", __func__);
bits = packet_get_int(); bits = packet_get_int();
packet_get_bignum(host_key->rsa->e); packet_get_bignum(host_key->rsa->e);
packet_get_bignum(host_key->rsa->n); packet_get_bignum(host_key->rsa->n);

10
sshd.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: sshd.c,v 1.482 2017/02/06 09:22:51 djm Exp $ */ /* $OpenBSD: sshd.c,v 1.483 2017/02/24 03:16:34 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1084,15 +1084,11 @@ server_listen(void)
close(listen_sock); close(listen_sock);
continue; continue;
} }
#ifdef WINDOWS if (fcntl(listen_sock, F_SETFD, FD_CLOEXEC) == -1) {
/* disable inheritance on listener socket */ verbose("socket: CLOEXEC: %s", strerror(errno));
if (fcntl(listen_sock, F_SETFD, FD_CLOEXEC) != 0) {
error("F_SETFD FD_CLOEXEC on socket %d error %d",
listen_sock, errno);
close(listen_sock); close(listen_sock);
continue; continue;
} }
#endif /* WINDOWS */
/* /*
* Set socket options. * Set socket options.
* Allow local port reuse in TIME_WAIT. * Allow local port reuse in TIME_WAIT.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sshkey.c,v 1.41 2016/10/24 01:09:17 dtucker Exp $ */ /* $OpenBSD: sshkey.c,v 1.45 2017/03/10 04:07:20 djm Exp $ */
/* /*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2008 Alexander von Gernler. All rights reserved. * Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@ -89,7 +89,9 @@ static const struct keytype keytypes[] = {
{ "ssh-ed25519-cert-v01@openssh.com", "ED25519-CERT", { "ssh-ed25519-cert-v01@openssh.com", "ED25519-CERT",
KEY_ED25519_CERT, 0, 1, 0 }, KEY_ED25519_CERT, 0, 1, 0 },
#ifdef WITH_OPENSSL #ifdef WITH_OPENSSL
# ifdef WITH_SSH1
{ NULL, "RSA1", KEY_RSA1, 0, 0, 0 }, { NULL, "RSA1", KEY_RSA1, 0, 0, 0 },
# endif
{ "ssh-rsa", "RSA", KEY_RSA, 0, 0, 0 }, { "ssh-rsa", "RSA", KEY_RSA, 0, 0, 0 },
{ "rsa-sha2-256", "RSA", KEY_RSA, 0, 0, 1 }, { "rsa-sha2-256", "RSA", KEY_RSA, 0, 0, 1 },
{ "rsa-sha2-512", "RSA", KEY_RSA, 0, 0, 1 }, { "rsa-sha2-512", "RSA", KEY_RSA, 0, 0, 1 },
@ -195,14 +197,16 @@ sshkey_ecdsa_nid_from_name(const char *name)
} }
char * char *
sshkey_alg_list(int certs_only, int plain_only, char sep) sshkey_alg_list(int certs_only, int plain_only, int include_sigonly, char sep)
{ {
char *tmp, *ret = NULL; char *tmp, *ret = NULL;
size_t nlen, rlen = 0; size_t nlen, rlen = 0;
const struct keytype *kt; const struct keytype *kt;
for (kt = keytypes; kt->type != -1; kt++) { for (kt = keytypes; kt->type != -1; kt++) {
if (kt->name == NULL || kt->sigonly) if (kt->name == NULL)
continue;
if (!include_sigonly && kt->sigonly)
continue; continue;
if ((certs_only && !kt->cert) || (plain_only && kt->cert)) if ((certs_only && !kt->cert) || (plain_only && kt->cert))
continue; continue;
@ -1237,6 +1241,9 @@ sshkey_read(struct sshkey *ret, char **cpp)
u_long bits; u_long bits;
#endif /* WITH_SSH1 */ #endif /* WITH_SSH1 */
if (ret == NULL)
return SSH_ERR_INVALID_ARGUMENT;
cp = *cpp; cp = *cpp;
switch (ret->type) { switch (ret->type) {
@ -3786,7 +3793,46 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type,
if ((pk = PEM_read_bio_PrivateKey(bio, NULL, NULL, if ((pk = PEM_read_bio_PrivateKey(bio, NULL, NULL,
(char *)passphrase)) == NULL) { (char *)passphrase)) == NULL) {
r = SSH_ERR_KEY_WRONG_PASSPHRASE; unsigned long pem_err = ERR_peek_last_error();
int pem_reason = ERR_GET_REASON(pem_err);
/*
* Translate OpenSSL error codes to determine whether
* passphrase is required/incorrect.
*/
switch (ERR_GET_LIB(pem_err)) {
case ERR_LIB_PEM:
switch (pem_reason) {
case PEM_R_BAD_PASSWORD_READ:
case PEM_R_PROBLEMS_GETTING_PASSWORD:
case PEM_R_BAD_DECRYPT:
r = SSH_ERR_KEY_WRONG_PASSPHRASE;
goto out;
default:
r = SSH_ERR_INVALID_FORMAT;
goto out;
}
case ERR_LIB_EVP:
switch (pem_reason) {
case EVP_R_BAD_DECRYPT:
r = SSH_ERR_KEY_WRONG_PASSPHRASE;
goto out;
case EVP_R_BN_DECODE_ERROR:
case EVP_R_DECODE_ERROR:
#ifdef EVP_R_PRIVATE_KEY_DECODE_ERROR
case EVP_R_PRIVATE_KEY_DECODE_ERROR:
#endif
r = SSH_ERR_INVALID_FORMAT;
goto out;
default:
r = SSH_ERR_LIBCRYPTO_ERROR;
goto out;
}
case ERR_LIB_ASN1:
r = SSH_ERR_INVALID_FORMAT;
goto out;
}
r = SSH_ERR_LIBCRYPTO_ERROR;
goto out; goto out;
} }
if (pk->type == EVP_PKEY_RSA && if (pk->type == EVP_PKEY_RSA &&
@ -3860,6 +3906,8 @@ int
sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type, sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type,
const char *passphrase, struct sshkey **keyp, char **commentp) const char *passphrase, struct sshkey **keyp, char **commentp)
{ {
int r = SSH_ERR_INTERNAL_ERROR;
if (keyp != NULL) if (keyp != NULL)
*keyp = NULL; *keyp = NULL;
if (commentp != NULL) if (commentp != NULL)
@ -3882,9 +3930,11 @@ sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type,
return sshkey_parse_private2(blob, type, passphrase, return sshkey_parse_private2(blob, type, passphrase,
keyp, commentp); keyp, commentp);
case KEY_UNSPEC: case KEY_UNSPEC:
if (sshkey_parse_private2(blob, type, passphrase, keyp, r = sshkey_parse_private2(blob, type, passphrase, keyp,
commentp) == 0) commentp);
return 0; /* Do not fallback to PEM parser if only passphrase is wrong. */
if (r == 0 || r == SSH_ERR_KEY_WRONG_PASSPHRASE)
return r;
#ifdef WITH_OPENSSL #ifdef WITH_OPENSSL
return sshkey_parse_private_pem_fileblob(blob, type, return sshkey_parse_private_pem_fileblob(blob, type,
passphrase, keyp); passphrase, keyp);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sshkey.h,v 1.14 2016/09/12 23:31:27 djm Exp $ */ /* $OpenBSD: sshkey.h,v 1.15 2017/03/10 04:07:20 djm Exp $ */
/* /*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@ -156,7 +156,7 @@ int sshkey_ec_validate_private(const EC_KEY *);
const char *sshkey_ssh_name(const struct sshkey *); const char *sshkey_ssh_name(const struct sshkey *);
const char *sshkey_ssh_name_plain(const struct sshkey *); const char *sshkey_ssh_name_plain(const struct sshkey *);
int sshkey_names_valid2(const char *, int); int sshkey_names_valid2(const char *, int);
char *sshkey_alg_list(int, int, char); char *sshkey_alg_list(int, int, int, char);
int sshkey_from_blob(const u_char *, size_t, struct sshkey **); int sshkey_from_blob(const u_char *, size_t, struct sshkey **);
int sshkey_fromb(struct sshbuf *, struct sshkey **); int sshkey_fromb(struct sshbuf *, struct sshkey **);

View File

@ -52,8 +52,8 @@ static int _in_raw_mode = 0;
* TTY raw mode routines for Windows * TTY raw mode routines for Windows
*/ */
int ConInit(DWORD OutputHandle, BOOL fSmartInit); int ConEnterRawMode(DWORD OutputHandle, BOOL fSmartInit);
int ConUnInit(void); int ConExitRawMode(void);
struct termios term_settings; struct termios term_settings;
@ -70,12 +70,12 @@ struct termios *
void void
leave_raw_mode(int quiet) { leave_raw_mode(int quiet) {
ConUnInit(); ConExitRawMode();
} }
void void
enter_raw_mode(int quiet) { enter_raw_mode(int quiet) {
ConInit(STD_OUTPUT_HANDLE, TRUE); ConEnterRawMode(STD_OUTPUT_HANDLE, TRUE);
} }
#else /* !WINDOWS */ #else /* !WINDOWS */
struct termios * struct termios *

12
utf8.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: utf8.c,v 1.4 2017/02/02 10:54:25 jsg Exp $ */ /* $OpenBSD: utf8.c,v 1.5 2017/02/19 00:10:57 djm Exp $ */
/* /*
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
* *
@ -57,16 +57,11 @@ static int vasnmprintf(char **, size_t, int *, const char *, va_list);
static int static int
dangerous_locale(void) { dangerous_locale(void) {
#ifdef WINDOWS
wchar_t loc[LOCALE_NAME_MAX_LENGTH];
GetSystemDefaultLocaleName(loc, LOCALE_NAME_MAX_LENGTH);
return wcscmp(loc, L"US-ASCII") && wcscmp(loc, L"UTF-8");
#else /* !WINDOWS */
char *loc; char *loc;
loc = nl_langinfo(CODESET); loc = nl_langinfo(CODESET);
return strcmp(loc, "US-ASCII") && strcmp(loc, "UTF-8"); return strcmp(loc, "US-ASCII") != 0 && strcmp(loc, "UTF-8") != 0 &&
#endif /* !WINDOWS */ strcmp(loc, "ANSI_X3.4-1968") != 0;
} }
static int static int
@ -337,3 +332,4 @@ msetlocale(void)
/* We can handle this locale */ /* We can handle this locale */
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
} }