Skip to content

Commit a4b577b

Browse files
committed
Source snapshot from Powershell/openssh-portable:latestw_cwb
1 parent 15c6a77 commit a4b577b

Some content is hidden

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

51 files changed

+837
-1425
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
See https://www.openssh.com/releasenotes.html#7.3p1 for the release notes.
1+
See https://www.openssh.com/releasenotes.html#7.4p1 for the release notes.
22

33
Please read https://www.openssh.com/report.html for bug reporting
44
instructions and note that we do not use Github for bug reporting or

appveyor.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
version: 0.0.4.0.{build}
1+
version: 0.0.6.0.{build}
22
image: Visual Studio 2015
33

44
branches:
55
only:
6-
- V_7_3w
7-
- latestw_cwb
6+
- latestw_all
7+
- latestw_all_openssl
88

99
init:
1010
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

auth.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: auth.c,v 1.118 2016/11/08 22:04:34 djm Exp $ */
1+
/* $OpenBSD: auth.c,v 1.119 2016/12/15 21:29:05 dtucker Exp $ */
22
/*
33
* Copyright (c) 2000 Markus Friedl. All rights reserved.
44
*
@@ -192,7 +192,7 @@ allowed_user(struct passwd * pw)
192192

193193
/* Return false if user is listed in DenyUsers */
194194
if (options.num_deny_users > 0) {
195-
for (i = 0; i < options.num_deny_users; i++)
195+
for (i = 0; i < options.num_deny_users; i++) {
196196
r = match_user(pw->pw_name, hostname, ipaddr,
197197
options.deny_users[i]);
198198
if (r < 0) {
@@ -204,6 +204,7 @@ allowed_user(struct passwd * pw)
204204
pw->pw_name, hostname);
205205
return 0;
206206
}
207+
}
207208
}
208209
/* Return false if AllowUsers isn't empty and user isn't listed there */
209210
if (options.num_allow_users > 0) {
@@ -576,7 +577,7 @@ auth_openfile(const char *file, struct passwd *pw, int strict_modes,
576577
struct stat st;
577578
int fd;
578579
FILE *f;
579-
580+
580581
#ifdef WINDOWS
581582
/* Windows POSIX adpater does not support fdopen() on open(file)*/
582583
if ((f = fopen(file, "r")) == NULL) {
@@ -616,6 +617,7 @@ auth_openfile(const char *file, struct passwd *pw, int strict_modes,
616617
return NULL;
617618
}
618619
#endif /* !WINDOWS */
620+
619621
return f;
620622
}
621623

auth2-pubkey.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,11 @@ userauth_pubkey(Authctxt *authctxt)
245245
* if a user is not allowed to login. is this an
246246
* issue? -markus
247247
*/
248-
#ifndef WINDOWS
249-
if (PRIVSEP(user_key_allowed(authctxt->pw, key, 0)))
250-
#endif /* !WINDOWS */
248+
#ifdef WINDOWS /* key validation in done in agent for Windows */
251249
{
250+
#else /* !WINDOWS */
251+
if (PRIVSEP(user_key_allowed(authctxt->pw, key, 0))) {
252+
#endif /* !WINDOWS */
252253
packet_start(SSH2_MSG_USERAUTH_PK_OK);
253254
packet_put_string(pkalg, alen);
254255
packet_put_string(pkblob, blen);

channels.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,7 @@ channel_post_mux_listener(Channel *c, fd_set *readset, fd_set *writeset)
20492049
c->notbefore = monotime() + 1;
20502050
return;
20512051
}
2052+
20522053
#ifndef WINDOWS /*TODO - implement user check for Windows*/
20532054
if (getpeereid(newsock, &euid, &egid) < 0) {
20542055
error("%s getpeereid failed: %s", __func__,

clientloop.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr,
12731273
}
12741274
continue;
12751275
#endif /* !WINDOWS */
1276+
12761277
case '?':
12771278
print_escape_help(berr, escape_char, compat20,
12781279
(c && c->ctl_chan != -1),

contrib/redhat/openssh.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%define ver 7.3p1
1+
%define ver 7.4p1
22
%define rel 1
33

44
# OpenSSH privilege separation requires a user & group ID

contrib/suse/openssh.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
Summary: OpenSSH, a free Secure Shell (SSH) protocol implementation
1515
Name: openssh
16-
Version: 7.3p1
16+
Version: 7.4p1
1717
URL: https://www.openssh.com/
1818
Release: 1
1919
Source0: openssh-%{version}.tar.gz

contrib/win32/openssh/build.psm1

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Set-StrictMode -Version Latest
33
[string] $script:platform = $env:PROCESSOR_ARCHITECTURE
44
[string] $script:vcPath = $null
55
[System.IO.DirectoryInfo] $script:OpenSSHRoot = $null
6+
[System.IO.DirectoryInfo] $script:gitRoot = $null
67
[bool] $script:Verbose = $false
78
[string] $script:BuildLogFile = $null
89

@@ -268,6 +269,34 @@ function Start-SSHBootstrap
268269
}
269270
}
270271

272+
function Clone-Win32OpenSSH
273+
{
274+
$win32OpenSSHPath = join-path $script:gitRoot "Win32-OpenSSH"
275+
if (-not (Test-Path -Path $win32OpenSSHPath -PathType Container))
276+
{
277+
Write-BuildMsg -AsInfo -Message "clone repo Win32-OpenSSH"
278+
Push-Location $gitRoot
279+
git clone -q --recursive https://github.com/PowerShell/Win32-OpenSSH.git $win32OpenSSHPath
280+
Pop-Location
281+
}
282+
Write-BuildMsg -AsInfo -Message "pull latest from repo Win32-OpenSSH"
283+
Push-Location $win32OpenSSHPath
284+
git fetch -q origin
285+
git checkout -qf L1-Prod
286+
Pop-Location
287+
}
288+
289+
function Copy-OpenSSLSDK
290+
{
291+
$sourcePath = Join-Path $script:gitRoot "Win32-OpenSSH\contrib\win32\openssh\OpenSSLSDK"
292+
Write-BuildMsg -AsInfo -Message "copying $sourcePath"
293+
Copy-Item -Container -Path $sourcePath -Destination $PSScriptRoot -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable e
294+
if($e -ne $null)
295+
{
296+
Write-BuildMsg -AsError -ErrorAction Stop -Message "Copy OpenSSL from $sourcePath failed "
297+
}
298+
}
299+
271300
function Start-SSHBuild
272301
{
273302
[CmdletBinding(SupportsShouldProcess=$false)]
@@ -286,6 +315,8 @@ function Start-SSHBuild
286315

287316
# Get openssh-portable root
288317
$script:OpenSSHRoot = Get-Item -Path $repositoryRoot.FullName
318+
$script:gitRoot = split-path $script:OpenSSHRoot
319+
289320

290321
if($PSBoundParameters.ContainsKey("Verbose"))
291322
{
@@ -302,6 +333,9 @@ function Start-SSHBuild
302333
Write-BuildMsg -AsInfo -Message "Build Log: $($script:BuildLogFile)"
303334

304335
Start-SSHBootstrap
336+
337+
Clone-Win32OpenSSH
338+
Copy-OpenSSLSDK
305339
$msbuildCmd = "msbuild.exe"
306340
$solutionFile = Get-SolutionFile -root $repositoryRoot.FullName
307341
$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
@@ -380,4 +414,4 @@ function Get-RepositoryRoot
380414
throw new-object System.IO.DirectoryNotFoundException("Could not find the root of the GIT repository")
381415
}
382416

383-
Export-ModuleMember -Function Start-SSHBuild, Get-RepositoryRoot, Get-BuildLogFile
417+
Export-ModuleMember -Function Start-SSHBuild, Get-RepositoryRoot, Get-BuildLogFile, Clone-Win32OpenSSH, Copy-OpenSSLSDK

contrib/win32/openssh/config.h.vs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@
876876
/* #undef HAVE_SET_ID */
877877

878878
/* Define to 1 if you have the `SHA256_Update' function. */
879-
#define HAVE_SHA256_UPDATE 1
879+
/* #undef HAVE_SHA256_UPDATE */
880880

881881
/* Define to 1 if you have the <sha2.h> header file. */
882882
/* #undef HAVE_SHA2_H */

contrib/win32/openssh/install-sshd.ps1

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
$scriptpath = $MyInvocation.MyCommand.Path
1+
# @manojampalam - authored initial script
2+
# @friism - Fixed issue with invalid SDDL on Set-Acl
3+
4+
$scriptpath = $MyInvocation.MyCommand.Path
25
$scriptdir = Split-Path $scriptpath
36

47
$sshdpath = Join-Path $scriptdir "sshd.exe"
58
$sshagentpath = Join-Path $scriptdir "ssh-agent.exe"
69
$logsdir = Join-Path $scriptdir "logs"
710

8-
$ntrights = "ntrights.exe -u `"NT SERVICE\SSHD`" +r SeAssignPrimaryTokenPrivilege"
11+
$account = "NT SERVICE\SSHD"
12+
$ntrights = "ntrights.exe -u `"{0}`" +r SeAssignPrimaryTokenPrivilege" -f $account
913

1014
if (-not (Test-Path $sshdpath)) {
1115
throw "sshd.exe is not present in script path"
@@ -27,17 +31,17 @@ New-Service -Name ssh-agent -BinaryPathName $sshagentpath -Description "SSH Agen
2731
cmd.exe /c 'sc.exe sdset ssh-agent D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RP;;;AU)'
2832

2933
New-Service -Name sshd -BinaryPathName $sshdpath -Description "SSH Deamon" -StartupType Manual -DependsOn ssh-agent | Out-Null
30-
sc.exe config sshd obj= "NT SERVICE\SSHD"
34+
sc.exe config sshd obj= $account
3135

3236
Push-Location
3337
cd $scriptdir
3438
cmd.exe /c $ntrights
3539
Pop-Location
3640

3741
mkdir $logsdir > $null
38-
$sddl = "O:SYG:DUD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;0x12019f;;;S-1-5-80-3847866527-469524349-687026318-516638107-1125189541)"
42+
$rights = [System.Security.AccessControl.FileSystemRights]"Read, Write"
43+
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($account, $rights, "ContainerInherit,ObjectInherit", "None", "Allow")
3944
$acl = Get-Acl -Path $logsdir
40-
$acl.SetSecurityDescriptorSddlForm($sddl)
45+
$Acl.SetAccessRule($accessRule)
4146
Set-Acl -Path $logsdir -AclObject $acl
4247
Write-Host -ForegroundColor Green "sshd and ssh-agent services successfully installed"
43-

contrib/win32/openssh/libssh.vcxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
195195
</ClCompile>
196196
<ClCompile Include="$(OpenSSH-Src-Path)digest-libc.c">
197-
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
197+
<ExcludedFromBuild Condition="$(UseOpenSSL)==true">true</ExcludedFromBuild>
198198
</ClCompile>
199199
<ClCompile Include="$(OpenSSH-Src-Path)dispatch.c" />
200200
<ClCompile Include="$(OpenSSH-Src-Path)dns.c" />
@@ -285,7 +285,9 @@
285285
<ClCompile Include="$(OpenSSH-Src-Path)sandbox-pledge.c" />
286286
<ClCompile Include="$(OpenSSH-Src-Path)utf8.c" />
287287
<ClCompile Include="$(OpenSSH-Src-Path)contrib\win32\win32compat\ttymodes_windows.c" />
288-
<ClCompile Include="..\..\..\digest-openssl.c" />
288+
<ClCompile Include="$(OpenSSH-Src-Path)digest-openssl.c">
289+
<ExcludedFromBuild Condition="$(UseOpenSSL)==false">true</ExcludedFromBuild>
290+
</ClCompile>
289291
</ItemGroup>
290292
<ItemGroup>
291293
<ClInclude Include="$(OpenSSH-Src-Path)crypto-wrap.h" />

contrib/win32/openssh/version.rc

0 Bytes
Binary file not shown.

contrib/win32/openssh/win32iocompat.vcxproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@
155155
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\win32_dirent.c" />
156156
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\no-ops.c" />
157157
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\win32_zlib.c" />
158-
<ClCompile Include="..\win32compat\ansiprsr.c" />
159-
<ClCompile Include="..\win32compat\conio.c" />
160-
<ClCompile Include="..\win32compat\console.c" />
161-
<ClCompile Include="..\win32compat\tncon.c" />
162-
<ClCompile Include="..\win32compat\tnnet.c" />
158+
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\ansiprsr.c" />
159+
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\conio.c" />
160+
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\console.c" />
161+
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tncon.c" />
162+
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\tnnet.c" />
163163
</ItemGroup>
164164
<ItemGroup>
165165
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" />
@@ -198,6 +198,7 @@
198198
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\termios.h" />
199199
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dirent.h" />
200200
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\pwd.h" />
201+
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\misc_internal.h" />
201202
</ItemGroup>
202203
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
203204
<ImportGroup Label="ExtensionTargets">

contrib/win32/openssh/win32iocompat.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
<Filter>inc</Filter>
118118
</ClInclude>
119119
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\pwd.h" />
120+
<ClInclude Include="..\win32compat\misc_internal.h" />
120121
</ItemGroup>
121122
<ItemGroup>
122123
<Filter Include="inc">

contrib/win32/win32compat/fileio.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,14 @@ createFile_flags_setup(int flags, int mode, struct createFile_flags* cf_flags) {
199199
return -1;
200200
}
201201

202+
cf_flags->dwShareMode = 0;
203+
202204
switch (rwflags) {
203205
case O_RDONLY:
204206
cf_flags->dwDesiredAccess = GENERIC_READ;
207+
/*todo: need to review to make sure all flags are correct*/
208+
if (flags & O_NONBLOCK)
209+
cf_flags->dwShareMode = FILE_SHARE_READ;
205210
break;
206211
case O_WRONLY:
207212
cf_flags->dwDesiredAccess = GENERIC_WRITE;
@@ -211,8 +216,6 @@ createFile_flags_setup(int flags, int mode, struct createFile_flags* cf_flags) {
211216
break;
212217
}
213218

214-
cf_flags->dwShareMode = 0;
215-
216219
cf_flags->securityAttributes.lpSecurityDescriptor = NULL;
217220
cf_flags->securityAttributes.bInheritHandle = TRUE;
218221
cf_flags->securityAttributes.nLength = 0;
@@ -230,7 +233,7 @@ createFile_flags_setup(int flags, int mode, struct createFile_flags* cf_flags) {
230233
if (c_s_flags & O_APPEND)
231234
cf_flags->dwDesiredAccess = FILE_APPEND_DATA;
232235

233-
cf_flags->dwFlagsAndAttributes = FILE_FLAG_OVERLAPPED | SECURITY_IMPERSONATION;
236+
cf_flags->dwFlagsAndAttributes = FILE_FLAG_OVERLAPPED | SECURITY_IMPERSONATION | FILE_FLAG_BACKUP_SEMANTICS;
234237

235238
/*TODO - map mode */
236239

contrib/win32/win32compat/inc/w32posix.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,6 @@ explicit_bzero(void *b, size_t len);
159159
#define fopen w32_fopen_utf8
160160
#define popen _popen
161161
#define pclose _pclose
162+
163+
void convertToBackslash(char *str);
164+
void convertToForwardslash(char *str);

0 commit comments

Comments
 (0)