Update to .NET 8 RC 2
Resolves: RHEL-13790
This commit is contained in:
parent
922ed5aba1
commit
e1588ed8b5
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,3 +34,4 @@
|
|||||||
/dotnet-prebuilts-8.0.100-rc.1.23410.12-ppc64le.tar.gz
|
/dotnet-prebuilts-8.0.100-rc.1.23410.12-ppc64le.tar.gz
|
||||||
/dotnet-prebuilts-8.0.100-rc.1.23410.12-s390x.tar.gz
|
/dotnet-prebuilts-8.0.100-rc.1.23410.12-s390x.tar.gz
|
||||||
/dotnet-v8.0.0-rc.1.23419.4.tar.gz
|
/dotnet-v8.0.0-rc.1.23419.4.tar.gz
|
||||||
|
/dotnet-v8.0.0-rc.2.23479.6.tar.gz
|
||||||
|
38
dotnet-3673-rc2-version-mismatch.patch
Normal file
38
dotnet-3673-rc2-version-mismatch.patch
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Matt Thalman <mthalman@microsoft.com>
|
||||||
|
Date: Tue, 24 Oct 2023 16:20:26 -0500
|
||||||
|
Subject: [PATCH] Use correct runtime package version
|
||||||
|
|
||||||
|
---
|
||||||
|
prereqs/git-info/AllRepoVersions.props | 2 +-
|
||||||
|
prereqs/git-info/runtime.props | 4 ++--
|
||||||
|
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/prereqs/git-info/AllRepoVersions.props b/prereqs/git-info/AllRepoVersions.props
|
||||||
|
index 79a789e1cd..a3f3ccf094 100644
|
||||||
|
--- a/prereqs/git-info/AllRepoVersions.props
|
||||||
|
+++ b/prereqs/git-info/AllRepoVersions.props
|
||||||
|
@@ -32,7 +32,7 @@
|
||||||
|
<roslynGitCommitHash>bdd9c5ba66b00beebdc3516acc5e29b83efd89af</roslynGitCommitHash>
|
||||||
|
<roslynOutputPackageVersion>4.8.0-3.23471.11</roslynOutputPackageVersion>
|
||||||
|
<runtimeGitCommitHash>0b25e38ad32a69cd83ae246104b32449203cc71c</runtimeGitCommitHash>
|
||||||
|
- <runtimeOutputPackageVersion>8.0.0-rc.2.23475.17</runtimeOutputPackageVersion>
|
||||||
|
+ <runtimeOutputPackageVersion>8.0.0-rc.2.23479.6</runtimeOutputPackageVersion>
|
||||||
|
<sdkGitCommitHash>67e671f384bee6937630b52b02cc78e69b27e280</sdkGitCommitHash>
|
||||||
|
<sdkOutputPackageVersion>8.0.100-rc.2.23480.5</sdkOutputPackageVersion>
|
||||||
|
<sourcebuildexternalsGitCommitHash>6dbf3aaa0fc9664df86462f5c70b99800934fccd</sourcebuildexternalsGitCommitHash>
|
||||||
|
diff --git a/prereqs/git-info/runtime.props b/prereqs/git-info/runtime.props
|
||||||
|
index 546469c3a0..20c2bf8840 100644
|
||||||
|
--- a/prereqs/git-info/runtime.props
|
||||||
|
+++ b/prereqs/git-info/runtime.props
|
||||||
|
@@ -2,8 +2,8 @@
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<GitCommitHash>0b25e38ad32a69cd83ae246104b32449203cc71c</GitCommitHash>
|
||||||
|
- <OfficialBuildId>20230925.17</OfficialBuildId>
|
||||||
|
- <OutputPackageVersion>8.0.0-rc.2.23475.17</OutputPackageVersion>
|
||||||
|
+ <OfficialBuildId>20230929.6</OfficialBuildId>
|
||||||
|
+ <OutputPackageVersion>8.0.0-rc.2.23479.6</OutputPackageVersion>
|
||||||
|
<PreReleaseVersionLabel>rc.2</PreReleaseVersionLabel>
|
||||||
|
<IsStable>false</IsStable>
|
||||||
|
</PropertyGroup>
|
@ -8,22 +8,22 @@
|
|||||||
|
|
||||||
%global dotnetver 8.0
|
%global dotnetver 8.0
|
||||||
|
|
||||||
%global host_version 8.0.0-rc.1.23419.4
|
%global host_version 8.0.0-rc.2.23479.6
|
||||||
%global runtime_version 8.0.0-rc.1.23419.4
|
%global runtime_version 8.0.0-rc.2.23479.6
|
||||||
%global aspnetcore_runtime_version 8.0.0-rc.1.23421.29
|
%global aspnetcore_runtime_version 8.0.0-rc.2.23480.2
|
||||||
%global sdk_version 8.0.100-rc.1.23455.1
|
%global sdk_version 8.0.100-rc.2.23502.1
|
||||||
%global sdk_feature_band_version %(echo %{sdk_version} | cut -d '-' -f 1 | sed -e 's|[[:digit:]][[:digit:]]$|00|')
|
%global sdk_feature_band_version %(echo %{sdk_version} | cut -d '-' -f 1 | sed -e 's|[[:digit:]][[:digit:]]$|00|')
|
||||||
%global templates_version 8.0.0-rc.1.23421.29
|
%global templates_version 8.0.0-rc.2.23480.2
|
||||||
#%%global templates_version %%(echo %%{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }')
|
#%%global templates_version %%(echo %%{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }')
|
||||||
|
|
||||||
# upstream can produce releases with a different tag than the SDK version
|
# upstream can produce releases with a different tag than the SDK version
|
||||||
%global upstream_tag v8.0.0-rc.1.23419.4
|
%global upstream_tag v8.0.0-rc.2.23479.6
|
||||||
%global upstream_tag_without_v %(echo %{upstream_tag} | sed -e 's|^v||')
|
%global upstream_tag_without_v %(echo %{upstream_tag} | sed -e 's|^v||')
|
||||||
|
|
||||||
%global host_rpm_version 8.0.0~rc.1
|
%global host_rpm_version 8.0.0~rc.2
|
||||||
%global runtime_rpm_version 8.0.0~rc.1
|
%global runtime_rpm_version 8.0.0~rc.2
|
||||||
%global aspnetcore_runtime_rpm_version 8.0.0~rc.1
|
%global aspnetcore_runtime_rpm_version 8.0.0~rc.2
|
||||||
%global sdk_rpm_version 8.0.100~rc.1
|
%global sdk_rpm_version 8.0.100~rc.2
|
||||||
|
|
||||||
%if 0%{?fedora} || 0%{?rhel} < 8
|
%if 0%{?fedora} || 0%{?rhel} < 8
|
||||||
%global use_bundled_libunwind 0
|
%global use_bundled_libunwind 0
|
||||||
@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
Name: dotnet%{dotnetver}
|
Name: dotnet%{dotnetver}
|
||||||
Version: %{sdk_rpm_version}
|
Version: %{sdk_rpm_version}
|
||||||
Release: 0.4%{?dist}
|
Release: 0.1%{?dist}
|
||||||
Summary: .NET Runtime and SDK
|
Summary: .NET Runtime and SDK
|
||||||
License: 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib
|
License: 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib
|
||||||
|
|
||||||
@ -90,18 +90,12 @@ Source21: dotnet.sh.in
|
|||||||
Patch1: roslyn-analyzers-ppc64le-apphost.patch
|
Patch1: roslyn-analyzers-ppc64le-apphost.patch
|
||||||
# https://github.com/dotnet/source-build/discussions/3481
|
# https://github.com/dotnet/source-build/discussions/3481
|
||||||
Patch2: vstest-intent-net8.0.patch
|
Patch2: vstest-intent-net8.0.patch
|
||||||
# https://github.com/dotnet/source-build/issues/3571
|
|
||||||
Patch3: fix-mono-typeloadexception.patch
|
|
||||||
# https://github.com/dotnet/runtime/pull/91008
|
|
||||||
Patch4: runtime-91008-mono-var-opcode-OP_REGOFFSET.patch
|
|
||||||
# https://github.com/dotnet/runtime/pull/91865
|
|
||||||
Patch5: runtime-91865-arm64-page-size.patch
|
|
||||||
# https://github.com/dotnet/runtime/pull/92274
|
# https://github.com/dotnet/runtime/pull/92274
|
||||||
Patch6: runtime-92274-webcil-s390x.patch
|
Patch3: runtime-92274-webcil-s390x.patch
|
||||||
# https://github.com/dotnet/runtime/pull/92441
|
# https://github.com/dotnet/runtime/pull/92920
|
||||||
Patch7: runtime-92441-s390x-host-le.patch
|
Patch4: runtime-92920-multiple-ssl-dirs.patch
|
||||||
# https://github.com/dotnet/sdk/pull/35600
|
# https://github.com/dotnet/source-build/issues/3673
|
||||||
Patch8: sdk-35600-skip-windows-gui.patch
|
Patch5: dotnet-3673-rc2-version-mismatch.patch
|
||||||
|
|
||||||
|
|
||||||
%if 0%{?fedora} || 0%{?rhel} >= 8
|
%if 0%{?fedora} || 0%{?rhel} >= 8
|
||||||
@ -386,7 +380,7 @@ if [[ ${release_json_tag} != %{upstream_tag} ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
%if %{without bootstrap}
|
%if %{without bootstrap}
|
||||||
%setup -q -n dotnet-%{upstream_tag}
|
%setup -q -n dotnet-%{upstream_tag_without_v}
|
||||||
|
|
||||||
# Remove all prebuilts
|
# Remove all prebuilts
|
||||||
find -iname '*.dll' -type f -delete
|
find -iname '*.dll' -type f -delete
|
||||||
@ -671,6 +665,10 @@ export COMPlus_LTTng=0
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Oct 16 2023 Omair Majid <omajid@redhat.com> - 8.0.100~rc.2-0.1
|
||||||
|
- Update to .NET 8 RC 2
|
||||||
|
- Resolves: RHEL-13790
|
||||||
|
|
||||||
* Thu Sep 28 2023 Omair Majid <omajid@redhat.com> - 8.0.100~rc.1-0.4
|
* Thu Sep 28 2023 Omair Majid <omajid@redhat.com> - 8.0.100~rc.1-0.4
|
||||||
- Disable bootstrap
|
- Disable bootstrap
|
||||||
- Related: RHEL-4074
|
- Related: RHEL-4074
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
From 02f6303d86672997ec2e6b79b16d5ddbf52118a0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tom Deseyn <tom.deseyn@gmail.com>
|
|
||||||
Date: Tue, 22 Aug 2023 14:52:36 +0200
|
|
||||||
Subject: [PATCH] Avoid loading System.Security.Permissions.
|
|
||||||
|
|
||||||
source-built Mono fails to load types from this assembly.
|
|
||||||
---
|
|
||||||
src/msbuild/src/Shared/ExceptionHandling.cs | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/msbuild/src/Shared/ExceptionHandling.cs b/src/msbuild/src/Shared/ExceptionHandling.cs
|
|
||||||
index a7ef74e873..3dce645df1 100644
|
|
||||||
--- a/src/msbuild/src/Shared/ExceptionHandling.cs
|
|
||||||
+++ b/src/msbuild/src/Shared/ExceptionHandling.cs
|
|
||||||
@@ -167,7 +167,7 @@ internal static bool IsIoRelatedException(Exception e)
|
|
||||||
internal static bool IsXmlException(Exception e)
|
|
||||||
{
|
|
||||||
return e is XmlException
|
|
||||||
- || e is XmlSyntaxException
|
|
||||||
+ // || e is XmlSyntaxException
|
|
||||||
|| e is XmlSchemaException
|
|
||||||
|| e is UriFormatException; // XmlTextReader for example uses this under the covers
|
|
||||||
}
|
|
10
release.json
10
release.json
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"release": "8.0.0-rc.1",
|
"release": "8.0.0-rc.2",
|
||||||
"channel": "8.0",
|
"channel": "8.0",
|
||||||
"tag": "v8.0.0-rc.1.23419.4",
|
"tag": "v8.0.0-rc.2.23479.6",
|
||||||
"sdkVersion": "8.0.100-rc.1.23455.8",
|
"sdkVersion": "8.0.100-rc.2.23502.2",
|
||||||
"runtimeVersion": "8.0.0-rc.1.23419.4",
|
"runtimeVersion": "8.0.0-rc.2.23479.6",
|
||||||
"sourceRepository": "https://github.com/dotnet/dotnet",
|
"sourceRepository": "https://github.com/dotnet/dotnet",
|
||||||
"sourceVersion": "113d797bc90104bb4f1cc51e1a462cf3d4ef18fc"
|
"sourceVersion": "1e872358329855089d8d14cec1f06d5b075824b5"
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
From a73b8bacfcc5819926bc05173ab2f7850eb00da3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Ulrich Weigand <ulrich.weigand@de.ibm.com>
|
|
||||||
Date: Wed, 23 Aug 2023 21:11:37 +0200
|
|
||||||
Subject: [PATCH] [mono] Handle enum return type when inlining CreateInstance
|
|
||||||
|
|
||||||
Use underlying base type when deciding how to inline a
|
|
||||||
CreateInstance invocation in mini_emit_inst_for_method.
|
|
||||||
|
|
||||||
Fixes https://github.com/dotnet/runtime/issues/90292
|
|
||||||
(Mono abort causing .NET 8 msbuild regression).
|
|
||||||
---
|
|
||||||
src/mono/mono/mini/intrinsics.c | 4 +++-
|
|
||||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/runtime/src/mono/mono/mini/intrinsics.c b/src/runtime/src/mono/mono/mini/intrinsics.c
|
|
||||||
index b1e5e76723147..ef77b7dc89f2e 100644
|
|
||||||
--- a/src/runtime/src/mono/mono/mini/intrinsics.c
|
|
||||||
+++ b//src/runtimesrc/mono/mono/mini/intrinsics.c
|
|
||||||
@@ -2079,7 +2079,9 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
|
|
||||||
MonoType *t = method_context->method_inst->type_argv [0];
|
|
||||||
MonoClass *arg0 = mono_class_from_mono_type_internal (t);
|
|
||||||
if (m_class_is_valuetype (arg0) && !mono_class_has_default_constructor (arg0, FALSE)) {
|
|
||||||
- if (m_class_is_primitive (arg0)) {
|
|
||||||
+ if (m_class_is_primitive (arg0) || m_class_is_enumtype (arg0)) {
|
|
||||||
+ if (m_class_is_enumtype (arg0))
|
|
||||||
+ t = mono_class_enum_basetype_internal (arg0);
|
|
||||||
int dreg = alloc_dreg (cfg, mini_type_to_stack_type (cfg, t));
|
|
||||||
mini_emit_init_rvar (cfg, dreg, t);
|
|
||||||
ins = cfg->cbb->last_ins;
|
|
@ -1,39 +0,0 @@
|
|||||||
From 7d3b041c09aa1d6cf532e64d24b75a7e5bd4d106 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tom Deseyn <tom.deseyn@gmail.com>
|
|
||||||
Date: Tue, 12 Sep 2023 07:43:45 +0200
|
|
||||||
Subject: [PATCH] Limit special diagnostics size region to 4KiB.
|
|
||||||
|
|
||||||
This fixes out-of-bounds access when trying to write the
|
|
||||||
diagnostics info on platforms where the PAGE_SIZE is larger
|
|
||||||
than the DumpWriter's 16KiB m_tempBuffer.
|
|
||||||
---
|
|
||||||
src/coreclr/debug/createdump/crashinfo.cpp | 2 +-
|
|
||||||
src/coreclr/debug/createdump/specialdiaginfo.h | 2 ++
|
|
||||||
2 files changed, 3 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp b/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp
|
|
||||||
index ef903767ba027..8af6ec4a54f5b 100644
|
|
||||||
--- a/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp
|
|
||||||
+++ b/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp
|
|
||||||
@@ -195,7 +195,7 @@ CrashInfo::GatherCrashInfo(DumpType dumpType)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Add the special (fake) memory region for the special diagnostics info
|
|
||||||
- MemoryRegion special(PF_R, SpecialDiagInfoAddress, SpecialDiagInfoAddress + PAGE_SIZE);
|
|
||||||
+ MemoryRegion special(PF_R, SpecialDiagInfoAddress, SpecialDiagInfoAddress + SpecialDiagInfoSize);
|
|
||||||
m_memoryRegions.insert(special);
|
|
||||||
#ifdef __APPLE__
|
|
||||||
InitializeOtherMappings();
|
|
||||||
diff --git a/src/runtime/src/coreclr/debug/createdump/specialdiaginfo.h b/src/runtime/src/coreclr/debug/createdump/specialdiaginfo.h
|
|
||||||
index 3a04a9f551e6d..a857129c9c91f 100644
|
|
||||||
--- a/src/runtime/src/coreclr/debug/createdump/specialdiaginfo.h
|
|
||||||
+++ b/src/runtime/src/coreclr/debug/createdump/specialdiaginfo.h
|
|
||||||
@@ -24,6 +24,8 @@ const uint64_t SpecialDiagInfoAddress = 0x7fff1000;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+const uint64_t SpecialDiagInfoSize = 0x1000;
|
|
||||||
+
|
|
||||||
struct SpecialDiagInfoHeader
|
|
||||||
{
|
|
||||||
char Signature[16];
|
|
@ -1,290 +0,0 @@
|
|||||||
From 0566e7dd9a7a8e5dec119d0ba715623beeba4c90 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Elinor Fung <elfung@microsoft.com>
|
|
||||||
Date: Wed, 20 Sep 2023 17:27:40 -0700
|
|
||||||
Subject: [PATCH 1/2] Make HostModel PEUtils always read/write little endian
|
|
||||||
|
|
||||||
---
|
|
||||||
.../AppHost/PEUtils.cs | 26 ++++++++++++-------
|
|
||||||
1 file changed, 16 insertions(+), 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs b/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs
|
|
||||||
index 0d0b33ed55569..e6142aba26e3e 100644
|
|
||||||
--- a/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs
|
|
||||||
+++ b/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs
|
|
||||||
@@ -1,6 +1,8 @@
|
|
||||||
// Licensed to the .NET Foundation under one or more agreements.
|
|
||||||
// The .NET Foundation licenses this file to you under the MIT license.
|
|
||||||
|
|
||||||
+using System;
|
|
||||||
+using System.Buffers.Binary;
|
|
||||||
using System.IO;
|
|
||||||
using System.IO.MemoryMappedFiles;
|
|
||||||
|
|
||||||
@@ -24,7 +26,9 @@ internal static unsafe bool IsPEImage(MemoryMappedViewAccessor accessor)
|
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Portable_Executable
|
|
||||||
// Validate that we're looking at Windows PE file
|
|
||||||
- if (((ushort*)bytes)[0] != PEOffsets.DosImageSignature
|
|
||||||
+ ReadOnlySpan<byte> signatureBytes = new(bytes, sizeof(ushort));
|
|
||||||
+ ushort signature = BinaryPrimitives.ReadUInt16LittleEndian(signatureBytes);
|
|
||||||
+ if (signature != PEOffsets.DosImageSignature
|
|
||||||
|| accessor.Capacity < PEOffsets.DosStub.PESignatureOffset + sizeof(uint))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
@@ -68,24 +72,26 @@ internal static unsafe void SetWindowsGraphicalUserInterfaceBit(MemoryMappedView
|
|
||||||
byte* bytes = pointer + accessor.PointerOffset;
|
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Portable_Executable
|
|
||||||
- uint peHeaderOffset = ((uint*)(bytes + PEOffsets.DosStub.PESignatureOffset))[0];
|
|
||||||
+ ReadOnlySpan<byte> peHeaderOffsetBytes = new(bytes + PEOffsets.DosStub.PESignatureOffset, sizeof(uint));
|
|
||||||
+ uint peHeaderOffset = BinaryPrimitives.ReadUInt32LittleEndian(peHeaderOffsetBytes);
|
|
||||||
|
|
||||||
if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort))
|
|
||||||
{
|
|
||||||
throw new AppHostNotPEFileException("Subsystem offset out of file range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
- ushort* subsystem = ((ushort*)(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem));
|
|
||||||
+ Span<byte> subsystemBytes = new(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem, sizeof(ushort));
|
|
||||||
+ ushort subsystem = BinaryPrimitives.ReadUInt16LittleEndian(subsystemBytes);
|
|
||||||
|
|
||||||
// https://docs.microsoft.com/en-us/windows/desktop/Debug/pe-format#windows-subsystem
|
|
||||||
// The subsystem of the prebuilt apphost should be set to CUI
|
|
||||||
- if (subsystem[0] != (ushort)PEOffsets.Subsystem.WindowsCui)
|
|
||||||
+ if (subsystem != (ushort)PEOffsets.Subsystem.WindowsCui)
|
|
||||||
{
|
|
||||||
- throw new AppHostNotCUIException(subsystem[0]);
|
|
||||||
+ throw new AppHostNotCUIException(subsystem);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the subsystem to GUI
|
|
||||||
- subsystem[0] = (ushort)PEOffsets.Subsystem.WindowsGui;
|
|
||||||
+ BinaryPrimitives.WriteUInt16LittleEndian(subsystemBytes, (ushort)PEOffsets.Subsystem.WindowsGui);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
@@ -121,16 +127,16 @@ internal static unsafe ushort GetWindowsGraphicalUserInterfaceBit(MemoryMappedVi
|
|
||||||
byte* bytes = pointer + accessor.PointerOffset;
|
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Portable_Executable
|
|
||||||
- uint peHeaderOffset = ((uint*)(bytes + PEOffsets.DosStub.PESignatureOffset))[0];
|
|
||||||
+ ReadOnlySpan<byte> peHeaderOffsetBytes = new(bytes + PEOffsets.DosStub.PESignatureOffset, sizeof(uint));
|
|
||||||
+ uint peHeaderOffset = BinaryPrimitives.ReadUInt32LittleEndian(peHeaderOffsetBytes);
|
|
||||||
|
|
||||||
if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort))
|
|
||||||
{
|
|
||||||
throw new AppHostNotPEFileException("Subsystem offset out of file range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
- ushort* subsystem = ((ushort*)(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem));
|
|
||||||
-
|
|
||||||
- return subsystem[0];
|
|
||||||
+ ReadOnlySpan<byte> subsystemBytes = new(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem, sizeof(ushort));
|
|
||||||
+ return BinaryPrimitives.ReadUInt16LittleEndian(subsystemBytes);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
|
|
||||||
From d39f18ecd6671748cc6baf57f141f94668cb5f9e Mon Sep 17 00:00:00 2001
|
|
||||||
From: Elinor Fung <elfung@microsoft.com>
|
|
||||||
Date: Thu, 21 Sep 2023 10:45:36 -0700
|
|
||||||
Subject: [PATCH 2/2] PR feeback - helper methods
|
|
||||||
|
|
||||||
---
|
|
||||||
.../AppHost/PEUtils.cs | 123 ++++++------------
|
|
||||||
.../AppHostUpdateTests.cs | 6 +-
|
|
||||||
2 files changed, 42 insertions(+), 87 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs b/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs
|
|
||||||
index e6142aba26e3e..1bfc80fcfca49 100644
|
|
||||||
--- a/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs
|
|
||||||
+++ b/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs
|
|
||||||
@@ -5,6 +5,7 @@
|
|
||||||
using System.Buffers.Binary;
|
|
||||||
using System.IO;
|
|
||||||
using System.IO.MemoryMappedFiles;
|
|
||||||
+using System.Reflection.PortableExecutable;
|
|
||||||
|
|
||||||
namespace Microsoft.NET.HostModel.AppHost
|
|
||||||
{
|
|
||||||
@@ -17,31 +18,13 @@ public static class PEUtils
|
|
||||||
/// <returns>true if the accessor represents a PE image, false otherwise.</returns>
|
|
||||||
internal static unsafe bool IsPEImage(MemoryMappedViewAccessor accessor)
|
|
||||||
{
|
|
||||||
- byte* pointer = null;
|
|
||||||
+ if (accessor.Capacity < PEOffsets.DosStub.PESignatureOffset + sizeof(uint))
|
|
||||||
+ return false;
|
|
||||||
|
|
||||||
- try
|
|
||||||
- {
|
|
||||||
- accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer);
|
|
||||||
- byte* bytes = pointer + accessor.PointerOffset;
|
|
||||||
-
|
|
||||||
- // https://en.wikipedia.org/wiki/Portable_Executable
|
|
||||||
- // Validate that we're looking at Windows PE file
|
|
||||||
- ReadOnlySpan<byte> signatureBytes = new(bytes, sizeof(ushort));
|
|
||||||
- ushort signature = BinaryPrimitives.ReadUInt16LittleEndian(signatureBytes);
|
|
||||||
- if (signature != PEOffsets.DosImageSignature
|
|
||||||
- || accessor.Capacity < PEOffsets.DosStub.PESignatureOffset + sizeof(uint))
|
|
||||||
- {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
- return true;
|
|
||||||
- }
|
|
||||||
- finally
|
|
||||||
- {
|
|
||||||
- if (pointer != null)
|
|
||||||
- {
|
|
||||||
- accessor.SafeMemoryMappedViewHandle.ReleasePointer();
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+ // https://en.wikipedia.org/wiki/Portable_Executable
|
|
||||||
+ // Validate that we're looking at Windows PE file
|
|
||||||
+ ushort signature = AsLittleEndian(accessor.ReadUInt16(0));
|
|
||||||
+ return signature == PEOffsets.DosImageSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsPEImage(string filePath)
|
|
||||||
@@ -64,42 +47,15 @@ public static bool IsPEImage(string filePath)
|
|
||||||
/// <param name="accessor">The memory accessor which has the apphost file opened.</param>
|
|
||||||
internal static unsafe void SetWindowsGraphicalUserInterfaceBit(MemoryMappedViewAccessor accessor)
|
|
||||||
{
|
|
||||||
- byte* pointer = null;
|
|
||||||
-
|
|
||||||
- try
|
|
||||||
- {
|
|
||||||
- accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer);
|
|
||||||
- byte* bytes = pointer + accessor.PointerOffset;
|
|
||||||
-
|
|
||||||
- // https://en.wikipedia.org/wiki/Portable_Executable
|
|
||||||
- ReadOnlySpan<byte> peHeaderOffsetBytes = new(bytes + PEOffsets.DosStub.PESignatureOffset, sizeof(uint));
|
|
||||||
- uint peHeaderOffset = BinaryPrimitives.ReadUInt32LittleEndian(peHeaderOffsetBytes);
|
|
||||||
-
|
|
||||||
- if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort))
|
|
||||||
- {
|
|
||||||
- throw new AppHostNotPEFileException("Subsystem offset out of file range.");
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- Span<byte> subsystemBytes = new(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem, sizeof(ushort));
|
|
||||||
- ushort subsystem = BinaryPrimitives.ReadUInt16LittleEndian(subsystemBytes);
|
|
||||||
-
|
|
||||||
- // https://docs.microsoft.com/en-us/windows/desktop/Debug/pe-format#windows-subsystem
|
|
||||||
- // The subsystem of the prebuilt apphost should be set to CUI
|
|
||||||
- if (subsystem != (ushort)PEOffsets.Subsystem.WindowsCui)
|
|
||||||
- {
|
|
||||||
- throw new AppHostNotCUIException(subsystem);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- // Set the subsystem to GUI
|
|
||||||
- BinaryPrimitives.WriteUInt16LittleEndian(subsystemBytes, (ushort)PEOffsets.Subsystem.WindowsGui);
|
|
||||||
- }
|
|
||||||
- finally
|
|
||||||
- {
|
|
||||||
- if (pointer != null)
|
|
||||||
- {
|
|
||||||
- accessor.SafeMemoryMappedViewHandle.ReleasePointer();
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+ // https://learn.microsoft.com/windows/win32/debug/pe-format#windows-subsystem
|
|
||||||
+ // The subsystem of the prebuilt apphost should be set to CUI
|
|
||||||
+ uint peHeaderOffset;
|
|
||||||
+ ushort subsystem = GetWindowsSubsystem(accessor, out peHeaderOffset);
|
|
||||||
+ if (subsystem != (ushort)Subsystem.WindowsCui)
|
|
||||||
+ throw new AppHostNotCUIException(subsystem);
|
|
||||||
+
|
|
||||||
+ // Set the subsystem to GUI
|
|
||||||
+ accessor.Write(peHeaderOffset + PEOffsets.PEHeader.Subsystem, AsLittleEndian((ushort)Subsystem.WindowsGui));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static unsafe void SetWindowsGraphicalUserInterfaceBit(string filePath)
|
|
||||||
@@ -119,32 +75,7 @@ public static unsafe void SetWindowsGraphicalUserInterfaceBit(string filePath)
|
|
||||||
/// <param name="accessor">The memory accessor which has the apphost file opened.</param>
|
|
||||||
internal static unsafe ushort GetWindowsGraphicalUserInterfaceBit(MemoryMappedViewAccessor accessor)
|
|
||||||
{
|
|
||||||
- byte* pointer = null;
|
|
||||||
-
|
|
||||||
- try
|
|
||||||
- {
|
|
||||||
- accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer);
|
|
||||||
- byte* bytes = pointer + accessor.PointerOffset;
|
|
||||||
-
|
|
||||||
- // https://en.wikipedia.org/wiki/Portable_Executable
|
|
||||||
- ReadOnlySpan<byte> peHeaderOffsetBytes = new(bytes + PEOffsets.DosStub.PESignatureOffset, sizeof(uint));
|
|
||||||
- uint peHeaderOffset = BinaryPrimitives.ReadUInt32LittleEndian(peHeaderOffsetBytes);
|
|
||||||
-
|
|
||||||
- if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort))
|
|
||||||
- {
|
|
||||||
- throw new AppHostNotPEFileException("Subsystem offset out of file range.");
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- ReadOnlySpan<byte> subsystemBytes = new(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem, sizeof(ushort));
|
|
||||||
- return BinaryPrimitives.ReadUInt16LittleEndian(subsystemBytes);
|
|
||||||
- }
|
|
||||||
- finally
|
|
||||||
- {
|
|
||||||
- if (pointer != null)
|
|
||||||
- {
|
|
||||||
- accessor.SafeMemoryMappedViewHandle.ReleasePointer();
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+ return GetWindowsSubsystem(accessor, out _);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static unsafe ushort GetWindowsGraphicalUserInterfaceBit(string filePath)
|
|
||||||
@@ -157,5 +88,25 @@ public static unsafe ushort GetWindowsGraphicalUserInterfaceBit(string filePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ private static ushort GetWindowsSubsystem(MemoryMappedViewAccessor accessor, out uint peHeaderOffset)
|
|
||||||
+ {
|
|
||||||
+ // https://en.wikipedia.org/wiki/Portable_Executable
|
|
||||||
+ if (accessor.Capacity < PEOffsets.DosStub.PESignatureOffset + sizeof(uint))
|
|
||||||
+ throw new AppHostNotPEFileException("PESignature offset out of file range.");
|
|
||||||
+
|
|
||||||
+ peHeaderOffset = AsLittleEndian(accessor.ReadUInt32(PEOffsets.DosStub.PESignatureOffset));
|
|
||||||
+ if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort))
|
|
||||||
+ throw new AppHostNotPEFileException("Subsystem offset out of file range.");
|
|
||||||
+
|
|
||||||
+ // https://learn.microsoft.com/windows/win32/debug/pe-format#windows-subsystem
|
|
||||||
+ return AsLittleEndian(accessor.ReadUInt16(peHeaderOffset + PEOffsets.PEHeader.Subsystem));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static ushort AsLittleEndian(ushort value)
|
|
||||||
+ => BitConverter.IsLittleEndian ? value : BinaryPrimitives.ReverseEndianness(value);
|
|
||||||
+
|
|
||||||
+ private static uint AsLittleEndian(uint value)
|
|
||||||
+ => BitConverter.IsLittleEndian ? value : BinaryPrimitives.ReverseEndianness(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/src/runtime/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUpdateTests.cs b/src/runtime/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUpdateTests.cs
|
|
||||||
index 232410be8f259..b4d038b99b5ce 100644
|
|
||||||
--- a/src/runtime/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUpdateTests.cs
|
|
||||||
+++ b/src/runtime/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUpdateTests.cs
|
|
||||||
@@ -11,6 +11,7 @@
|
|
||||||
using Microsoft.NET.HostModel.AppHost;
|
|
||||||
using Microsoft.DotNet.CoreSetup.Test;
|
|
||||||
using System.Diagnostics;
|
|
||||||
+using System.Reflection.PortableExecutable;
|
|
||||||
|
|
||||||
namespace Microsoft.NET.HostModel.Tests
|
|
||||||
{
|
|
||||||
@@ -111,7 +112,9 @@ public void ItCanSetWindowsGUISubsystem()
|
|
||||||
BitConverter
|
|
||||||
.ToUInt16(File.ReadAllBytes(destinationFilePath), SubsystemOffset)
|
|
||||||
.Should()
|
|
||||||
- .Be(2);
|
|
||||||
+ .Be((ushort)Subsystem.WindowsGui);
|
|
||||||
+
|
|
||||||
+ Assert.Equal((ushort)Subsystem.WindowsGui, PEUtils.GetWindowsGraphicalUserInterfaceBit(destinationFilePath));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -153,6 +156,7 @@ public void ItFailsToSetGUISubsystemWithWrongDefault()
|
|
||||||
string destinationFilePath = Path.Combine(testDirectory.Path, "DestinationAppHost.exe.mock");
|
|
||||||
string appBinaryFilePath = "Test/App/Binary/Path.dll";
|
|
||||||
|
|
||||||
+ Assert.Equal(42, PEUtils.GetWindowsGraphicalUserInterfaceBit(sourceAppHostMock));
|
|
||||||
Assert.Throws<AppHostNotCUIException>(() =>
|
|
||||||
HostWriter.CreateAppHost(
|
|
||||||
sourceAppHostMock,
|
|
416
runtime-92920-multiple-ssl-dirs.patch
Normal file
416
runtime-92920-multiple-ssl-dirs.patch
Normal file
@ -0,0 +1,416 @@
|
|||||||
|
From 9aec1e3b0b9ddc02b81bd115399f8951288b261b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tom Deseyn <tom.deseyn@gmail.com>
|
||||||
|
Date: Wed, 11 Oct 2023 18:32:20 +0200
|
||||||
|
Subject: [PATCH] Support specifying multiple directories through SSL_CERT_DIR
|
||||||
|
|
||||||
|
Co-authored-by: Jeremy Barton <jbarton@microsoft.com>
|
||||||
|
Co-authored-by: Kevin Jones <vcsjones@github.com>
|
||||||
|
---
|
||||||
|
.../OpenSslCachedSystemStoreProvider.cs | 232 +++++++++---------
|
||||||
|
.../X509Certificates/X509StoreTests.Unix.cs | 42 +++-
|
||||||
|
2 files changed, 157 insertions(+), 117 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslCachedSystemStoreProvider.cs b/src/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslCachedSystemStoreProvider.cs
|
||||||
|
index 4c9643c01e2..e66b3d1ad11 100644
|
||||||
|
--- a/src/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslCachedSystemStoreProvider.cs
|
||||||
|
+++ b/src/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslCachedSystemStoreProvider.cs
|
||||||
|
@@ -21,14 +21,14 @@ internal sealed class OpenSslCachedSystemStoreProvider : IStorePal
|
||||||
|
private static readonly TimeSpan s_lastWriteRecheckInterval = TimeSpan.FromSeconds(5);
|
||||||
|
private static readonly TimeSpan s_assumeInvalidInterval = TimeSpan.FromMinutes(5);
|
||||||
|
private static readonly Stopwatch s_recheckStopwatch = new Stopwatch();
|
||||||
|
- private static DirectoryInfo? s_rootStoreDirectoryInfo = SafeOpenRootDirectoryInfo();
|
||||||
|
+ private static string[]? s_rootStoreDirectories;
|
||||||
|
private static bool s_defaultRootDir;
|
||||||
|
- private static readonly FileInfo? s_rootStoreFileInfo = SafeOpenRootFileInfo();
|
||||||
|
+ private static string? s_rootStoreFile;
|
||||||
|
+ private static DateTime[]? s_directoryLastWrite;
|
||||||
|
+ private static DateTime s_fileLastWrite;
|
||||||
|
|
||||||
|
// Use non-Value-Tuple so that it's an atomic update.
|
||||||
|
private static Tuple<SafeX509StackHandle, SafeX509StackHandle>? s_nativeCollections;
|
||||||
|
- private static DateTime s_directoryCertsLastWrite;
|
||||||
|
- private static DateTime s_fileCertsLastWrite;
|
||||||
|
|
||||||
|
private readonly bool _isRoot;
|
||||||
|
|
||||||
|
@@ -93,18 +93,11 @@ public void Remove(ICertificatePal cert)
|
||||||
|
{
|
||||||
|
lock (s_recheckStopwatch)
|
||||||
|
{
|
||||||
|
- FileInfo? fileInfo = s_rootStoreFileInfo;
|
||||||
|
- DirectoryInfo? dirInfo = s_rootStoreDirectoryInfo;
|
||||||
|
-
|
||||||
|
- fileInfo?.Refresh();
|
||||||
|
- dirInfo?.Refresh();
|
||||||
|
-
|
||||||
|
if (ret == null ||
|
||||||
|
elapsed > s_assumeInvalidInterval ||
|
||||||
|
- (fileInfo != null && fileInfo.Exists && ContentWriteTime(fileInfo) != s_fileCertsLastWrite) ||
|
||||||
|
- (dirInfo != null && dirInfo.Exists && ContentWriteTime(dirInfo) != s_directoryCertsLastWrite))
|
||||||
|
+ LastWriteTimesHaveChanged())
|
||||||
|
{
|
||||||
|
- ret = LoadMachineStores(dirInfo, fileInfo);
|
||||||
|
+ ret = LoadMachineStores();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -113,9 +106,37 @@ public void Remove(ICertificatePal cert)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static Tuple<SafeX509StackHandle, SafeX509StackHandle> LoadMachineStores(
|
||||||
|
- DirectoryInfo? rootStorePath,
|
||||||
|
- FileInfo? rootStoreFile)
|
||||||
|
+ private static bool LastWriteTimesHaveChanged()
|
||||||
|
+ {
|
||||||
|
+ Debug.Assert(
|
||||||
|
+ Monitor.IsEntered(s_recheckStopwatch),
|
||||||
|
+ "LastWriteTimesHaveChanged assumes a lock(s_recheckStopwatch)");
|
||||||
|
+
|
||||||
|
+ if (s_rootStoreFile != null)
|
||||||
|
+ {
|
||||||
|
+ _ = TryStatFile(s_rootStoreFile, out DateTime lastModified);
|
||||||
|
+ if (lastModified != s_fileLastWrite)
|
||||||
|
+ {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (s_rootStoreDirectories != null && s_directoryLastWrite != null)
|
||||||
|
+ {
|
||||||
|
+ for (int i = 0; i < s_rootStoreDirectories.Length; i++)
|
||||||
|
+ {
|
||||||
|
+ _ = TryStatDirectory(s_rootStoreDirectories[i], out DateTime lastModified);
|
||||||
|
+ if (lastModified != s_directoryLastWrite[i])
|
||||||
|
+ {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static Tuple<SafeX509StackHandle, SafeX509StackHandle> LoadMachineStores()
|
||||||
|
{
|
||||||
|
Debug.Assert(
|
||||||
|
Monitor.IsEntered(s_recheckStopwatch),
|
||||||
|
@@ -126,61 +147,76 @@ public void Remove(ICertificatePal cert)
|
||||||
|
SafeX509StackHandle intermedStore = Interop.Crypto.NewX509Stack();
|
||||||
|
Interop.Crypto.CheckValidOpenSslHandle(intermedStore);
|
||||||
|
|
||||||
|
- DateTime newFileTime = default;
|
||||||
|
- DateTime newDirTime = default;
|
||||||
|
-
|
||||||
|
var uniqueRootCerts = new HashSet<X509Certificate2>();
|
||||||
|
var uniqueIntermediateCerts = new HashSet<X509Certificate2>();
|
||||||
|
bool firstLoad = (s_nativeCollections == null);
|
||||||
|
|
||||||
|
- if (rootStoreFile != null && rootStoreFile.Exists)
|
||||||
|
+ if (firstLoad)
|
||||||
|
{
|
||||||
|
- newFileTime = ContentWriteTime(rootStoreFile);
|
||||||
|
- ProcessFile(rootStoreFile);
|
||||||
|
+ s_rootStoreDirectories = GetRootStoreDirectories(out s_defaultRootDir);
|
||||||
|
+ s_directoryLastWrite = new DateTime[s_rootStoreDirectories.Length];
|
||||||
|
+ s_rootStoreFile = GetRootStoreFile();
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ Debug.Assert(s_rootStoreDirectories is not null);
|
||||||
|
+ Debug.Assert(s_directoryLastWrite is not null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (s_rootStoreFile != null)
|
||||||
|
+ {
|
||||||
|
+ ProcessFile(s_rootStoreFile, out s_fileLastWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasStoreData = false;
|
||||||
|
|
||||||
|
- if (rootStorePath != null && rootStorePath.Exists)
|
||||||
|
+ for (int i = 0; i < s_rootStoreDirectories.Length; i++)
|
||||||
|
{
|
||||||
|
- newDirTime = ContentWriteTime(rootStorePath);
|
||||||
|
- hasStoreData = ProcessDir(rootStorePath);
|
||||||
|
+ hasStoreData = ProcessDir(s_rootStoreDirectories[i], out s_directoryLastWrite[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstLoad && !hasStoreData && s_defaultRootDir)
|
||||||
|
{
|
||||||
|
- DirectoryInfo etcSslCerts = new DirectoryInfo("/etc/ssl/certs");
|
||||||
|
-
|
||||||
|
- if (etcSslCerts.Exists)
|
||||||
|
+ const string DefaultCertDir = "/etc/ssl/certs";
|
||||||
|
+ hasStoreData = ProcessDir(DefaultCertDir, out DateTime lastModified);
|
||||||
|
+ if (hasStoreData)
|
||||||
|
{
|
||||||
|
- DateTime tmpTime = ContentWriteTime(etcSslCerts);
|
||||||
|
- hasStoreData = ProcessDir(etcSslCerts);
|
||||||
|
-
|
||||||
|
- if (hasStoreData)
|
||||||
|
- {
|
||||||
|
- newDirTime = tmpTime;
|
||||||
|
- s_rootStoreDirectoryInfo = etcSslCerts;
|
||||||
|
- }
|
||||||
|
+ s_rootStoreDirectories = new[] { DefaultCertDir };
|
||||||
|
+ s_directoryLastWrite = new[] { lastModified };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- bool ProcessDir(DirectoryInfo dir)
|
||||||
|
+ bool ProcessDir(string dir, out DateTime lastModified)
|
||||||
|
{
|
||||||
|
+ if (!TryStatDirectory(dir, out lastModified))
|
||||||
|
+ {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
bool hasStoreData = false;
|
||||||
|
|
||||||
|
- foreach (FileInfo file in dir.EnumerateFiles())
|
||||||
|
+ foreach (string file in Directory.EnumerateFiles(dir))
|
||||||
|
{
|
||||||
|
- hasStoreData |= ProcessFile(file);
|
||||||
|
+ hasStoreData |= ProcessFile(file, out _, skipStat: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasStoreData;
|
||||||
|
}
|
||||||
|
|
||||||
|
- bool ProcessFile(FileInfo file)
|
||||||
|
+ bool ProcessFile(string file, out DateTime lastModified, bool skipStat = false)
|
||||||
|
{
|
||||||
|
bool readData = false;
|
||||||
|
|
||||||
|
- using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(file.FullName, "rb"))
|
||||||
|
+ if (skipStat)
|
||||||
|
+ {
|
||||||
|
+ lastModified = default;
|
||||||
|
+ }
|
||||||
|
+ else if (!TryStatFile(file, out lastModified))
|
||||||
|
+ {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(file, "rb"))
|
||||||
|
{
|
||||||
|
// The handle may be invalid, for example when we don't have read permission for the file.
|
||||||
|
if (fileBio.IsInvalid)
|
||||||
|
@@ -274,114 +310,78 @@ bool ProcessFile(FileInfo file)
|
||||||
|
// on every call.
|
||||||
|
|
||||||
|
Volatile.Write(ref s_nativeCollections, newCollections);
|
||||||
|
- s_directoryCertsLastWrite = newDirTime;
|
||||||
|
- s_fileCertsLastWrite = newFileTime;
|
||||||
|
s_recheckStopwatch.Restart();
|
||||||
|
return newCollections;
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static FileInfo? SafeOpenRootFileInfo()
|
||||||
|
+ private static string? GetRootStoreFile()
|
||||||
|
{
|
||||||
|
string? rootFile = Interop.Crypto.GetX509RootStoreFile();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(rootFile))
|
||||||
|
{
|
||||||
|
- try
|
||||||
|
- {
|
||||||
|
- return new FileInfo(rootFile);
|
||||||
|
- }
|
||||||
|
- catch (ArgumentException)
|
||||||
|
- {
|
||||||
|
- // If SSL_CERT_FILE is set to the empty string, or anything else which gives
|
||||||
|
- // "The path is not of a legal form", then the GetX509RootStoreFile value is ignored.
|
||||||
|
- }
|
||||||
|
+ return Path.GetFullPath(rootFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static DirectoryInfo? SafeOpenRootDirectoryInfo()
|
||||||
|
+ private static string[] GetRootStoreDirectories(out bool isDefault)
|
||||||
|
{
|
||||||
|
- string? rootDirectory = Interop.Crypto.GetX509RootStorePath(out s_defaultRootDir);
|
||||||
|
+ string rootDirectory = Interop.Crypto.GetX509RootStorePath(out isDefault) ?? "";
|
||||||
|
|
||||||
|
- if (!string.IsNullOrEmpty(rootDirectory))
|
||||||
|
- {
|
||||||
|
- try
|
||||||
|
- {
|
||||||
|
- return new DirectoryInfo(rootDirectory);
|
||||||
|
- }
|
||||||
|
- catch (ArgumentException)
|
||||||
|
- {
|
||||||
|
- // If SSL_CERT_DIR is set to the empty string, or anything else which gives
|
||||||
|
- // "The path is not of a legal form", then the GetX509RootStoreFile value is ignored.
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return null;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private static DateTime ContentWriteTime(FileInfo info)
|
||||||
|
- {
|
||||||
|
- string path = info.FullName;
|
||||||
|
- string? target = Interop.Sys.ReadLink(path);
|
||||||
|
-
|
||||||
|
- if (string.IsNullOrEmpty(target))
|
||||||
|
- {
|
||||||
|
- return info.LastWriteTimeUtc;
|
||||||
|
- }
|
||||||
|
+ string[] directories = rootDirectory.Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
- if (target[0] != '/')
|
||||||
|
+ for (int i = 0; i < directories.Length; i++)
|
||||||
|
{
|
||||||
|
- target = Path.Join(info.Directory?.FullName, target);
|
||||||
|
+ directories[i] = Path.GetFullPath(directories[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- try
|
||||||
|
+ // Remove duplicates.
|
||||||
|
+ if (directories.Length > 1)
|
||||||
|
{
|
||||||
|
- var targetInfo = new FileInfo(target);
|
||||||
|
-
|
||||||
|
- if (targetInfo.Exists)
|
||||||
|
+ var set = new HashSet<string>(directories, StringComparer.Ordinal);
|
||||||
|
+ if (set.Count != directories.Length)
|
||||||
|
{
|
||||||
|
- return targetInfo.LastWriteTimeUtc;
|
||||||
|
+ // Preserve the original order.
|
||||||
|
+ string[] directoriesTrimmed = new string[set.Count];
|
||||||
|
+ int j = 0;
|
||||||
|
+ for (int i = 0; i < directories.Length; i++)
|
||||||
|
+ {
|
||||||
|
+ string directory = directories[i];
|
||||||
|
+ if (set.Remove(directory))
|
||||||
|
+ {
|
||||||
|
+ directoriesTrimmed[j++] = directory;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ Debug.Assert(set.Count == 0);
|
||||||
|
+ directories = directoriesTrimmed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- catch (ArgumentException)
|
||||||
|
- {
|
||||||
|
- // If we can't load information about the link path, just treat it as not a link.
|
||||||
|
- }
|
||||||
|
|
||||||
|
- return info.LastWriteTimeUtc;
|
||||||
|
+ return directories;
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static DateTime ContentWriteTime(DirectoryInfo info)
|
||||||
|
- {
|
||||||
|
- string path = info.FullName;
|
||||||
|
- string? target = Interop.Sys.ReadLink(path);
|
||||||
|
-
|
||||||
|
- if (string.IsNullOrEmpty(target))
|
||||||
|
- {
|
||||||
|
- return info.LastWriteTimeUtc;
|
||||||
|
- }
|
||||||
|
+ private static bool TryStatFile(string path, out DateTime lastModified)
|
||||||
|
+ => TryStat(path, Interop.Sys.FileTypes.S_IFREG, out lastModified);
|
||||||
|
|
||||||
|
- if (target[0] != '/')
|
||||||
|
- {
|
||||||
|
- target = Path.Join(info.Parent?.FullName, target);
|
||||||
|
- }
|
||||||
|
+ private static bool TryStatDirectory(string path, out DateTime lastModified)
|
||||||
|
+ => TryStat(path, Interop.Sys.FileTypes.S_IFDIR, out lastModified);
|
||||||
|
|
||||||
|
- try
|
||||||
|
- {
|
||||||
|
- var targetInfo = new DirectoryInfo(target);
|
||||||
|
+ private static bool TryStat(string path, int fileType, out DateTime lastModified)
|
||||||
|
+ {
|
||||||
|
+ lastModified = default;
|
||||||
|
|
||||||
|
- if (targetInfo.Exists)
|
||||||
|
- {
|
||||||
|
- return targetInfo.LastWriteTimeUtc;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- catch (ArgumentException)
|
||||||
|
+ Interop.Sys.FileStatus status;
|
||||||
|
+ // Use Stat to follow links.
|
||||||
|
+ if (Interop.Sys.Stat(path, out status) < 0 ||
|
||||||
|
+ (status.Mode & Interop.Sys.FileTypes.S_IFMT) != fileType)
|
||||||
|
{
|
||||||
|
- // If we can't load information about the link path, just treat it as not a link.
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
- return info.LastWriteTimeUtc;
|
||||||
|
+ lastModified = DateTime.UnixEpoch + TimeSpan.FromTicks(status.MTime * TimeSpan.TicksPerSecond + status.MTimeNsec / TimeSpan.NanosecondsPerTick);
|
||||||
|
+ return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/runtime/src/libraries/System.Security.Cryptography/tests/X509Certificates/X509StoreTests.Unix.cs b/src/runtime/src/libraries/System.Security.Cryptography/tests/X509Certificates/X509StoreTests.Unix.cs
|
||||||
|
index 0efb6c12028..f460d6b9bd6 100644
|
||||||
|
--- a/src/runtime/src/libraries/System.Security.Cryptography/tests/X509Certificates/X509StoreTests.Unix.cs
|
||||||
|
+++ b/src/runtime/src/libraries/System.Security.Cryptography/tests/X509Certificates/X509StoreTests.Unix.cs
|
||||||
|
@@ -10,7 +10,6 @@ namespace System.Security.Cryptography.X509Certificates.Tests
|
||||||
|
{
|
||||||
|
public partial class X509StoreTests
|
||||||
|
{
|
||||||
|
-
|
||||||
|
[ConditionalFact(nameof(NotRunningAsRootAndRemoteExecutorSupported))] // root can read '2.pem'
|
||||||
|
[PlatformSpecific(TestPlatforms.Linux)] // Windows/OSX doesn't use SSL_CERT_{DIR,FILE}.
|
||||||
|
private void X509Store_MachineStoreLoadSkipsInvalidFiles()
|
||||||
|
@@ -50,6 +49,47 @@ private void X509Store_MachineStoreLoadSkipsInvalidFiles()
|
||||||
|
}, new RemoteInvokeOptions { StartInfo = psi }).Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
|
||||||
|
+ [PlatformSpecific(TestPlatforms.Linux)] // Windows/OSX doesn't use SSL_CERT_{DIR,FILE}.
|
||||||
|
+ private void X509Store_MachineStoreLoadsMutipleSslCertDirectories()
|
||||||
|
+ {
|
||||||
|
+ // Create 3 certificates and place them in two directories that will be passed
|
||||||
|
+ // using SSL_CERT_DIR.
|
||||||
|
+ string sslCertDir1 = GetTestFilePath();
|
||||||
|
+ Directory.CreateDirectory(sslCertDir1);
|
||||||
|
+ File.WriteAllBytes(Path.Combine(sslCertDir1, "1.pem"), TestData.SelfSigned1PemBytes);
|
||||||
|
+ File.WriteAllBytes(Path.Combine(sslCertDir1, "2.pem"), TestData.SelfSigned2PemBytes);
|
||||||
|
+ string sslCertDir2 = GetTestFilePath();
|
||||||
|
+ Directory.CreateDirectory(sslCertDir2);
|
||||||
|
+ File.WriteAllBytes(Path.Combine(sslCertDir2, "3.pem"), TestData.SelfSigned3PemBytes);
|
||||||
|
+
|
||||||
|
+ // Add a non-existing directory after each valid directory to verify they are ignored.
|
||||||
|
+ string sslCertDir = string.Join(Path.PathSeparator,
|
||||||
|
+ new[] {
|
||||||
|
+ sslCertDir1,
|
||||||
|
+ sslCertDir2,
|
||||||
|
+ "", // empty string
|
||||||
|
+ sslCertDir2, // duplicate directory
|
||||||
|
+ "/invalid2", // path that does not exist
|
||||||
|
+ });
|
||||||
|
+
|
||||||
|
+ var psi = new ProcessStartInfo();
|
||||||
|
+ psi.Environment.Add("SSL_CERT_DIR", sslCertDir);
|
||||||
|
+ // Set SSL_CERT_FILE to avoid loading the default bundle file.
|
||||||
|
+ psi.Environment.Add("SSL_CERT_FILE", "/nonexisting");
|
||||||
|
+ RemoteExecutor.Invoke(() =>
|
||||||
|
+ {
|
||||||
|
+ Assert.NotNull(Environment.GetEnvironmentVariable("SSL_CERT_DIR"));
|
||||||
|
+ using (var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine))
|
||||||
|
+ {
|
||||||
|
+ store.Open(OpenFlags.OpenExistingOnly);
|
||||||
|
+
|
||||||
|
+ // Check nr of certificates in store.
|
||||||
|
+ Assert.Equal(3, store.Certificates.Count);
|
||||||
|
+ }
|
||||||
|
+ }, new RemoteInvokeOptions { StartInfo = psi }).Dispose();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public static bool NotRunningAsRootAndRemoteExecutorSupported => !Environment.IsPrivilegedProcess && RemoteExecutor.IsSupported;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
From eaa9d8ebefb59cb289e147223b242d77e69f0861 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Elinor Fung <elfung@microsoft.com>
|
|
||||||
Date: Wed, 20 Sep 2023 15:55:32 -0700
|
|
||||||
Subject: [PATCH] Skip getting Windows GUI bit on non-Windows in
|
|
||||||
AppHostShellShimMaker
|
|
||||||
|
|
||||||
---
|
|
||||||
src/Cli/dotnet/ShellShim/AppHostShimMaker.cs | 6 +++---
|
|
||||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/sdk/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs b/src/sdk/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs
|
|
||||||
index eb9a1332299..7240150e06d 100644
|
|
||||||
--- a/src/sdk/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs
|
|
||||||
+++ b/src/sdk/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs
|
|
||||||
@@ -40,14 +40,14 @@ public void CreateApphostShellShim(FilePath entryPoint, FilePath shimPath)
|
|
||||||
string entryPointFullPath = Path.GetFullPath(entryPoint.Value);
|
|
||||||
var appBinaryFilePath = Path.GetRelativePath(Path.GetDirectoryName(appHostDestinationFilePath), entryPointFullPath);
|
|
||||||
|
|
||||||
-
|
|
||||||
if (ResourceUpdater.IsSupportedOS())
|
|
||||||
{
|
|
||||||
- var windowsGraphicalUserInterfaceBit = PEUtils.GetWindowsGraphicalUserInterfaceBit(entryPointFullPath);
|
|
||||||
+ bool windowsGraphicalUserInterface = OperatingSystem.IsWindows()
|
|
||||||
+ && PEUtils.GetWindowsGraphicalUserInterfaceBit(entryPointFullPath) == WindowsGUISubsystem;
|
|
||||||
HostWriter.CreateAppHost(appHostSourceFilePath: appHostSourcePath,
|
|
||||||
appHostDestinationFilePath: appHostDestinationFilePath,
|
|
||||||
appBinaryFilePath: appBinaryFilePath,
|
|
||||||
- windowsGraphicalUserInterface: (windowsGraphicalUserInterfaceBit == WindowsGUISubsystem) && OperatingSystem.IsWindows(),
|
|
||||||
+ windowsGraphicalUserInterface: windowsGraphicalUserInterface,
|
|
||||||
assemblyToCopyResourcesFrom: entryPointFullPath,
|
|
||||||
enableMacOSCodeSign: OperatingSystem.IsMacOS());
|
|
||||||
}
|
|
2
sources
2
sources
@ -1 +1 @@
|
|||||||
SHA512 (dotnet-v8.0.0-rc.1.23419.4.tar.gz) = 6a3f7e20adce8e76e10b235427f16a8b6bbc928be0cec5cb168722d497ac01cce8b6a16b6f12066b422ef33c2c39ad620f9bed24c247e7b75a2b998332f09873
|
SHA512 (dotnet-v8.0.0-rc.2.23479.6.tar.gz) = 604220e91cfb3b0909b5127ed6b53b0a661f6258dd87068e5eb2f589729fb7b634ce934967e821075f027e0d2e12d15595a2fff57099efba036f760c6eb79493
|
||||||
|
Loading…
Reference in New Issue
Block a user