From 4194343c39fa66778a8de9804c88789bd41dae48 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 4 May 2021 22:47:19 -0700 Subject: Move Http.wixext into ext --- .editorconfig | 37 -- Http.wixext.sln | 61 -- README.md | 2 - appveyor.cmd | 14 - appveyor.yml | 40 -- global.json | 5 - nuget.config | 17 - src/.editorconfig | 37 ++ src/CSharp.Build.props | 11 - src/Cpp.Build.props | 86 --- src/Directory.Build.props | 29 - src/Directory.Build.targets | 48 -- src/FindLocalWix.props | 8 - src/ca/caDecor.h | 13 - src/ca/cost.h | 6 - src/ca/dllmain.cpp | 26 - src/ca/httpca.vcxproj | 72 --- src/ca/httpca.vcxproj.filters | 42 -- src/ca/packages.config | 5 - src/ca/precomp.h | 25 - src/ca/snisslcert.cpp | 704 --------------------- src/ca/wixhttpca.cpp | 530 ---------------- src/ca/wixhttpca.def | 12 - src/ext/Http/CSharp.Build.props | 11 + src/ext/Http/Cpp.Build.props | 86 +++ src/ext/Http/Directory.Build.props | 29 + src/ext/Http/Directory.Build.targets | 48 ++ src/ext/Http/FindLocalWix.props | 8 + src/ext/Http/Http.wixext.sln | 61 ++ src/ext/Http/README.md | 2 + src/ext/Http/appveyor.cmd | 14 + src/ext/Http/appveyor.yml | 40 ++ src/ext/Http/ca/caDecor.h | 13 + src/ext/Http/ca/cost.h | 6 + src/ext/Http/ca/dllmain.cpp | 26 + src/ext/Http/ca/httpca.vcxproj | 72 +++ src/ext/Http/ca/httpca.vcxproj.filters | 42 ++ src/ext/Http/ca/packages.config | 5 + src/ext/Http/ca/precomp.h | 25 + src/ext/Http/ca/snisslcert.cpp | 704 +++++++++++++++++++++ src/ext/Http/ca/wixhttpca.cpp | 530 ++++++++++++++++ src/ext/Http/ca/wixhttpca.def | 12 + src/ext/Http/nuget.config | 17 + .../WixToolsetTest.Http/HttpExtensionFixture.cs | 57 ++ .../TestData/SniSsl/Package.en-us.wxl | 11 + .../TestData/SniSsl/Package.wxs | 15 + .../TestData/SniSsl/PackageComponents.wxs | 12 + .../TestData/SniSsl/example.txt | 1 + .../TestData/UsingUrlReservation/Package.en-us.wxl | 11 + .../TestData/UsingUrlReservation/Package.wxs | 15 + .../UsingUrlReservation/PackageComponents.wxs | 16 + .../TestData/UsingUrlReservation/example.txt | 1 + .../WixToolsetTest.Http/WixToolsetTest.Http.csproj | 38 ++ src/ext/Http/wix.snk | Bin 0 -> 596 bytes src/ext/Http/wixext/HttpCompiler.cs | 383 +++++++++++ src/ext/Http/wixext/HttpConstants.cs | 15 + src/ext/Http/wixext/HttpDecompiler.cs | 137 ++++ src/ext/Http/wixext/HttpErrors.cs | 31 + src/ext/Http/wixext/HttpExtensionData.cs | 30 + src/ext/Http/wixext/HttpExtensionFactory.cs | 18 + src/ext/Http/wixext/HttpTableDefinitions.cs | 60 ++ .../HttpWindowsInstallerBackendBinderExtension.cs | 13 + src/ext/Http/wixext/Symbols/HandleExisting.cs | 14 + .../Http/wixext/Symbols/HttpSymbolDefinitions.cs | 47 ++ .../Http/wixext/Symbols/WixHttpSniSslCertSymbol.cs | 95 +++ src/ext/Http/wixext/Symbols/WixHttpUrlAceSymbol.cs | 63 ++ .../wixext/Symbols/WixHttpUrlReservationSymbol.cs | 71 +++ src/ext/Http/wixext/WixToolset.Http.wixext.csproj | 31 + src/ext/Http/wixext/WixToolset.Http.wixext.targets | 11 + src/ext/Http/wixlib/HttpExtension.wxs | 10 + src/ext/Http/wixlib/HttpExtension_Platform.wxi | 64 ++ src/ext/Http/wixlib/HttpExtension_arm64.wxs | 7 + src/ext/Http/wixlib/HttpExtension_x64.wxs | 7 + src/ext/Http/wixlib/HttpExtension_x86.wxs | 7 + src/ext/Http/wixlib/caDecor.wxi | 39 ++ src/ext/Http/wixlib/caerr.wxi | 96 +++ src/ext/Http/wixlib/en-us.wxl | 17 + src/ext/Http/wixlib/http.wixproj | 24 + src/ext/global.json | 5 + .../WixToolsetTest.Http/HttpExtensionFixture.cs | 57 -- .../TestData/SniSsl/Package.en-us.wxl | 11 - .../TestData/SniSsl/Package.wxs | 15 - .../TestData/SniSsl/PackageComponents.wxs | 12 - .../TestData/SniSsl/example.txt | 1 - .../TestData/UsingUrlReservation/Package.en-us.wxl | 11 - .../TestData/UsingUrlReservation/Package.wxs | 15 - .../UsingUrlReservation/PackageComponents.wxs | 16 - .../TestData/UsingUrlReservation/example.txt | 1 - .../WixToolsetTest.Http/WixToolsetTest.Http.csproj | 38 -- src/version.json | 11 + src/wix.snk | Bin 596 -> 0 bytes src/wixext/HttpCompiler.cs | 383 ----------- src/wixext/HttpConstants.cs | 15 - src/wixext/HttpDecompiler.cs | 137 ---- src/wixext/HttpErrors.cs | 31 - src/wixext/HttpExtensionData.cs | 30 - src/wixext/HttpExtensionFactory.cs | 18 - src/wixext/HttpTableDefinitions.cs | 60 -- .../HttpWindowsInstallerBackendBinderExtension.cs | 13 - src/wixext/Symbols/HandleExisting.cs | 14 - src/wixext/Symbols/HttpSymbolDefinitions.cs | 47 -- src/wixext/Symbols/WixHttpSniSslCertSymbol.cs | 95 --- src/wixext/Symbols/WixHttpUrlAceSymbol.cs | 63 -- src/wixext/Symbols/WixHttpUrlReservationSymbol.cs | 71 --- src/wixext/WixToolset.Http.wixext.csproj | 31 - src/wixext/WixToolset.Http.wixext.targets | 11 - src/wixlib/HttpExtension.wxs | 10 - src/wixlib/HttpExtension_Platform.wxi | 64 -- src/wixlib/HttpExtension_arm64.wxs | 7 - src/wixlib/HttpExtension_x64.wxs | 7 - src/wixlib/HttpExtension_x86.wxs | 7 - src/wixlib/caDecor.wxi | 39 -- src/wixlib/caerr.wxi | 96 --- src/wixlib/en-us.wxl | 17 - src/wixlib/http.wixproj | 24 - version.json | 11 - 116 files changed, 3271 insertions(+), 3271 deletions(-) delete mode 100644 .editorconfig delete mode 100644 Http.wixext.sln delete mode 100644 README.md delete mode 100644 appveyor.cmd delete mode 100644 appveyor.yml delete mode 100644 global.json delete mode 100644 nuget.config create mode 100644 src/.editorconfig delete mode 100644 src/CSharp.Build.props delete mode 100644 src/Cpp.Build.props delete mode 100644 src/Directory.Build.props delete mode 100644 src/Directory.Build.targets delete mode 100644 src/FindLocalWix.props delete mode 100644 src/ca/caDecor.h delete mode 100644 src/ca/cost.h delete mode 100644 src/ca/dllmain.cpp delete mode 100644 src/ca/httpca.vcxproj delete mode 100644 src/ca/httpca.vcxproj.filters delete mode 100644 src/ca/packages.config delete mode 100644 src/ca/precomp.h delete mode 100644 src/ca/snisslcert.cpp delete mode 100644 src/ca/wixhttpca.cpp delete mode 100644 src/ca/wixhttpca.def create mode 100644 src/ext/Http/CSharp.Build.props create mode 100644 src/ext/Http/Cpp.Build.props create mode 100644 src/ext/Http/Directory.Build.props create mode 100644 src/ext/Http/Directory.Build.targets create mode 100644 src/ext/Http/FindLocalWix.props create mode 100644 src/ext/Http/Http.wixext.sln create mode 100644 src/ext/Http/README.md create mode 100644 src/ext/Http/appveyor.cmd create mode 100644 src/ext/Http/appveyor.yml create mode 100644 src/ext/Http/ca/caDecor.h create mode 100644 src/ext/Http/ca/cost.h create mode 100644 src/ext/Http/ca/dllmain.cpp create mode 100644 src/ext/Http/ca/httpca.vcxproj create mode 100644 src/ext/Http/ca/httpca.vcxproj.filters create mode 100644 src/ext/Http/ca/packages.config create mode 100644 src/ext/Http/ca/precomp.h create mode 100644 src/ext/Http/ca/snisslcert.cpp create mode 100644 src/ext/Http/ca/wixhttpca.cpp create mode 100644 src/ext/Http/ca/wixhttpca.def create mode 100644 src/ext/Http/nuget.config create mode 100644 src/ext/Http/test/WixToolsetTest.Http/HttpExtensionFixture.cs create mode 100644 src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/Package.en-us.wxl create mode 100644 src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/Package.wxs create mode 100644 src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/PackageComponents.wxs create mode 100644 src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/example.txt create mode 100644 src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.en-us.wxl create mode 100644 src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.wxs create mode 100644 src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/PackageComponents.wxs create mode 100644 src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/example.txt create mode 100644 src/ext/Http/test/WixToolsetTest.Http/WixToolsetTest.Http.csproj create mode 100644 src/ext/Http/wix.snk create mode 100644 src/ext/Http/wixext/HttpCompiler.cs create mode 100644 src/ext/Http/wixext/HttpConstants.cs create mode 100644 src/ext/Http/wixext/HttpDecompiler.cs create mode 100644 src/ext/Http/wixext/HttpErrors.cs create mode 100644 src/ext/Http/wixext/HttpExtensionData.cs create mode 100644 src/ext/Http/wixext/HttpExtensionFactory.cs create mode 100644 src/ext/Http/wixext/HttpTableDefinitions.cs create mode 100644 src/ext/Http/wixext/HttpWindowsInstallerBackendBinderExtension.cs create mode 100644 src/ext/Http/wixext/Symbols/HandleExisting.cs create mode 100644 src/ext/Http/wixext/Symbols/HttpSymbolDefinitions.cs create mode 100644 src/ext/Http/wixext/Symbols/WixHttpSniSslCertSymbol.cs create mode 100644 src/ext/Http/wixext/Symbols/WixHttpUrlAceSymbol.cs create mode 100644 src/ext/Http/wixext/Symbols/WixHttpUrlReservationSymbol.cs create mode 100644 src/ext/Http/wixext/WixToolset.Http.wixext.csproj create mode 100644 src/ext/Http/wixext/WixToolset.Http.wixext.targets create mode 100644 src/ext/Http/wixlib/HttpExtension.wxs create mode 100644 src/ext/Http/wixlib/HttpExtension_Platform.wxi create mode 100644 src/ext/Http/wixlib/HttpExtension_arm64.wxs create mode 100644 src/ext/Http/wixlib/HttpExtension_x64.wxs create mode 100644 src/ext/Http/wixlib/HttpExtension_x86.wxs create mode 100644 src/ext/Http/wixlib/caDecor.wxi create mode 100644 src/ext/Http/wixlib/caerr.wxi create mode 100644 src/ext/Http/wixlib/en-us.wxl create mode 100644 src/ext/Http/wixlib/http.wixproj create mode 100644 src/ext/global.json delete mode 100644 src/test/WixToolsetTest.Http/HttpExtensionFixture.cs delete mode 100644 src/test/WixToolsetTest.Http/TestData/SniSsl/Package.en-us.wxl delete mode 100644 src/test/WixToolsetTest.Http/TestData/SniSsl/Package.wxs delete mode 100644 src/test/WixToolsetTest.Http/TestData/SniSsl/PackageComponents.wxs delete mode 100644 src/test/WixToolsetTest.Http/TestData/SniSsl/example.txt delete mode 100644 src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.en-us.wxl delete mode 100644 src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.wxs delete mode 100644 src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/PackageComponents.wxs delete mode 100644 src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/example.txt delete mode 100644 src/test/WixToolsetTest.Http/WixToolsetTest.Http.csproj create mode 100644 src/version.json delete mode 100644 src/wix.snk delete mode 100644 src/wixext/HttpCompiler.cs delete mode 100644 src/wixext/HttpConstants.cs delete mode 100644 src/wixext/HttpDecompiler.cs delete mode 100644 src/wixext/HttpErrors.cs delete mode 100644 src/wixext/HttpExtensionData.cs delete mode 100644 src/wixext/HttpExtensionFactory.cs delete mode 100644 src/wixext/HttpTableDefinitions.cs delete mode 100644 src/wixext/HttpWindowsInstallerBackendBinderExtension.cs delete mode 100644 src/wixext/Symbols/HandleExisting.cs delete mode 100644 src/wixext/Symbols/HttpSymbolDefinitions.cs delete mode 100644 src/wixext/Symbols/WixHttpSniSslCertSymbol.cs delete mode 100644 src/wixext/Symbols/WixHttpUrlAceSymbol.cs delete mode 100644 src/wixext/Symbols/WixHttpUrlReservationSymbol.cs delete mode 100644 src/wixext/WixToolset.Http.wixext.csproj delete mode 100644 src/wixext/WixToolset.Http.wixext.targets delete mode 100644 src/wixlib/HttpExtension.wxs delete mode 100644 src/wixlib/HttpExtension_Platform.wxi delete mode 100644 src/wixlib/HttpExtension_arm64.wxs delete mode 100644 src/wixlib/HttpExtension_x64.wxs delete mode 100644 src/wixlib/HttpExtension_x86.wxs delete mode 100644 src/wixlib/caDecor.wxi delete mode 100644 src/wixlib/caerr.wxi delete mode 100644 src/wixlib/en-us.wxl delete mode 100644 src/wixlib/http.wixproj delete mode 100644 version.json diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 1d72e683..00000000 --- a/.editorconfig +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig -# then update all of the repos. - -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true - -[*.{cs,vb}] -dotnet_sort_system_directives_first = true - -[*.cs] -csharp_indent_case_contents = true : error -csharp_indent_switch_labels = true : error -csharp_new_line_before_open_brace = all -csharp_prefer_braces = true : error -csharp_style_expression_bodied_methods = when_on_single_line : suggestion -csharp_style_expression_bodied_constructors = when_on_single_line : suggestion -csharp_style_expression_bodied_operators = when_on_single_line : suggestion -csharp_style_expression_bodied_properties = when_on_single_line : suggestion -csharp_style_expression_bodied_indexers = when_on_single_line : suggestion -csharp_style_expression_bodied_accessors = when_on_single_line : suggestion -csharp_style_var_elsewhere = true : suggestion -csharp_style_var_for_built_in_types = true : suggestion -csharp_style_var_when_type_is_apparent = true : suggestion -dotnet_style_qualification_for_event = true : error -dotnet_style_qualification_for_field = true : error -dotnet_style_qualification_for_method = true : error -dotnet_style_qualification_for_property = true : error - -[*.targets] -indent_size = 2 diff --git a/Http.wixext.sln b/Http.wixext.sln deleted file mode 100644 index fe5c52e9..00000000 --- a/Http.wixext.sln +++ /dev/null @@ -1,61 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30204.135 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "httpca", "src\ca\httpca.vcxproj", "{90743805-C043-47C7-B5FF-8F5EE5C8A2DE}" -EndProject -Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "http", "src\wixlib\http.wixproj", "{055C1517-4CED-4199-BCDE-A383E5C4EF78}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Http.wixext", "src\wixext\WixToolset.Http.wixext.csproj", "{AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Http", "src\test\WixToolsetTest.Http\WixToolsetTest.Http.csproj", "{6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Debug|Any CPU.Build.0 = Debug|Win32 - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Debug|x86.ActiveCfg = Debug|Win32 - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Debug|x86.Build.0 = Debug|Win32 - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Release|Any CPU.ActiveCfg = Release|Win32 - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Release|Any CPU.Build.0 = Release|Win32 - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Release|x86.ActiveCfg = Release|Win32 - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Release|x86.Build.0 = Release|Win32 - {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Debug|Any CPU.ActiveCfg = Debug|x86 - {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Debug|Any CPU.Build.0 = Debug|x86 - {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Debug|x86.ActiveCfg = Debug|x86 - {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Debug|x86.Build.0 = Debug|x86 - {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Release|Any CPU.ActiveCfg = Release|x86 - {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Release|Any CPU.Build.0 = Release|x86 - {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Release|x86.ActiveCfg = Release|x86 - {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Release|x86.Build.0 = Release|x86 - {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Debug|x86.ActiveCfg = Debug|Any CPU - {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Debug|x86.Build.0 = Debug|Any CPU - {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Release|Any CPU.Build.0 = Release|Any CPU - {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Release|x86.ActiveCfg = Release|Any CPU - {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Release|x86.Build.0 = Release|Any CPU - {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Debug|x86.ActiveCfg = Debug|Any CPU - {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Debug|x86.Build.0 = Debug|Any CPU - {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Release|Any CPU.Build.0 = Release|Any CPU - {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Release|x86.ActiveCfg = Release|Any CPU - {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {570B1B57-B310-4493-A3A3-B40D7374EFC3} - EndGlobalSection -EndGlobal diff --git a/README.md b/README.md deleted file mode 100644 index 2d9f1895..00000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Http.wixext -WixToolset.Http.wixext - Http WiX Toolset Extension diff --git a/appveyor.cmd b/appveyor.cmd deleted file mode 100644 index 16a34ff9..00000000 --- a/appveyor.cmd +++ /dev/null @@ -1,14 +0,0 @@ -@setlocal -@pushd %~dp0 - -nuget restore || exit /b - -msbuild -p:Configuration=Release -t:Restore || exit /b - -msbuild -p:Configuration=Release src\test\WixToolsetTest.Http\WixToolsetTest.Http.csproj || exit /b -dotnet test -c Release --no-build src\test\WixToolsetTest.Http || exit /b - -msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.Http.wixext.csproj || exit /b - -@popd -@endlocal \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7c686b04..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml -# then update all of the repos. - -branches: - only: - - master - - develop - -image: Visual Studio 2019 - -version: 0.0.0.{build} -configuration: Release - -environment: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - NUGET_XMLDOC_MODE: skip - -build_script: - - appveyor.cmd - -pull_requests: - do_not_increment_build_number: true - -nuget: - disable_publish_on_pr: true - -skip_branch_with_pr: true -skip_tags: true - -artifacts: -- path: build\Release\**\*.nupkg - name: nuget - -notifications: -- provider: Slack - incoming_webhook: - secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/global.json b/global.json deleted file mode 100644 index 23dd3fa6..00000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0211" - } -} diff --git a/nuget.config b/nuget.config deleted file mode 100644 index db7aba29..00000000 --- a/nuget.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,37 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props deleted file mode 100644 index b12f4c6e..00000000 --- a/src/CSharp.Build.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - - true - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) - - diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props deleted file mode 100644 index 9b7a1bb5..00000000 --- a/src/Cpp.Build.props +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - Win32 - $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ - $(OutputPath)$(Platform)\ - - - - $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) - - - - - $(DisableSpecificCompilerWarnings) - Level4 - $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - Use - precomp.h - StdCall - true - false - -YlprecompDefine - /Zc:threadSafeInit- %(AdditionalOptions) - true - - - $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) - $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) - - - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) - - - $(ProjectSubSystem) - $(ProjectModuleDefinitionFile) - $(ResourceOnlyDll) - true - $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) - /IGNORE:4099 %(AdditionalOptions) - - - - - - NoExtensions - - - - - CDecl - - - - - OldStyle - true - true - - - - - Disabled - EnableFastChecks - _DEBUG;DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - MinSpace - NDEBUG;%(PreprocessorDefinitions) - true - true - MultiThreaded - - - true - true - - - diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index f83cc154..00000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Debug - false - MSB3246 - - $(MSBuildProjectName) - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) - $(BaseOutputPath)obj\$(ProjectName)\ - $(BaseOutputPath)$(Configuration)\ - - WiX Toolset Team - WiX Toolset - Copyright (c) .NET Foundation and contributors. All rights reserved. - MS-RL - WiX Toolset - - - - - - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets deleted file mode 100644 index dac7452a..00000000 --- a/src/Directory.Build.targets +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - true - $(SolutionPath) - $(NCrunchOriginalSolutionPath) - - - - - - - $([System.IO.File]::ReadAllText($(TheSolutionPath))) - $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) - (?<="[PackageName]", ")(.*)(?=", ") - - - - - - %(Identity) - $(SolutionFileContent.Contains('\%(Identity).csproj')) - - - - - $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) - $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) - - - - - - - - - - - diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props deleted file mode 100644 index 1666e4fe..00000000 --- a/src/FindLocalWix.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets - - diff --git a/src/ca/caDecor.h b/src/ca/caDecor.h deleted file mode 100644 index da274650..00000000 --- a/src/ca/caDecor.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#if defined(_M_ARM64) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64" -#elif defined(_M_AMD64) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64" -#elif defined(_M_ARM) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM" -#else -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86" -#endif diff --git a/src/ca/cost.h b/src/ca/cost.h deleted file mode 100644 index 9677e7e8..00000000 --- a/src/ca/cost.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -const UINT COST_HTTP_URL_ACL = 2000; -const UINT COST_HTTP_SNI_SSL = 2000; diff --git a/src/ca/dllmain.cpp b/src/ca/dllmain.cpp deleted file mode 100644 index b4c8c037..00000000 --- a/src/ca/dllmain.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -/******************************************************************** -DllMain - standard entry point for all WiX CustomActions - -********************************************************************/ -extern "C" BOOL WINAPI DllMain( - IN HINSTANCE hInstance, - IN ULONG ulReason, - IN LPVOID) -{ - switch(ulReason) - { - case DLL_PROCESS_ATTACH: - WcaGlobalInitialize(hInstance); - break; - - case DLL_PROCESS_DETACH: - WcaGlobalFinalize(); - break; - } - - return TRUE; -} diff --git a/src/ca/httpca.vcxproj b/src/ca/httpca.vcxproj deleted file mode 100644 index fde00ff4..00000000 --- a/src/ca/httpca.vcxproj +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM64 - - - Release - ARM64 - - - - - {90743805-C043-47C7-B5FF-8F5EE5C8A2DE} - DynamicLibrary - v142 - Unicode - httpca - wixhttpca.def - WiX Toolset Http CustomAction - - - - - - - crypt32.lib;httpapi.lib;msi.lib;rpcrt4.lib;ws2_32.lib - - - - - Create - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - diff --git a/src/ca/httpca.vcxproj.filters b/src/ca/httpca.vcxproj.filters deleted file mode 100644 index 2ccd604d..00000000 --- a/src/ca/httpca.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Source Files - - - - \ No newline at end of file diff --git a/src/ca/packages.config b/src/ca/packages.config deleted file mode 100644 index 9d88f529..00000000 --- a/src/ca/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ca/precomp.h b/src/ca/precomp.h deleted file mode 100644 index c78d78c1..00000000 --- a/src/ca/precomp.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#include -#include -#include - -#include "wcautil.h" -#include "cryputil.h" -#include "dutil.h" -#include "memutil.h" -#include "strutil.h" -#include "aclutil.h" - -#include "cost.h" - -#include "caDecor.h" - -enum eHandleExisting -{ - heReplace = 0, - heIgnore = 1, - heFail = 2 -}; diff --git a/src/ca/snisslcert.cpp b/src/ca/snisslcert.cpp deleted file mode 100644 index 3a7336af..00000000 --- a/src/ca/snisslcert.cpp +++ /dev/null @@ -1,704 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -#if _WIN32_WINNT < 0x0602 - -typedef struct _HTTP_SERVICE_CONFIG_SSL_SNI_KEY -{ - SOCKADDR_STORAGE IpPort; - PWSTR Host; -} HTTP_SERVICE_CONFIG_SSL_SNI_KEY, * PHTTP_SERVICE_CONFIG_SSL_SNI_KEY; - -typedef struct _HTTP_SERVICE_CONFIG_SSL_SNI_SET -{ - HTTP_SERVICE_CONFIG_SSL_SNI_KEY KeyDesc; - HTTP_SERVICE_CONFIG_SSL_PARAM ParamDesc; -} HTTP_SERVICE_CONFIG_SSL_SNI_SET, * PHTTP_SERVICE_CONFIG_SSL_SNI_SET; - -typedef struct _HTTP_SERVICE_CONFIG_SSL_SNI_QUERY -{ - HTTP_SERVICE_CONFIG_QUERY_TYPE QueryDesc; - HTTP_SERVICE_CONFIG_SSL_SNI_KEY KeyDesc; - DWORD dwToken; -} HTTP_SERVICE_CONFIG_SSL_SNI_QUERY, * PHTTP_SERVICE_CONFIG_SSL_SNI_QUERY; - -#define HttpServiceConfigSslSniCertInfo static_cast(HttpServiceConfigCache + 1) - -#endif - -static UINT SchedHttpSniSslCerts( - __in WCA_TODO todoSched -); -static HRESULT WriteExistingSniSslCert( - __in WCA_TODO action, - __in_z LPCWSTR wzId, - __in_z LPCWSTR wzHost, - __in int iPort, - __in int iHandleExisting, - __in HTTP_SERVICE_CONFIG_SSL_SNI_SET* pSniSslSet, - __inout_z LPWSTR* psczCustomActionData -); -static HRESULT WriteSniSslCert( - __in WCA_TODO action, - __in_z LPCWSTR wzId, - __in_z LPCWSTR wzHost, - __in int iPort, - __in int iHandleExisting, - __in_z LPCWSTR wzCertificateThumbprint, - __in_z LPCWSTR wzAppId, - __in_z_opt LPCWSTR wzCertificateStore, - __inout_z LPWSTR* psczCustomActionData -); -static HRESULT EnsureAppId( - __inout_z LPWSTR* psczAppId, - __in_opt HTTP_SERVICE_CONFIG_SSL_SNI_SET* pExistingSniSslSet -); -static HRESULT StringFromGuid( - __in REFGUID rguid, - __inout_z LPWSTR* psczGuid -); -static HRESULT AddSniSslCert( - __in_z LPCWSTR wzId, - __in_z LPWSTR wzHost, - __in int iPort, - __in BYTE rgbCertificateThumbprint[], - __in DWORD cbCertificateThumbprint, - __in GUID* pAppId, - __in_z LPWSTR wzSslCertStore -); -static HRESULT GetSniSslCert( - __in_z LPWSTR wzHost, - __in int nPort, - __out HTTP_SERVICE_CONFIG_SSL_SNI_SET** ppSet -); -static HRESULT RemoveSniSslCert( - __in_z LPCWSTR wzId, - __in_z LPWSTR wzHost, - __in int iPort -); -static void SetSniSslCertSetKey( - __in HTTP_SERVICE_CONFIG_SSL_SNI_KEY* pKey, - __in_z LPWSTR wzHost, - __in int iPort -); - - -LPCWSTR vcsWixHttpSniSslCertQuery = -L"SELECT `Wix4HttpSniSslCert`.`Wix4HttpSniSslCert`, `Wix4HttpSniSslCert`.`Host`, `Wix4HttpSniSslCert`.`Port`, `Wix4HttpSniSslCert`.`Thumbprint`, `Wix4HttpSniSslCert`.`AppId`, `Wix4HttpSniSslCert`.`Store`, `Wix4HttpSniSslCert`.`HandleExisting`, `Wix4HttpSniSslCert`.`Component_` " -L"FROM `Wix4HttpSniSslCert`"; -enum eWixHttpSniSslCertQuery { hurqId = 1, hurqHost, hurqPort, hurqCertificateThumbprint, hurqAppId, hurqCertificateStore, hurqHandleExisting, hurqComponent }; - -/****************************************************************** - SchedWixHttpSniSslCertsInstall - immediate custom action entry - point to prepare adding URL reservations. - -********************************************************************/ -extern "C" UINT __stdcall SchedHttpSniSslCertsInstall( - __in MSIHANDLE hInstall -) -{ - HRESULT hr = S_OK; - - hr = WcaInitialize(hInstall, "SchedHttpSniSslCertsInstall"); - ExitOnFailure(hr, "Failed to initialize"); - - hr = SchedHttpSniSslCerts(WCA_TODO_INSTALL); - -LExit: - return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); -} - -/****************************************************************** - SchedWixHttpSniSslCertsUninstall - immediate custom action entry - point to prepare removing URL reservations. - -********************************************************************/ -extern "C" UINT __stdcall SchedHttpSniSslCertsUninstall( - __in MSIHANDLE hInstall -) -{ - HRESULT hr = S_OK; - - hr = WcaInitialize(hInstall, "SchedHttpSniSslCertsUninstall"); - ExitOnFailure(hr, "Failed to initialize"); - - hr = SchedHttpSniSslCerts(WCA_TODO_UNINSTALL); - -LExit: - return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); -} - -/****************************************************************** - ExecHttpSniSslCerts - deferred custom action entry point to - register and remove URL reservations. - -********************************************************************/ -extern "C" UINT __stdcall ExecHttpSniSslCerts( - __in MSIHANDLE hInstall -) -{ - HRESULT hr = S_OK; - BOOL fHttpInitialized = FALSE; - LPWSTR sczCustomActionData = NULL; - LPWSTR wz = NULL; - int iTodo = WCA_TODO_UNKNOWN; - LPWSTR sczId = NULL; - LPWSTR sczHost = NULL; - int iPort = 0; - eHandleExisting handleExisting = heIgnore; - LPWSTR sczCertificateThumbprint = NULL; - LPWSTR sczAppId = NULL; - LPWSTR sczCertificateStore = NULL; - - BOOL fRollback = ::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK); - BOOL fRemove = FALSE; - BOOL fAdd = FALSE; - BOOL fFailOnExisting = FALSE; - - GUID guidAppId = { }; - BYTE* pbCertificateThumbprint = NULL; - DWORD cbCertificateThumbprint = 0; - - // Initialize. - hr = WcaInitialize(hInstall, "ExecHttpSniSslCerts"); - ExitOnFailure(hr, "Failed to initialize"); - - hr = HRESULT_FROM_WIN32(::HttpInitialize(HTTPAPI_VERSION_1, HTTP_INITIALIZE_CONFIG, NULL)); - ExitOnFailure(hr, "Failed to initialize HTTP Server configuration"); - - fHttpInitialized = TRUE; - - hr = WcaGetProperty(L"CustomActionData", &sczCustomActionData); - ExitOnFailure(hr, "Failed to get CustomActionData"); - WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", sczCustomActionData); - - wz = sczCustomActionData; - while (wz && *wz) - { - // Extract the custom action data and if rolling back, swap INSTALL and UNINSTALL. - hr = WcaReadIntegerFromCaData(&wz, &iTodo); - ExitOnFailure(hr, "Failed to read todo from custom action data"); - - hr = WcaReadStringFromCaData(&wz, &sczId); - ExitOnFailure(hr, "Failed to read Id from custom action data"); - - hr = WcaReadStringFromCaData(&wz, &sczHost); - ExitOnFailure(hr, "Failed to read Host from custom action data"); - - hr = WcaReadIntegerFromCaData(&wz, &iPort); - ExitOnFailure(hr, "Failed to read Port from custom action data"); - - hr = WcaReadIntegerFromCaData(&wz, reinterpret_cast(&handleExisting)); - ExitOnFailure(hr, "Failed to read HandleExisting from custom action data"); - - hr = WcaReadStringFromCaData(&wz, &sczCertificateThumbprint); - ExitOnFailure(hr, "Failed to read CertificateThumbprint from custom action data"); - - hr = WcaReadStringFromCaData(&wz, &sczAppId); - ExitOnFailure(hr, "Failed to read AppId from custom action data"); - - hr = WcaReadStringFromCaData(&wz, &sczCertificateStore); - ExitOnFailure(hr, "Failed to read CertificateStore from custom action data"); - - switch (iTodo) - { - case WCA_TODO_INSTALL: - case WCA_TODO_REINSTALL: - fRemove = heReplace == handleExisting || fRollback; - fAdd = !fRollback || *sczCertificateThumbprint; - fFailOnExisting = heFail == handleExisting && !fRollback; - break; - - case WCA_TODO_UNINSTALL: - fRemove = !fRollback; - fAdd = fRollback && *sczCertificateThumbprint; - fFailOnExisting = FALSE; - break; - } - - if (fRemove) - { - hr = RemoveSniSslCert(sczId, sczHost, iPort); - if (S_OK == hr) - { - WcaLog(LOGMSG_STANDARD, "Removed SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); - } - else if (FAILED(hr)) - { - if (fRollback) - { - WcaLogError(hr, "Failed to remove SNI SSL certificate to rollback '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); - } - else - { - ExitOnFailure(hr, "Failed to remove SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); - } - } - } - - if (fAdd) - { - WcaLog(LOGMSG_STANDARD, "Adding SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); - - hr = StrAllocHexDecode(sczCertificateThumbprint, &pbCertificateThumbprint, &cbCertificateThumbprint); - ExitOnFailure(hr, "Failed to convert thumbprint to bytes for SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); - - hr = ::IIDFromString(sczAppId, &guidAppId); - ExitOnFailure(hr, "Failed to convert AppId '%ls' back to GUID for SNI SSL certificate '%ls' for hostname: %ls:%d", sczAppId, sczId, sczHost, iPort); - - hr = AddSniSslCert(sczId, sczHost, iPort, pbCertificateThumbprint, cbCertificateThumbprint, &guidAppId, sczCertificateStore && *sczCertificateStore ? sczCertificateStore : L"MY"); - if (S_FALSE == hr && fFailOnExisting) - { - hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS); - } - - if (S_OK == hr) - { - WcaLog(LOGMSG_STANDARD, "Added SNI SSL certificate '%ls' for hostname: %ls:%d with thumbprint: %ls", sczId, sczHost, iPort, sczCertificateThumbprint); - } - else if (FAILED(hr)) - { - if (fRollback) - { - WcaLogError(hr, "Failed to add SNI SSL certificate to rollback '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); - } - else - { - ExitOnFailure(hr, "Failed to add SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); - } - } - - ReleaseNullMem(pbCertificateThumbprint); - } - } - -LExit: - ReleaseMem(pbCertificateThumbprint); - ReleaseStr(sczCertificateStore); - ReleaseStr(sczAppId); - ReleaseStr(sczCertificateThumbprint); - ReleaseStr(sczHost); - ReleaseStr(sczId); - ReleaseStr(sczCustomActionData); - - if (fHttpInitialized) - { - ::HttpTerminate(HTTP_INITIALIZE_CONFIG, NULL); - } - - return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); -} - -static UINT SchedHttpSniSslCerts( - __in WCA_TODO todoSched -) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - BOOL fHttpInitialized = FALSE; - DWORD cCertificates = 0; - - PMSIHANDLE hView = NULL; - PMSIHANDLE hRec = NULL; - PMSIHANDLE hQueryReq = NULL; - PMSIHANDLE hAceView = NULL; - - LPWSTR sczCustomActionData = NULL; - LPWSTR sczRollbackCustomActionData = NULL; - - LPWSTR sczId = NULL; - LPWSTR sczComponent = NULL; - WCA_TODO todoComponent = WCA_TODO_UNKNOWN; - LPWSTR sczHost = NULL; - int iPort = 0; - LPWSTR sczCertificateThumbprint = NULL; - LPWSTR sczAppId = NULL; - LPWSTR sczCertificateStore = NULL; - int iHandleExisting = 0; - - HTTP_SERVICE_CONFIG_SSL_SNI_SET* pExistingSniSslSet = NULL; - - // Anything to do? - hr = WcaTableExists(L"Wix4HttpSniSslCert"); - ExitOnFailure(hr, "Failed to check if the Wix4HttpSniSslCert table exists"); - if (S_FALSE == hr) - { - WcaLog(LOGMSG_STANDARD, "Wix4HttpSniSslCert table doesn't exist, so there are no URL reservations to configure"); - ExitFunction(); - } - - // Query and loop through all the SNI SSL certificates. - hr = WcaOpenExecuteView(vcsWixHttpSniSslCertQuery, &hView); - ExitOnFailure(hr, "Failed to open view on the Wix4HttpSniSslCert table"); - - hr = HRESULT_FROM_WIN32(::HttpInitialize(HTTPAPI_VERSION_1, HTTP_INITIALIZE_CONFIG, NULL)); - ExitOnFailure(hr, "Failed to initialize HTTP Server configuration"); - - fHttpInitialized = TRUE; - - while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) - { - hr = WcaGetRecordString(hRec, hurqId, &sczId); - ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Wix4HttpSniSslCert"); - - hr = WcaGetRecordString(hRec, hurqComponent, &sczComponent); - ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Component_"); - - // Figure out what we're doing for this reservation, treating reinstall the same as install. - todoComponent = WcaGetComponentToDo(sczComponent); - if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) - { - WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d) for Wix4HttpSniSslCert '%ls'", sczComponent, todoComponent, todoSched, sczId); - continue; - } - - hr = WcaGetRecordFormattedString(hRec, hurqHost, &sczHost); - ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Host"); - - hr = WcaGetRecordFormattedInteger(hRec, hurqPort, &iPort); - ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Port"); - - hr = WcaGetRecordFormattedString(hRec, hurqCertificateThumbprint, &sczCertificateThumbprint); - ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.CertificateThumbprint"); - - if (!sczHost || !*sczHost) - { - hr = E_INVALIDARG; - ExitOnFailure(hr, "Require a Host value for Wix4HttpSniSslCert '%ls'", sczId); - } - - if (!iPort) - { - hr = E_INVALIDARG; - ExitOnFailure(hr, "Require a Port value for Wix4HttpSniSslCert '%ls'", sczId); - } - - if (!sczCertificateThumbprint || !*sczCertificateThumbprint) - { - hr = E_INVALIDARG; - ExitOnFailure(hr, "Require a CertificateThumbprint value for Wix4HttpSniSslCert '%ls'", sczId); - } - - hr = WcaGetRecordFormattedString(hRec, hurqAppId, &sczAppId); - ExitOnFailure(hr, "Failed to get AppId for Wix4HttpSniSslCert '%ls'", sczId); - - hr = WcaGetRecordFormattedString(hRec, hurqCertificateStore, &sczCertificateStore); - ExitOnFailure(hr, "Failed to get CertificateStore for Wix4HttpSniSslCert '%ls'", sczId); - - hr = WcaGetRecordInteger(hRec, hurqHandleExisting, &iHandleExisting); - ExitOnFailure(hr, "Failed to get HandleExisting for Wix4HttpSniSslCert '%ls'", sczId); - - hr = GetSniSslCert(sczHost, iPort, &pExistingSniSslSet); - ExitOnFailure(hr, "Failed to get the existing SNI SSL certificate for Wix4HttpSniSslCert '%ls'", sczId); - - hr = EnsureAppId(&sczAppId, pExistingSniSslSet); - ExitOnFailure(hr, "Failed to ensure AppId for Wix4HttpSniSslCert '%ls'", sczId); - - hr = WriteExistingSniSslCert(todoComponent, sczId, sczHost, iPort, iHandleExisting, pExistingSniSslSet, &sczRollbackCustomActionData); - ExitOnFailure(hr, "Failed to write rollback custom action data for Wix4HttpSniSslCert '%ls'", sczId); - - hr = WriteSniSslCert(todoComponent, sczId, sczHost, iPort, iHandleExisting, sczCertificateThumbprint, sczAppId, sczCertificateStore, &sczCustomActionData); - ExitOnFailure(hr, "Failed to write custom action data for Wix4HttpSniSslCert '%ls'", sczId); - ++cCertificates; - - ReleaseNullMem(pExistingSniSslSet); - } - - // Reaching the end of the list is not an error. - if (E_NOMOREITEMS == hr) - { - hr = S_OK; - } - ExitOnFailure(hr, "Failure occurred while processing Wix4HttpSniSslCert table"); - - // Schedule ExecHttpSniSslCerts if there's anything to do. - if (cCertificates) - { - WcaLog(LOGMSG_STANDARD, "Scheduling SNI SSL certificate (%ls)", sczCustomActionData); - WcaLog(LOGMSG_STANDARD, "Scheduling rollback SNI SSL certificate (%ls)", sczRollbackCustomActionData); - - if (WCA_TODO_INSTALL == todoSched) - { - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixRollbackHttpSniSslCertsInstall"), sczRollbackCustomActionData, cCertificates * COST_HTTP_SNI_SSL); - ExitOnFailure(hr, "Failed to schedule install SNI SSL certificate rollback"); - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixExecHttpSniSslCertsInstall"), sczCustomActionData, cCertificates * COST_HTTP_SNI_SSL); - ExitOnFailure(hr, "Failed to schedule install SNI SSL certificate execution"); - } - else - { - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixRollbackHttpSniSslCertsUninstall"), sczRollbackCustomActionData, cCertificates * COST_HTTP_SNI_SSL); - ExitOnFailure(hr, "Failed to schedule uninstall SNI SSL certificate rollback"); - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixExecHttpSniSslCertsUninstall"), sczCustomActionData, cCertificates * COST_HTTP_SNI_SSL); - ExitOnFailure(hr, "Failed to schedule uninstall SNI SSL certificate execution"); - } - } - else - { - WcaLog(LOGMSG_STANDARD, "No SNI SSL certificates scheduled"); - } - -LExit: - ReleaseMem(pExistingSniSslSet); - ReleaseStr(sczCertificateStore); - ReleaseStr(sczAppId); - ReleaseStr(sczCertificateThumbprint); - ReleaseStr(sczHost); - ReleaseStr(sczComponent); - ReleaseStr(sczId); - ReleaseStr(sczRollbackCustomActionData); - ReleaseStr(sczCustomActionData); - - if (fHttpInitialized) - { - ::HttpTerminate(HTTP_INITIALIZE_CONFIG, NULL); - } - - return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); -} - -static HRESULT WriteExistingSniSslCert( - __in WCA_TODO action, - __in_z LPCWSTR wzId, - __in_z LPCWSTR wzHost, - __in int iPort, - __in int iHandleExisting, - __in HTTP_SERVICE_CONFIG_SSL_SNI_SET* pSniSslSet, - __inout_z LPWSTR* psczCustomActionData -) -{ - HRESULT hr = S_OK; - LPWSTR sczCertificateThumbprint = NULL; - LPWSTR sczAppId = NULL; - LPCWSTR wzCertificateStore = NULL; - - if (pSniSslSet) - { - hr = StrAllocHexEncode(reinterpret_cast(pSniSslSet->ParamDesc.pSslHash), pSniSslSet->ParamDesc.SslHashLength, &sczCertificateThumbprint); - ExitOnFailure(hr, "Failed to convert existing certificate thumbprint to hex for Wix4HttpSniSslCert '%ls'", wzId); - - hr = StringFromGuid(pSniSslSet->ParamDesc.AppId, &sczAppId); - ExitOnFailure(hr, "Failed to copy existing AppId for Wix4HttpSniSslCert '%ls'", wzId); - - wzCertificateStore = pSniSslSet->ParamDesc.pSslCertStoreName; - } - - hr = WriteSniSslCert(action, wzId, wzHost, iPort, iHandleExisting, sczCertificateThumbprint ? sczCertificateThumbprint : L"", sczAppId ? sczAppId : L"", wzCertificateStore ? wzCertificateStore : L"", psczCustomActionData); - ExitOnFailure(hr, "Failed to write custom action data for Wix4HttpSniSslCert '%ls'", wzId); - -LExit: - ReleaseStr(sczAppId); - ReleaseStr(sczCertificateThumbprint); - - return hr; -} - -static HRESULT WriteSniSslCert( - __in WCA_TODO action, - __in_z LPCWSTR wzId, - __in_z LPCWSTR wzHost, - __in int iPort, - __in int iHandleExisting, - __in_z LPCWSTR wzCertificateThumbprint, - __in_z LPCWSTR wzAppId, - __in_z_opt LPCWSTR wzCertificateStore, - __inout_z LPWSTR* psczCustomActionData -) -{ - HRESULT hr = S_OK; - - hr = WcaWriteIntegerToCaData(action, psczCustomActionData); - ExitOnFailure(hr, "Failed to write action to custom action data"); - - hr = WcaWriteStringToCaData(wzId, psczCustomActionData); - ExitOnFailure(hr, "Failed to write id to custom action data"); - - hr = WcaWriteStringToCaData(wzHost, psczCustomActionData); - ExitOnFailure(hr, "Failed to write Host to custom action data"); - - hr = WcaWriteIntegerToCaData(iPort, psczCustomActionData); - ExitOnFailure(hr, "Failed to write Port to custom action data"); - - hr = WcaWriteIntegerToCaData(iHandleExisting, psczCustomActionData); - ExitOnFailure(hr, "Failed to write HandleExisting to custom action data"); - - hr = WcaWriteStringToCaData(wzCertificateThumbprint, psczCustomActionData); - ExitOnFailure(hr, "Failed to write CertificateThumbprint to custom action data"); - - hr = WcaWriteStringToCaData(wzAppId, psczCustomActionData); - ExitOnFailure(hr, "Failed to write AppId to custom action data"); - - hr = WcaWriteStringToCaData(wzCertificateStore ? wzCertificateStore : L"", psczCustomActionData); - ExitOnFailure(hr, "Failed to write CertificateStore to custom action data"); - -LExit: - return hr; -} - -static HRESULT EnsureAppId( - __inout_z LPWSTR* psczAppId, - __in_opt HTTP_SERVICE_CONFIG_SSL_SNI_SET* pExistingSniSslSet -) -{ - HRESULT hr = S_OK; - RPC_STATUS rs = RPC_S_OK; - GUID guid = { }; - - if (!psczAppId || !*psczAppId || !**psczAppId) - { - if (pExistingSniSslSet) - { - hr = StringFromGuid(pExistingSniSslSet->ParamDesc.AppId, psczAppId); - ExitOnFailure(hr, "Failed to ensure AppId guid"); - } - else - { - rs = ::UuidCreate(&guid); - hr = HRESULT_FROM_RPC(rs); - ExitOnRootFailure(hr, "Failed to create guid for AppId"); - - hr = StringFromGuid(guid, psczAppId); - ExitOnFailure(hr, "Failed to ensure AppId guid"); - } - } - -LExit: - return hr; -} - -static HRESULT StringFromGuid( - __in REFGUID rguid, - __inout_z LPWSTR* psczGuid -) -{ - HRESULT hr = S_OK; - WCHAR wzGuid[39]; - - if (!::StringFromGUID2(rguid, wzGuid, countof(wzGuid))) - { - hr = E_OUTOFMEMORY; - ExitOnRootFailure(hr, "Failed to convert guid into string"); - } - - hr = StrAllocString(psczGuid, wzGuid, 0); - ExitOnFailure(hr, "Failed to copy guid"); - -LExit: - return hr; -} - -static HRESULT AddSniSslCert( - __in_z LPCWSTR /*wzId*/, - __in_z LPWSTR wzHost, - __in int iPort, - __in BYTE rgbCertificateThumbprint[], - __in DWORD cbCertificateThumbprint, - __in GUID* pAppId, - __in_z LPWSTR wzSslCertStore -) -{ - HRESULT hr = S_OK; - DWORD er = ERROR_SUCCESS; - HTTP_SERVICE_CONFIG_SSL_SNI_SET set = { }; - - SetSniSslCertSetKey(&set.KeyDesc, wzHost, iPort); - set.ParamDesc.SslHashLength = cbCertificateThumbprint; - set.ParamDesc.pSslHash = rgbCertificateThumbprint; - set.ParamDesc.AppId = *pAppId; - set.ParamDesc.pSslCertStoreName = wzSslCertStore; - - er = ::HttpSetServiceConfiguration(NULL, HttpServiceConfigSslSniCertInfo, &set, sizeof(set), NULL); - if (ERROR_ALREADY_EXISTS == er) - { - hr = S_FALSE; - } - else - { - hr = HRESULT_FROM_WIN32(er); - } - - return hr; -} - -static HRESULT GetSniSslCert( - __in_z LPWSTR wzHost, - __in int nPort, - __out HTTP_SERVICE_CONFIG_SSL_SNI_SET** ppSet -) -{ - HRESULT hr = S_OK; - DWORD er = ERROR_SUCCESS; - HTTP_SERVICE_CONFIG_SSL_SNI_QUERY query = { }; - HTTP_SERVICE_CONFIG_SSL_SNI_SET* pSet = NULL; - ULONG cbSet = 0; - - *ppSet = NULL; - - query.QueryDesc = HttpServiceConfigQueryExact; - SetSniSslCertSetKey(&query.KeyDesc, wzHost, nPort); - - er = ::HttpQueryServiceConfiguration(NULL, HttpServiceConfigSslSniCertInfo, &query, sizeof(query), pSet, cbSet, &cbSet, NULL); - if (ERROR_INSUFFICIENT_BUFFER == er) - { - pSet = reinterpret_cast(MemAlloc(cbSet, TRUE)); - ExitOnNull(pSet, hr, E_OUTOFMEMORY, "Failed to allocate query SN SSL certificate buffer"); - - er = ::HttpQueryServiceConfiguration(NULL, HttpServiceConfigSslSniCertInfo, &query, sizeof(query), pSet, cbSet, &cbSet, NULL); - } - - if (ERROR_SUCCESS == er) - { - *ppSet = pSet; - pSet = NULL; - } - else if (ERROR_FILE_NOT_FOUND == er) - { - hr = S_FALSE; - } - else - { - hr = HRESULT_FROM_WIN32(er); - } - -LExit: - ReleaseMem(pSet); - - return hr; -} - -static HRESULT RemoveSniSslCert( - __in_z LPCWSTR /*wzId*/, - __in_z LPWSTR wzHost, - __in int iPort -) -{ - HRESULT hr = S_OK; - DWORD er = ERROR_SUCCESS; - HTTP_SERVICE_CONFIG_SSL_SNI_SET set = { }; - - SetSniSslCertSetKey(&set.KeyDesc, wzHost, iPort); - - er = ::HttpDeleteServiceConfiguration(NULL, HttpServiceConfigSslSniCertInfo, &set, sizeof(set), NULL); - if (ERROR_FILE_NOT_FOUND == er) - { - hr = S_FALSE; - } - else - { - hr = HRESULT_FROM_WIN32(er); - } - - return hr; -} - -static void SetSniSslCertSetKey( - __in HTTP_SERVICE_CONFIG_SSL_SNI_KEY* pKey, - __in_z LPWSTR wzHost, - __in int iPort -) -{ - pKey->Host = wzHost; - SOCKADDR_IN* pss = reinterpret_cast(&pKey->IpPort); - pss->sin_family = AF_INET; - pss->sin_port = htons(static_cast(iPort)); -} diff --git a/src/ca/wixhttpca.cpp b/src/ca/wixhttpca.cpp deleted file mode 100644 index 8c846ffc..00000000 --- a/src/ca/wixhttpca.cpp +++ /dev/null @@ -1,530 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -static HRESULT AppendUrlAce( - __in LPWSTR wzSecurityPrincipal, - __in int iRights, - __in LPWSTR* psczSDDL - ); -static HRESULT WriteHttpUrlReservation( - __in WCA_TODO action, - __in LPWSTR wzUrl, - __in LPWSTR wzSDDL, - __in int iHandleExisting, - __in LPWSTR* psczCustomActionData - ); -static HRESULT AddUrlReservation( - __in LPWSTR wzUrl, - __in LPWSTR wzSddl - ); -static HRESULT GetUrlReservation( - __in LPWSTR wzUrl, - __deref_out_z LPWSTR* psczSddl - ); -static HRESULT RemoveUrlReservation( - __in LPWSTR wzUrl - ); - -HTTPAPI_VERSION vcHttpVersion = HTTPAPI_VERSION_1; -ULONG vcHttpFlags = HTTP_INITIALIZE_CONFIG; - -LPCWSTR vcsHttpUrlReservationQuery = - L"SELECT `Wix4HttpUrlReservation`.`Wix4HttpUrlReservation`, `Wix4HttpUrlReservation`.`HandleExisting`, `Wix4HttpUrlReservation`.`Sddl`, `Wix4HttpUrlReservation`.`Url`, `Wix4HttpUrlReservation`.`Component_` " - L"FROM `Wix4HttpUrlReservation`"; -enum eHttpUrlReservationQuery { hurqId = 1, hurqHandleExisting, hurqSDDL, hurqUrl, hurqComponent }; - -LPCWSTR vcsHttpUrlAceQuery = - L"SELECT `Wix4HttpUrlAce`.`SecurityPrincipal`, `Wix4HttpUrlAce`.`Rights` " - L"FROM `Wix4HttpUrlAce` " - L"WHERE `Wix4HttpUrlAce`.`Wix4HttpUrlReservation_`=?"; -enum eHttpUrlAceQuery { huaqSecurityPrincipal = 1, huaqRights }; - -/****************************************************************** - SchedHttpUrlReservations - immediate custom action worker to - prepare configuring URL reservations. - -********************************************************************/ -static UINT SchedHttpUrlReservations( - __in MSIHANDLE hInstall, - __in WCA_TODO todoSched - ) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - BOOL fAceTableExists = FALSE; - BOOL fHttpInitialized = FALSE; - DWORD cUrlReservations = 0; - - PMSIHANDLE hView = NULL; - PMSIHANDLE hRec = NULL; - PMSIHANDLE hQueryReq = NULL; - PMSIHANDLE hAceView = NULL; - - LPWSTR sczCustomActionData = NULL; - LPWSTR sczRollbackCustomActionData = NULL; - - LPWSTR sczId = NULL; - LPWSTR sczComponent = NULL; - WCA_TODO todoComponent = WCA_TODO_UNKNOWN; - LPWSTR sczUrl = NULL; - LPWSTR sczSecurityPrincipal = NULL; - int iRights = 0; - int iHandleExisting = 0; - - LPWSTR sczExistingSDDL = NULL; - LPWSTR sczSDDL = NULL; - - // Initialize. - hr = WcaInitialize(hInstall, "SchedHttpUrlReservations"); - ExitOnFailure(hr, "Failed to initialize."); - - // Anything to do? - hr = WcaTableExists(L"Wix4HttpUrlReservation"); - ExitOnFailure(hr, "Failed to check if the Wix4HttpUrlReservation table exists."); - if (S_FALSE == hr) - { - WcaLog(LOGMSG_STANDARD, "Wix4HttpUrlReservation table doesn't exist, so there are no URL reservations to configure."); - ExitFunction(); - } - - hr = WcaTableExists(L"Wix4HttpUrlAce"); - ExitOnFailure(hr, "Failed to check if the Wix4HttpUrlAce table exists."); - fAceTableExists = S_OK == hr; - - // Query and loop through all the URL reservations. - hr = WcaOpenExecuteView(vcsHttpUrlReservationQuery, &hView); - ExitOnFailure(hr, "Failed to open view on the Wix4HttpUrlReservation table."); - - hr = HRESULT_FROM_WIN32(::HttpInitialize(vcHttpVersion, vcHttpFlags, NULL)); - ExitOnFailure(hr, "Failed to initialize HTTP Server configuration."); - - fHttpInitialized = TRUE; - - while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) - { - hr = WcaGetRecordString(hRec, hurqId, &sczId); - ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.Wix4HttpUrlReservation"); - - hr = WcaGetRecordString(hRec, hurqComponent, &sczComponent); - ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.Component_"); - - // Figure out what we're doing for this reservation, treating reinstall the same as install. - todoComponent = WcaGetComponentToDo(sczComponent); - if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) - { - WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d) for UrlReservation '%ls'.", sczComponent, todoComponent, todoSched, sczId); - continue; - } - - hr = WcaGetRecordFormattedString(hRec, hurqUrl, &sczUrl); - ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.Url"); - - hr = WcaGetRecordInteger(hRec, hurqHandleExisting, &iHandleExisting); - ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.HandleExisting"); - - if (::MsiRecordIsNull(hRec, hurqSDDL)) - { - hr = StrAllocString(&sczSDDL, L"D:", 2); - ExitOnFailure(hr, "Failed to allocate SDDL string."); - - // Skip creating the SDDL on uninstall, since it's never used and the lookup(s) could fail. - if (fAceTableExists && WCA_TODO_UNINSTALL != todoComponent) - { - hQueryReq = ::MsiCreateRecord(1); - hr = WcaSetRecordString(hQueryReq, 1, sczId); - ExitOnFailure(hr, "Failed to create record for querying Wix4HttpUrlAce table for reservation %ls", sczId); - - hr = WcaOpenView(vcsHttpUrlAceQuery, &hAceView); - ExitOnFailure(hr, "Failed to open view on Wix4HttpUrlAce table for reservation %ls", sczId); - hr = WcaExecuteView(hAceView, hQueryReq); - ExitOnFailure(hr, "Failed to execute view on Wix4HttpUrlAce table for reservation %ls", sczId); - - while (S_OK == (hr = WcaFetchRecord(hAceView, &hRec))) - { - hr = WcaGetRecordFormattedString(hRec, huaqSecurityPrincipal, &sczSecurityPrincipal); - ExitOnFailure(hr, "Failed to get Wix4HttpUrlAce.SecurityPrincipal"); - - hr = WcaGetRecordInteger(hRec, huaqRights, &iRights); - ExitOnFailure(hr, "Failed to get Wix4HttpUrlAce.Rights"); - - hr = AppendUrlAce(sczSecurityPrincipal, iRights, &sczSDDL); - ExitOnFailure(hr, "Failed to append URL ACE."); - } - - if (E_NOMOREITEMS == hr) - { - hr = S_OK; - } - ExitOnFailure(hr, "Failed to enumerate selected rows from Wix4HttpUrlAce table."); - } - } - else - { - hr = WcaGetRecordFormattedString(hRec, hurqSDDL, &sczSDDL); - ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.SDDL"); - } - - hr = GetUrlReservation(sczUrl, &sczExistingSDDL); - ExitOnFailure(hr, "Failed to get the existing SDDL for %ls", sczUrl); - - hr = WriteHttpUrlReservation(todoComponent, sczUrl, sczExistingSDDL ? sczExistingSDDL : L"", iHandleExisting, &sczRollbackCustomActionData); - ExitOnFailure(hr, "Failed to write URL Reservation to rollback custom action data."); - - hr = WriteHttpUrlReservation(todoComponent, sczUrl, sczSDDL, iHandleExisting, &sczCustomActionData); - ExitOnFailure(hr, "Failed to write URL reservation to custom action data."); - ++cUrlReservations; - } - - // Reaching the end of the list is not an error. - if (E_NOMOREITEMS == hr) - { - hr = S_OK; - } - ExitOnFailure(hr, "Failure occurred while processing Wix4HttpUrlReservation table."); - - // Schedule ExecHttpUrlReservations if there's anything to do. - if (cUrlReservations) - { - WcaLog(LOGMSG_STANDARD, "Scheduling URL reservations (%ls)", sczCustomActionData); - WcaLog(LOGMSG_STANDARD, "Scheduling rollback URL reservations (%ls)", sczRollbackCustomActionData); - - if (WCA_TODO_INSTALL == todoSched) - { - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixRollbackHttpUrlReservationsInstall"), sczRollbackCustomActionData, cUrlReservations * COST_HTTP_URL_ACL); - ExitOnFailure(hr, "Failed to schedule install URL reservations rollback."); - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixExecHttpUrlReservationsInstall"), sczCustomActionData, cUrlReservations * COST_HTTP_URL_ACL); - ExitOnFailure(hr, "Failed to schedule install URL reservations execution."); - } - else - { - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixRollbackHttpUrlReservationsUninstall"), sczRollbackCustomActionData, cUrlReservations * COST_HTTP_URL_ACL); - ExitOnFailure(hr, "Failed to schedule uninstall URL reservations rollback."); - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixExecHttpUrlReservationsUninstall"), sczCustomActionData, cUrlReservations * COST_HTTP_URL_ACL); - ExitOnFailure(hr, "Failed to schedule uninstall URL reservations execution."); - } - } - else - { - WcaLog(LOGMSG_STANDARD, "No URL reservations scheduled."); - } - -LExit: - ReleaseStr(sczSDDL); - ReleaseStr(sczExistingSDDL); - ReleaseStr(sczSecurityPrincipal); - ReleaseStr(sczUrl) - ReleaseStr(sczComponent); - ReleaseStr(sczId); - ReleaseStr(sczRollbackCustomActionData); - ReleaseStr(sczCustomActionData); - - if (fHttpInitialized) - { - ::HttpTerminate(vcHttpFlags, NULL); - } - - return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); -} - -static HRESULT AppendUrlAce( - __in LPWSTR wzSecurityPrincipal, - __in int iRights, - __in LPWSTR* psczSDDL - ) -{ - HRESULT hr = S_OK; - LPCWSTR wzSid = NULL; - LPWSTR sczSid = NULL; - - Assert(wzSecurityPrincipal && *wzSecurityPrincipal); - Assert(psczSDDL && *psczSDDL); - - // As documented in the xsd, if the first char is '*', then the rest of the string is a SID string, e.g. *S-1-5-18. - if (L'*' == wzSecurityPrincipal[0]) - { - wzSid = &wzSecurityPrincipal[1]; - } - else - { - hr = AclGetAccountSidStringEx(NULL, wzSecurityPrincipal, &sczSid); - ExitOnFailure(hr, "Failed to lookup the SID for account %ls", wzSecurityPrincipal); - - wzSid = sczSid; - } - - hr = StrAllocFormatted(psczSDDL, L"%ls(A;;%#x;;;%ls)", *psczSDDL, iRights, wzSid); - -LExit: - ReleaseStr(sczSid); - - return hr; -} - -static HRESULT WriteHttpUrlReservation( - __in WCA_TODO action, - __in LPWSTR wzUrl, - __in LPWSTR wzSDDL, - __in int iHandleExisting, - __in LPWSTR* psczCustomActionData - ) -{ - HRESULT hr = S_OK; - - hr = WcaWriteIntegerToCaData(action, psczCustomActionData); - ExitOnFailure(hr, "Failed to write action to custom action data."); - - hr = WcaWriteStringToCaData(wzUrl, psczCustomActionData); - ExitOnFailure(hr, "Failed to write URL to custom action data."); - - hr = WcaWriteStringToCaData(wzSDDL, psczCustomActionData); - ExitOnFailure(hr, "Failed to write SDDL to custom action data."); - - hr = WcaWriteIntegerToCaData(iHandleExisting, psczCustomActionData); - ExitOnFailure(hr, "Failed to write HandleExisting to custom action data.") - -LExit: - return hr; -} - -/****************************************************************** - SchedHttpUrlReservationsInstall - immediate custom action entry - point to prepare adding URL reservations. - -********************************************************************/ -extern "C" UINT __stdcall SchedHttpUrlReservationsInstall( - __in MSIHANDLE hInstall - ) -{ - return SchedHttpUrlReservations(hInstall, WCA_TODO_INSTALL); -} - -/****************************************************************** - SchedHttpUrlReservationsUninstall - immediate custom action entry - point to prepare removing URL reservations. - -********************************************************************/ -extern "C" UINT __stdcall SchedHttpUrlReservationsUninstall( - __in MSIHANDLE hInstall - ) -{ - return SchedHttpUrlReservations(hInstall, WCA_TODO_UNINSTALL); -} - -/****************************************************************** - ExecHttpUrlReservations - deferred custom action entry point to - register and remove URL reservations. - -********************************************************************/ -extern "C" UINT __stdcall ExecHttpUrlReservations( - __in MSIHANDLE hInstall - ) -{ - HRESULT hr = S_OK; - BOOL fHttpInitialized = FALSE; - LPWSTR sczCustomActionData = NULL; - LPWSTR wz = NULL; - int iTodo = WCA_TODO_UNKNOWN; - LPWSTR sczUrl = NULL; - LPWSTR sczSDDL = NULL; - eHandleExisting handleExisting = heIgnore; - BOOL fRollback = ::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK); - BOOL fRemove = FALSE; - BOOL fAdd = FALSE; - BOOL fFailOnExisting = FALSE; - - // Initialize. - hr = WcaInitialize(hInstall, "ExecHttpUrlReservations"); - ExitOnFailure(hr, "Failed to initialize."); - - hr = HRESULT_FROM_WIN32(::HttpInitialize(vcHttpVersion, vcHttpFlags, NULL)); - ExitOnFailure(hr, "Failed to initialize HTTP Server configuration."); - - fHttpInitialized = TRUE; - - hr = WcaGetProperty(L"CustomActionData", &sczCustomActionData); - ExitOnFailure(hr, "Failed to get CustomActionData."); - WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", sczCustomActionData); - - if (!sczCustomActionData || !*sczCustomActionData) - { - WcaLog(LOGMSG_STANDARD, "No URL reservations to be executed."); - } - - wz = sczCustomActionData; - while (wz && *wz) - { - // Extract the custom action data and if rolling back, swap INSTALL and UNINSTALL. - hr = WcaReadIntegerFromCaData(&wz, &iTodo); - ExitOnFailure(hr, "Failed to read todo from custom action data."); - - hr = WcaReadStringFromCaData(&wz, &sczUrl); - ExitOnFailure(hr, "Failed to read Url from custom action data."); - - hr = WcaReadStringFromCaData(&wz, &sczSDDL); - ExitOnFailure(hr, "Failed to read SDDL from custom action data."); - - hr = WcaReadIntegerFromCaData(&wz, reinterpret_cast(&handleExisting)); - ExitOnFailure(hr, "Failed to read HandleExisting from custom action data."); - - switch (iTodo) - { - case WCA_TODO_INSTALL: - case WCA_TODO_REINSTALL: - fRemove = heReplace == handleExisting || fRollback; - fAdd = !fRollback || *sczSDDL; - fFailOnExisting = heFail == handleExisting && !fRollback; - break; - - case WCA_TODO_UNINSTALL: - fRemove = !fRollback; - fAdd = fRollback && *sczSDDL; - fFailOnExisting = FALSE; - break; - } - - if (fRemove) - { - WcaLog(LOGMSG_STANDARD, "Removing reservation for URL '%ls'", sczUrl); - hr = RemoveUrlReservation(sczUrl); - if (FAILED(hr)) - { - if (fRollback) - { - WcaLogError(hr, "Failed to remove reservation for rollback for URL '%ls'", sczUrl); - } - else - { - ExitOnFailure(hr, "Failed to remove reservation for URL '%ls'", sczUrl); - } - } - } - - if (fAdd) - { - WcaLog(LOGMSG_STANDARD, "Adding reservation for URL '%ls' with SDDL '%ls'", sczUrl, sczSDDL); - hr = AddUrlReservation(sczUrl, sczSDDL); - if (S_FALSE == hr && fFailOnExisting) - { - hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS); - } - if (FAILED(hr)) - { - if (fRollback) - { - WcaLogError(hr, "Failed to add reservation for rollback for URL '%ls' with SDDL '%ls'", sczUrl, sczSDDL); - } - else - { - ExitOnFailure(hr, "Failed to add reservation for URL '%ls' with SDDL '%ls'", sczUrl, sczSDDL); - } - } - } - } - -LExit: - ReleaseStr(sczSDDL); - ReleaseStr(sczUrl); - ReleaseStr(sczCustomActionData); - - if (fHttpInitialized) - { - ::HttpTerminate(vcHttpFlags, NULL); - } - - return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); -} - -static HRESULT AddUrlReservation( - __in LPWSTR wzUrl, - __in LPWSTR wzSddl - ) -{ - HRESULT hr = S_OK; - DWORD er = ERROR_SUCCESS; - HTTP_SERVICE_CONFIG_URLACL_SET set = { }; - - set.KeyDesc.pUrlPrefix = wzUrl; - set.ParamDesc.pStringSecurityDescriptor = wzSddl; - - er = ::HttpSetServiceConfiguration(NULL, HttpServiceConfigUrlAclInfo, &set, sizeof(set), NULL); - if (ERROR_ALREADY_EXISTS == er) - { - hr = S_FALSE; - } - else - { - hr = HRESULT_FROM_WIN32(er); - } - ExitOnFailure(hr, "Failed to add URL reservation: %ls, ACL: %ls", wzUrl, wzSddl); - -LExit: - return hr; -} - -static HRESULT GetUrlReservation( - __in LPWSTR wzUrl, - __deref_out_z LPWSTR* psczSddl - ) -{ - HRESULT hr = S_OK; - DWORD er = ERROR_SUCCESS; - HTTP_SERVICE_CONFIG_URLACL_QUERY query = { }; - HTTP_SERVICE_CONFIG_URLACL_SET* pSet = NULL; - ULONG cbSet = 0; - - query.QueryDesc = HttpServiceConfigQueryExact; - query.KeyDesc.pUrlPrefix = wzUrl; - - er = ::HttpQueryServiceConfiguration(NULL, HttpServiceConfigUrlAclInfo, &query, sizeof(query), pSet, cbSet, &cbSet, NULL); - if (ERROR_INSUFFICIENT_BUFFER == er) - { - pSet = reinterpret_cast(MemAlloc(cbSet, TRUE)); - ExitOnNull(pSet, hr, E_OUTOFMEMORY, "Failed to allocate query URLACL buffer."); - - er = ::HttpQueryServiceConfiguration(NULL, HttpServiceConfigUrlAclInfo, &query, sizeof(query), pSet, cbSet, &cbSet, NULL); - } - - if (ERROR_SUCCESS == er) - { - hr = StrAllocString(psczSddl, pSet->ParamDesc.pStringSecurityDescriptor, 0); - } - else if (ERROR_FILE_NOT_FOUND == er) - { - hr = S_FALSE; - } - else - { - hr = HRESULT_FROM_WIN32(er); - } - -LExit: - ReleaseMem(pSet); - - return hr; -} - -static HRESULT RemoveUrlReservation( - __in LPWSTR wzUrl - ) -{ - HRESULT hr = S_OK; - DWORD er = ERROR_SUCCESS; - HTTP_SERVICE_CONFIG_URLACL_SET set = { }; - - set.KeyDesc.pUrlPrefix = wzUrl; - - er = ::HttpDeleteServiceConfiguration(NULL, HttpServiceConfigUrlAclInfo, &set, sizeof(set), NULL); - if (ERROR_FILE_NOT_FOUND == er) - { - hr = S_FALSE; - } - else - { - hr = HRESULT_FROM_WIN32(er); - } - ExitOnFailure(hr, "Failed to remove URL reservation: %ls", wzUrl); - -LExit: - return hr; -} diff --git a/src/ca/wixhttpca.def b/src/ca/wixhttpca.def deleted file mode 100644 index 281c5631..00000000 --- a/src/ca/wixhttpca.def +++ /dev/null @@ -1,12 +0,0 @@ -; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -LIBRARY "httpca" - -EXPORTS - SchedHttpUrlReservationsInstall - SchedHttpUrlReservationsUninstall - ExecHttpUrlReservations - SchedHttpSniSslCertsInstall - SchedHttpSniSslCertsUninstall - ExecHttpSniSslCerts diff --git a/src/ext/Http/CSharp.Build.props b/src/ext/Http/CSharp.Build.props new file mode 100644 index 00000000..b12f4c6e --- /dev/null +++ b/src/ext/Http/CSharp.Build.props @@ -0,0 +1,11 @@ + + + + + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + + diff --git a/src/ext/Http/Cpp.Build.props b/src/ext/Http/Cpp.Build.props new file mode 100644 index 00000000..9b7a1bb5 --- /dev/null +++ b/src/ext/Http/Cpp.Build.props @@ -0,0 +1,86 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + diff --git a/src/ext/Http/Directory.Build.props b/src/ext/Http/Directory.Build.props new file mode 100644 index 00000000..f83cc154 --- /dev/null +++ b/src/ext/Http/Directory.Build.props @@ -0,0 +1,29 @@ + + + + + + Debug + false + MSB3246 + + $(MSBuildProjectName) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL + WiX Toolset + + + + + + + diff --git a/src/ext/Http/Directory.Build.targets b/src/ext/Http/Directory.Build.targets new file mode 100644 index 00000000..dac7452a --- /dev/null +++ b/src/ext/Http/Directory.Build.targets @@ -0,0 +1,48 @@ + + + + + + + true + $(SolutionPath) + $(NCrunchOriginalSolutionPath) + + + + + + + $([System.IO.File]::ReadAllText($(TheSolutionPath))) + $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) + (?<="[PackageName]", ")(.*)(?=", ") + + + + + + %(Identity) + $(SolutionFileContent.Contains('\%(Identity).csproj')) + + + + + $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) + $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) + + + + + + + + + + + diff --git a/src/ext/Http/FindLocalWix.props b/src/ext/Http/FindLocalWix.props new file mode 100644 index 00000000..1666e4fe --- /dev/null +++ b/src/ext/Http/FindLocalWix.props @@ -0,0 +1,8 @@ + + + + + + $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets + + diff --git a/src/ext/Http/Http.wixext.sln b/src/ext/Http/Http.wixext.sln new file mode 100644 index 00000000..fe5c52e9 --- /dev/null +++ b/src/ext/Http/Http.wixext.sln @@ -0,0 +1,61 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30204.135 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "httpca", "src\ca\httpca.vcxproj", "{90743805-C043-47C7-B5FF-8F5EE5C8A2DE}" +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "http", "src\wixlib\http.wixproj", "{055C1517-4CED-4199-BCDE-A383E5C4EF78}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Http.wixext", "src\wixext\WixToolset.Http.wixext.csproj", "{AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Http", "src\test\WixToolsetTest.Http\WixToolsetTest.Http.csproj", "{6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Debug|Any CPU.Build.0 = Debug|Win32 + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Debug|x86.ActiveCfg = Debug|Win32 + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Debug|x86.Build.0 = Debug|Win32 + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Release|Any CPU.ActiveCfg = Release|Win32 + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Release|Any CPU.Build.0 = Release|Win32 + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Release|x86.ActiveCfg = Release|Win32 + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE}.Release|x86.Build.0 = Release|Win32 + {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Debug|Any CPU.ActiveCfg = Debug|x86 + {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Debug|Any CPU.Build.0 = Debug|x86 + {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Debug|x86.ActiveCfg = Debug|x86 + {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Debug|x86.Build.0 = Debug|x86 + {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Release|Any CPU.ActiveCfg = Release|x86 + {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Release|Any CPU.Build.0 = Release|x86 + {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Release|x86.ActiveCfg = Release|x86 + {055C1517-4CED-4199-BCDE-A383E5C4EF78}.Release|x86.Build.0 = Release|x86 + {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Debug|x86.ActiveCfg = Debug|Any CPU + {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Debug|x86.Build.0 = Debug|Any CPU + {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Release|Any CPU.Build.0 = Release|Any CPU + {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Release|x86.ActiveCfg = Release|Any CPU + {AAFC3C7F-D818-4B1D-AF3F-A331EA917F3F}.Release|x86.Build.0 = Release|Any CPU + {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Debug|x86.ActiveCfg = Debug|Any CPU + {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Debug|x86.Build.0 = Debug|Any CPU + {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Release|Any CPU.Build.0 = Release|Any CPU + {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Release|x86.ActiveCfg = Release|Any CPU + {6379EBAA-B5FE-4468-89A3-EF0B5D30B87E}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {570B1B57-B310-4493-A3A3-B40D7374EFC3} + EndGlobalSection +EndGlobal diff --git a/src/ext/Http/README.md b/src/ext/Http/README.md new file mode 100644 index 00000000..2d9f1895 --- /dev/null +++ b/src/ext/Http/README.md @@ -0,0 +1,2 @@ +# Http.wixext +WixToolset.Http.wixext - Http WiX Toolset Extension diff --git a/src/ext/Http/appveyor.cmd b/src/ext/Http/appveyor.cmd new file mode 100644 index 00000000..16a34ff9 --- /dev/null +++ b/src/ext/Http/appveyor.cmd @@ -0,0 +1,14 @@ +@setlocal +@pushd %~dp0 + +nuget restore || exit /b + +msbuild -p:Configuration=Release -t:Restore || exit /b + +msbuild -p:Configuration=Release src\test\WixToolsetTest.Http\WixToolsetTest.Http.csproj || exit /b +dotnet test -c Release --no-build src\test\WixToolsetTest.Http || exit /b + +msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.Http.wixext.csproj || exit /b + +@popd +@endlocal \ No newline at end of file diff --git a/src/ext/Http/appveyor.yml b/src/ext/Http/appveyor.yml new file mode 100644 index 00000000..7c686b04 --- /dev/null +++ b/src/ext/Http/appveyor.yml @@ -0,0 +1,40 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +branches: + only: + - master + - develop + +image: Visual Studio 2019 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/src/ext/Http/ca/caDecor.h b/src/ext/Http/ca/caDecor.h new file mode 100644 index 00000000..da274650 --- /dev/null +++ b/src/ext/Http/ca/caDecor.h @@ -0,0 +1,13 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#if defined(_M_ARM64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64" +#elif defined(_M_AMD64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64" +#elif defined(_M_ARM) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM" +#else +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86" +#endif diff --git a/src/ext/Http/ca/cost.h b/src/ext/Http/ca/cost.h new file mode 100644 index 00000000..9677e7e8 --- /dev/null +++ b/src/ext/Http/ca/cost.h @@ -0,0 +1,6 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +const UINT COST_HTTP_URL_ACL = 2000; +const UINT COST_HTTP_SNI_SSL = 2000; diff --git a/src/ext/Http/ca/dllmain.cpp b/src/ext/Http/ca/dllmain.cpp new file mode 100644 index 00000000..b4c8c037 --- /dev/null +++ b/src/ext/Http/ca/dllmain.cpp @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +/******************************************************************** +DllMain - standard entry point for all WiX CustomActions + +********************************************************************/ +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInstance, + IN ULONG ulReason, + IN LPVOID) +{ + switch(ulReason) + { + case DLL_PROCESS_ATTACH: + WcaGlobalInitialize(hInstance); + break; + + case DLL_PROCESS_DETACH: + WcaGlobalFinalize(); + break; + } + + return TRUE; +} diff --git a/src/ext/Http/ca/httpca.vcxproj b/src/ext/Http/ca/httpca.vcxproj new file mode 100644 index 00000000..fde00ff4 --- /dev/null +++ b/src/ext/Http/ca/httpca.vcxproj @@ -0,0 +1,72 @@ + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + + {90743805-C043-47C7-B5FF-8F5EE5C8A2DE} + DynamicLibrary + v142 + Unicode + httpca + wixhttpca.def + WiX Toolset Http CustomAction + + + + + + + crypt32.lib;httpapi.lib;msi.lib;rpcrt4.lib;ws2_32.lib + + + + + Create + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + diff --git a/src/ext/Http/ca/httpca.vcxproj.filters b/src/ext/Http/ca/httpca.vcxproj.filters new file mode 100644 index 00000000..2ccd604d --- /dev/null +++ b/src/ext/Http/ca/httpca.vcxproj.filters @@ -0,0 +1,42 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Source Files + + + + \ No newline at end of file diff --git a/src/ext/Http/ca/packages.config b/src/ext/Http/ca/packages.config new file mode 100644 index 00000000..9d88f529 --- /dev/null +++ b/src/ext/Http/ca/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/ext/Http/ca/precomp.h b/src/ext/Http/ca/precomp.h new file mode 100644 index 00000000..c78d78c1 --- /dev/null +++ b/src/ext/Http/ca/precomp.h @@ -0,0 +1,25 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include +#include +#include + +#include "wcautil.h" +#include "cryputil.h" +#include "dutil.h" +#include "memutil.h" +#include "strutil.h" +#include "aclutil.h" + +#include "cost.h" + +#include "caDecor.h" + +enum eHandleExisting +{ + heReplace = 0, + heIgnore = 1, + heFail = 2 +}; diff --git a/src/ext/Http/ca/snisslcert.cpp b/src/ext/Http/ca/snisslcert.cpp new file mode 100644 index 00000000..3a7336af --- /dev/null +++ b/src/ext/Http/ca/snisslcert.cpp @@ -0,0 +1,704 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +#if _WIN32_WINNT < 0x0602 + +typedef struct _HTTP_SERVICE_CONFIG_SSL_SNI_KEY +{ + SOCKADDR_STORAGE IpPort; + PWSTR Host; +} HTTP_SERVICE_CONFIG_SSL_SNI_KEY, * PHTTP_SERVICE_CONFIG_SSL_SNI_KEY; + +typedef struct _HTTP_SERVICE_CONFIG_SSL_SNI_SET +{ + HTTP_SERVICE_CONFIG_SSL_SNI_KEY KeyDesc; + HTTP_SERVICE_CONFIG_SSL_PARAM ParamDesc; +} HTTP_SERVICE_CONFIG_SSL_SNI_SET, * PHTTP_SERVICE_CONFIG_SSL_SNI_SET; + +typedef struct _HTTP_SERVICE_CONFIG_SSL_SNI_QUERY +{ + HTTP_SERVICE_CONFIG_QUERY_TYPE QueryDesc; + HTTP_SERVICE_CONFIG_SSL_SNI_KEY KeyDesc; + DWORD dwToken; +} HTTP_SERVICE_CONFIG_SSL_SNI_QUERY, * PHTTP_SERVICE_CONFIG_SSL_SNI_QUERY; + +#define HttpServiceConfigSslSniCertInfo static_cast(HttpServiceConfigCache + 1) + +#endif + +static UINT SchedHttpSniSslCerts( + __in WCA_TODO todoSched +); +static HRESULT WriteExistingSniSslCert( + __in WCA_TODO action, + __in_z LPCWSTR wzId, + __in_z LPCWSTR wzHost, + __in int iPort, + __in int iHandleExisting, + __in HTTP_SERVICE_CONFIG_SSL_SNI_SET* pSniSslSet, + __inout_z LPWSTR* psczCustomActionData +); +static HRESULT WriteSniSslCert( + __in WCA_TODO action, + __in_z LPCWSTR wzId, + __in_z LPCWSTR wzHost, + __in int iPort, + __in int iHandleExisting, + __in_z LPCWSTR wzCertificateThumbprint, + __in_z LPCWSTR wzAppId, + __in_z_opt LPCWSTR wzCertificateStore, + __inout_z LPWSTR* psczCustomActionData +); +static HRESULT EnsureAppId( + __inout_z LPWSTR* psczAppId, + __in_opt HTTP_SERVICE_CONFIG_SSL_SNI_SET* pExistingSniSslSet +); +static HRESULT StringFromGuid( + __in REFGUID rguid, + __inout_z LPWSTR* psczGuid +); +static HRESULT AddSniSslCert( + __in_z LPCWSTR wzId, + __in_z LPWSTR wzHost, + __in int iPort, + __in BYTE rgbCertificateThumbprint[], + __in DWORD cbCertificateThumbprint, + __in GUID* pAppId, + __in_z LPWSTR wzSslCertStore +); +static HRESULT GetSniSslCert( + __in_z LPWSTR wzHost, + __in int nPort, + __out HTTP_SERVICE_CONFIG_SSL_SNI_SET** ppSet +); +static HRESULT RemoveSniSslCert( + __in_z LPCWSTR wzId, + __in_z LPWSTR wzHost, + __in int iPort +); +static void SetSniSslCertSetKey( + __in HTTP_SERVICE_CONFIG_SSL_SNI_KEY* pKey, + __in_z LPWSTR wzHost, + __in int iPort +); + + +LPCWSTR vcsWixHttpSniSslCertQuery = +L"SELECT `Wix4HttpSniSslCert`.`Wix4HttpSniSslCert`, `Wix4HttpSniSslCert`.`Host`, `Wix4HttpSniSslCert`.`Port`, `Wix4HttpSniSslCert`.`Thumbprint`, `Wix4HttpSniSslCert`.`AppId`, `Wix4HttpSniSslCert`.`Store`, `Wix4HttpSniSslCert`.`HandleExisting`, `Wix4HttpSniSslCert`.`Component_` " +L"FROM `Wix4HttpSniSslCert`"; +enum eWixHttpSniSslCertQuery { hurqId = 1, hurqHost, hurqPort, hurqCertificateThumbprint, hurqAppId, hurqCertificateStore, hurqHandleExisting, hurqComponent }; + +/****************************************************************** + SchedWixHttpSniSslCertsInstall - immediate custom action entry + point to prepare adding URL reservations. + +********************************************************************/ +extern "C" UINT __stdcall SchedHttpSniSslCertsInstall( + __in MSIHANDLE hInstall +) +{ + HRESULT hr = S_OK; + + hr = WcaInitialize(hInstall, "SchedHttpSniSslCertsInstall"); + ExitOnFailure(hr, "Failed to initialize"); + + hr = SchedHttpSniSslCerts(WCA_TODO_INSTALL); + +LExit: + return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); +} + +/****************************************************************** + SchedWixHttpSniSslCertsUninstall - immediate custom action entry + point to prepare removing URL reservations. + +********************************************************************/ +extern "C" UINT __stdcall SchedHttpSniSslCertsUninstall( + __in MSIHANDLE hInstall +) +{ + HRESULT hr = S_OK; + + hr = WcaInitialize(hInstall, "SchedHttpSniSslCertsUninstall"); + ExitOnFailure(hr, "Failed to initialize"); + + hr = SchedHttpSniSslCerts(WCA_TODO_UNINSTALL); + +LExit: + return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); +} + +/****************************************************************** + ExecHttpSniSslCerts - deferred custom action entry point to + register and remove URL reservations. + +********************************************************************/ +extern "C" UINT __stdcall ExecHttpSniSslCerts( + __in MSIHANDLE hInstall +) +{ + HRESULT hr = S_OK; + BOOL fHttpInitialized = FALSE; + LPWSTR sczCustomActionData = NULL; + LPWSTR wz = NULL; + int iTodo = WCA_TODO_UNKNOWN; + LPWSTR sczId = NULL; + LPWSTR sczHost = NULL; + int iPort = 0; + eHandleExisting handleExisting = heIgnore; + LPWSTR sczCertificateThumbprint = NULL; + LPWSTR sczAppId = NULL; + LPWSTR sczCertificateStore = NULL; + + BOOL fRollback = ::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK); + BOOL fRemove = FALSE; + BOOL fAdd = FALSE; + BOOL fFailOnExisting = FALSE; + + GUID guidAppId = { }; + BYTE* pbCertificateThumbprint = NULL; + DWORD cbCertificateThumbprint = 0; + + // Initialize. + hr = WcaInitialize(hInstall, "ExecHttpSniSslCerts"); + ExitOnFailure(hr, "Failed to initialize"); + + hr = HRESULT_FROM_WIN32(::HttpInitialize(HTTPAPI_VERSION_1, HTTP_INITIALIZE_CONFIG, NULL)); + ExitOnFailure(hr, "Failed to initialize HTTP Server configuration"); + + fHttpInitialized = TRUE; + + hr = WcaGetProperty(L"CustomActionData", &sczCustomActionData); + ExitOnFailure(hr, "Failed to get CustomActionData"); + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", sczCustomActionData); + + wz = sczCustomActionData; + while (wz && *wz) + { + // Extract the custom action data and if rolling back, swap INSTALL and UNINSTALL. + hr = WcaReadIntegerFromCaData(&wz, &iTodo); + ExitOnFailure(hr, "Failed to read todo from custom action data"); + + hr = WcaReadStringFromCaData(&wz, &sczId); + ExitOnFailure(hr, "Failed to read Id from custom action data"); + + hr = WcaReadStringFromCaData(&wz, &sczHost); + ExitOnFailure(hr, "Failed to read Host from custom action data"); + + hr = WcaReadIntegerFromCaData(&wz, &iPort); + ExitOnFailure(hr, "Failed to read Port from custom action data"); + + hr = WcaReadIntegerFromCaData(&wz, reinterpret_cast(&handleExisting)); + ExitOnFailure(hr, "Failed to read HandleExisting from custom action data"); + + hr = WcaReadStringFromCaData(&wz, &sczCertificateThumbprint); + ExitOnFailure(hr, "Failed to read CertificateThumbprint from custom action data"); + + hr = WcaReadStringFromCaData(&wz, &sczAppId); + ExitOnFailure(hr, "Failed to read AppId from custom action data"); + + hr = WcaReadStringFromCaData(&wz, &sczCertificateStore); + ExitOnFailure(hr, "Failed to read CertificateStore from custom action data"); + + switch (iTodo) + { + case WCA_TODO_INSTALL: + case WCA_TODO_REINSTALL: + fRemove = heReplace == handleExisting || fRollback; + fAdd = !fRollback || *sczCertificateThumbprint; + fFailOnExisting = heFail == handleExisting && !fRollback; + break; + + case WCA_TODO_UNINSTALL: + fRemove = !fRollback; + fAdd = fRollback && *sczCertificateThumbprint; + fFailOnExisting = FALSE; + break; + } + + if (fRemove) + { + hr = RemoveSniSslCert(sczId, sczHost, iPort); + if (S_OK == hr) + { + WcaLog(LOGMSG_STANDARD, "Removed SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); + } + else if (FAILED(hr)) + { + if (fRollback) + { + WcaLogError(hr, "Failed to remove SNI SSL certificate to rollback '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); + } + else + { + ExitOnFailure(hr, "Failed to remove SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); + } + } + } + + if (fAdd) + { + WcaLog(LOGMSG_STANDARD, "Adding SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); + + hr = StrAllocHexDecode(sczCertificateThumbprint, &pbCertificateThumbprint, &cbCertificateThumbprint); + ExitOnFailure(hr, "Failed to convert thumbprint to bytes for SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); + + hr = ::IIDFromString(sczAppId, &guidAppId); + ExitOnFailure(hr, "Failed to convert AppId '%ls' back to GUID for SNI SSL certificate '%ls' for hostname: %ls:%d", sczAppId, sczId, sczHost, iPort); + + hr = AddSniSslCert(sczId, sczHost, iPort, pbCertificateThumbprint, cbCertificateThumbprint, &guidAppId, sczCertificateStore && *sczCertificateStore ? sczCertificateStore : L"MY"); + if (S_FALSE == hr && fFailOnExisting) + { + hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS); + } + + if (S_OK == hr) + { + WcaLog(LOGMSG_STANDARD, "Added SNI SSL certificate '%ls' for hostname: %ls:%d with thumbprint: %ls", sczId, sczHost, iPort, sczCertificateThumbprint); + } + else if (FAILED(hr)) + { + if (fRollback) + { + WcaLogError(hr, "Failed to add SNI SSL certificate to rollback '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); + } + else + { + ExitOnFailure(hr, "Failed to add SNI SSL certificate '%ls' for hostname: %ls:%d", sczId, sczHost, iPort); + } + } + + ReleaseNullMem(pbCertificateThumbprint); + } + } + +LExit: + ReleaseMem(pbCertificateThumbprint); + ReleaseStr(sczCertificateStore); + ReleaseStr(sczAppId); + ReleaseStr(sczCertificateThumbprint); + ReleaseStr(sczHost); + ReleaseStr(sczId); + ReleaseStr(sczCustomActionData); + + if (fHttpInitialized) + { + ::HttpTerminate(HTTP_INITIALIZE_CONFIG, NULL); + } + + return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); +} + +static UINT SchedHttpSniSslCerts( + __in WCA_TODO todoSched +) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + BOOL fHttpInitialized = FALSE; + DWORD cCertificates = 0; + + PMSIHANDLE hView = NULL; + PMSIHANDLE hRec = NULL; + PMSIHANDLE hQueryReq = NULL; + PMSIHANDLE hAceView = NULL; + + LPWSTR sczCustomActionData = NULL; + LPWSTR sczRollbackCustomActionData = NULL; + + LPWSTR sczId = NULL; + LPWSTR sczComponent = NULL; + WCA_TODO todoComponent = WCA_TODO_UNKNOWN; + LPWSTR sczHost = NULL; + int iPort = 0; + LPWSTR sczCertificateThumbprint = NULL; + LPWSTR sczAppId = NULL; + LPWSTR sczCertificateStore = NULL; + int iHandleExisting = 0; + + HTTP_SERVICE_CONFIG_SSL_SNI_SET* pExistingSniSslSet = NULL; + + // Anything to do? + hr = WcaTableExists(L"Wix4HttpSniSslCert"); + ExitOnFailure(hr, "Failed to check if the Wix4HttpSniSslCert table exists"); + if (S_FALSE == hr) + { + WcaLog(LOGMSG_STANDARD, "Wix4HttpSniSslCert table doesn't exist, so there are no URL reservations to configure"); + ExitFunction(); + } + + // Query and loop through all the SNI SSL certificates. + hr = WcaOpenExecuteView(vcsWixHttpSniSslCertQuery, &hView); + ExitOnFailure(hr, "Failed to open view on the Wix4HttpSniSslCert table"); + + hr = HRESULT_FROM_WIN32(::HttpInitialize(HTTPAPI_VERSION_1, HTTP_INITIALIZE_CONFIG, NULL)); + ExitOnFailure(hr, "Failed to initialize HTTP Server configuration"); + + fHttpInitialized = TRUE; + + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + hr = WcaGetRecordString(hRec, hurqId, &sczId); + ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Wix4HttpSniSslCert"); + + hr = WcaGetRecordString(hRec, hurqComponent, &sczComponent); + ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Component_"); + + // Figure out what we're doing for this reservation, treating reinstall the same as install. + todoComponent = WcaGetComponentToDo(sczComponent); + if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) + { + WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d) for Wix4HttpSniSslCert '%ls'", sczComponent, todoComponent, todoSched, sczId); + continue; + } + + hr = WcaGetRecordFormattedString(hRec, hurqHost, &sczHost); + ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Host"); + + hr = WcaGetRecordFormattedInteger(hRec, hurqPort, &iPort); + ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Port"); + + hr = WcaGetRecordFormattedString(hRec, hurqCertificateThumbprint, &sczCertificateThumbprint); + ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.CertificateThumbprint"); + + if (!sczHost || !*sczHost) + { + hr = E_INVALIDARG; + ExitOnFailure(hr, "Require a Host value for Wix4HttpSniSslCert '%ls'", sczId); + } + + if (!iPort) + { + hr = E_INVALIDARG; + ExitOnFailure(hr, "Require a Port value for Wix4HttpSniSslCert '%ls'", sczId); + } + + if (!sczCertificateThumbprint || !*sczCertificateThumbprint) + { + hr = E_INVALIDARG; + ExitOnFailure(hr, "Require a CertificateThumbprint value for Wix4HttpSniSslCert '%ls'", sczId); + } + + hr = WcaGetRecordFormattedString(hRec, hurqAppId, &sczAppId); + ExitOnFailure(hr, "Failed to get AppId for Wix4HttpSniSslCert '%ls'", sczId); + + hr = WcaGetRecordFormattedString(hRec, hurqCertificateStore, &sczCertificateStore); + ExitOnFailure(hr, "Failed to get CertificateStore for Wix4HttpSniSslCert '%ls'", sczId); + + hr = WcaGetRecordInteger(hRec, hurqHandleExisting, &iHandleExisting); + ExitOnFailure(hr, "Failed to get HandleExisting for Wix4HttpSniSslCert '%ls'", sczId); + + hr = GetSniSslCert(sczHost, iPort, &pExistingSniSslSet); + ExitOnFailure(hr, "Failed to get the existing SNI SSL certificate for Wix4HttpSniSslCert '%ls'", sczId); + + hr = EnsureAppId(&sczAppId, pExistingSniSslSet); + ExitOnFailure(hr, "Failed to ensure AppId for Wix4HttpSniSslCert '%ls'", sczId); + + hr = WriteExistingSniSslCert(todoComponent, sczId, sczHost, iPort, iHandleExisting, pExistingSniSslSet, &sczRollbackCustomActionData); + ExitOnFailure(hr, "Failed to write rollback custom action data for Wix4HttpSniSslCert '%ls'", sczId); + + hr = WriteSniSslCert(todoComponent, sczId, sczHost, iPort, iHandleExisting, sczCertificateThumbprint, sczAppId, sczCertificateStore, &sczCustomActionData); + ExitOnFailure(hr, "Failed to write custom action data for Wix4HttpSniSslCert '%ls'", sczId); + ++cCertificates; + + ReleaseNullMem(pExistingSniSslSet); + } + + // Reaching the end of the list is not an error. + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failure occurred while processing Wix4HttpSniSslCert table"); + + // Schedule ExecHttpSniSslCerts if there's anything to do. + if (cCertificates) + { + WcaLog(LOGMSG_STANDARD, "Scheduling SNI SSL certificate (%ls)", sczCustomActionData); + WcaLog(LOGMSG_STANDARD, "Scheduling rollback SNI SSL certificate (%ls)", sczRollbackCustomActionData); + + if (WCA_TODO_INSTALL == todoSched) + { + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixRollbackHttpSniSslCertsInstall"), sczRollbackCustomActionData, cCertificates * COST_HTTP_SNI_SSL); + ExitOnFailure(hr, "Failed to schedule install SNI SSL certificate rollback"); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixExecHttpSniSslCertsInstall"), sczCustomActionData, cCertificates * COST_HTTP_SNI_SSL); + ExitOnFailure(hr, "Failed to schedule install SNI SSL certificate execution"); + } + else + { + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixRollbackHttpSniSslCertsUninstall"), sczRollbackCustomActionData, cCertificates * COST_HTTP_SNI_SSL); + ExitOnFailure(hr, "Failed to schedule uninstall SNI SSL certificate rollback"); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixExecHttpSniSslCertsUninstall"), sczCustomActionData, cCertificates * COST_HTTP_SNI_SSL); + ExitOnFailure(hr, "Failed to schedule uninstall SNI SSL certificate execution"); + } + } + else + { + WcaLog(LOGMSG_STANDARD, "No SNI SSL certificates scheduled"); + } + +LExit: + ReleaseMem(pExistingSniSslSet); + ReleaseStr(sczCertificateStore); + ReleaseStr(sczAppId); + ReleaseStr(sczCertificateThumbprint); + ReleaseStr(sczHost); + ReleaseStr(sczComponent); + ReleaseStr(sczId); + ReleaseStr(sczRollbackCustomActionData); + ReleaseStr(sczCustomActionData); + + if (fHttpInitialized) + { + ::HttpTerminate(HTTP_INITIALIZE_CONFIG, NULL); + } + + return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); +} + +static HRESULT WriteExistingSniSslCert( + __in WCA_TODO action, + __in_z LPCWSTR wzId, + __in_z LPCWSTR wzHost, + __in int iPort, + __in int iHandleExisting, + __in HTTP_SERVICE_CONFIG_SSL_SNI_SET* pSniSslSet, + __inout_z LPWSTR* psczCustomActionData +) +{ + HRESULT hr = S_OK; + LPWSTR sczCertificateThumbprint = NULL; + LPWSTR sczAppId = NULL; + LPCWSTR wzCertificateStore = NULL; + + if (pSniSslSet) + { + hr = StrAllocHexEncode(reinterpret_cast(pSniSslSet->ParamDesc.pSslHash), pSniSslSet->ParamDesc.SslHashLength, &sczCertificateThumbprint); + ExitOnFailure(hr, "Failed to convert existing certificate thumbprint to hex for Wix4HttpSniSslCert '%ls'", wzId); + + hr = StringFromGuid(pSniSslSet->ParamDesc.AppId, &sczAppId); + ExitOnFailure(hr, "Failed to copy existing AppId for Wix4HttpSniSslCert '%ls'", wzId); + + wzCertificateStore = pSniSslSet->ParamDesc.pSslCertStoreName; + } + + hr = WriteSniSslCert(action, wzId, wzHost, iPort, iHandleExisting, sczCertificateThumbprint ? sczCertificateThumbprint : L"", sczAppId ? sczAppId : L"", wzCertificateStore ? wzCertificateStore : L"", psczCustomActionData); + ExitOnFailure(hr, "Failed to write custom action data for Wix4HttpSniSslCert '%ls'", wzId); + +LExit: + ReleaseStr(sczAppId); + ReleaseStr(sczCertificateThumbprint); + + return hr; +} + +static HRESULT WriteSniSslCert( + __in WCA_TODO action, + __in_z LPCWSTR wzId, + __in_z LPCWSTR wzHost, + __in int iPort, + __in int iHandleExisting, + __in_z LPCWSTR wzCertificateThumbprint, + __in_z LPCWSTR wzAppId, + __in_z_opt LPCWSTR wzCertificateStore, + __inout_z LPWSTR* psczCustomActionData +) +{ + HRESULT hr = S_OK; + + hr = WcaWriteIntegerToCaData(action, psczCustomActionData); + ExitOnFailure(hr, "Failed to write action to custom action data"); + + hr = WcaWriteStringToCaData(wzId, psczCustomActionData); + ExitOnFailure(hr, "Failed to write id to custom action data"); + + hr = WcaWriteStringToCaData(wzHost, psczCustomActionData); + ExitOnFailure(hr, "Failed to write Host to custom action data"); + + hr = WcaWriteIntegerToCaData(iPort, psczCustomActionData); + ExitOnFailure(hr, "Failed to write Port to custom action data"); + + hr = WcaWriteIntegerToCaData(iHandleExisting, psczCustomActionData); + ExitOnFailure(hr, "Failed to write HandleExisting to custom action data"); + + hr = WcaWriteStringToCaData(wzCertificateThumbprint, psczCustomActionData); + ExitOnFailure(hr, "Failed to write CertificateThumbprint to custom action data"); + + hr = WcaWriteStringToCaData(wzAppId, psczCustomActionData); + ExitOnFailure(hr, "Failed to write AppId to custom action data"); + + hr = WcaWriteStringToCaData(wzCertificateStore ? wzCertificateStore : L"", psczCustomActionData); + ExitOnFailure(hr, "Failed to write CertificateStore to custom action data"); + +LExit: + return hr; +} + +static HRESULT EnsureAppId( + __inout_z LPWSTR* psczAppId, + __in_opt HTTP_SERVICE_CONFIG_SSL_SNI_SET* pExistingSniSslSet +) +{ + HRESULT hr = S_OK; + RPC_STATUS rs = RPC_S_OK; + GUID guid = { }; + + if (!psczAppId || !*psczAppId || !**psczAppId) + { + if (pExistingSniSslSet) + { + hr = StringFromGuid(pExistingSniSslSet->ParamDesc.AppId, psczAppId); + ExitOnFailure(hr, "Failed to ensure AppId guid"); + } + else + { + rs = ::UuidCreate(&guid); + hr = HRESULT_FROM_RPC(rs); + ExitOnRootFailure(hr, "Failed to create guid for AppId"); + + hr = StringFromGuid(guid, psczAppId); + ExitOnFailure(hr, "Failed to ensure AppId guid"); + } + } + +LExit: + return hr; +} + +static HRESULT StringFromGuid( + __in REFGUID rguid, + __inout_z LPWSTR* psczGuid +) +{ + HRESULT hr = S_OK; + WCHAR wzGuid[39]; + + if (!::StringFromGUID2(rguid, wzGuid, countof(wzGuid))) + { + hr = E_OUTOFMEMORY; + ExitOnRootFailure(hr, "Failed to convert guid into string"); + } + + hr = StrAllocString(psczGuid, wzGuid, 0); + ExitOnFailure(hr, "Failed to copy guid"); + +LExit: + return hr; +} + +static HRESULT AddSniSslCert( + __in_z LPCWSTR /*wzId*/, + __in_z LPWSTR wzHost, + __in int iPort, + __in BYTE rgbCertificateThumbprint[], + __in DWORD cbCertificateThumbprint, + __in GUID* pAppId, + __in_z LPWSTR wzSslCertStore +) +{ + HRESULT hr = S_OK; + DWORD er = ERROR_SUCCESS; + HTTP_SERVICE_CONFIG_SSL_SNI_SET set = { }; + + SetSniSslCertSetKey(&set.KeyDesc, wzHost, iPort); + set.ParamDesc.SslHashLength = cbCertificateThumbprint; + set.ParamDesc.pSslHash = rgbCertificateThumbprint; + set.ParamDesc.AppId = *pAppId; + set.ParamDesc.pSslCertStoreName = wzSslCertStore; + + er = ::HttpSetServiceConfiguration(NULL, HttpServiceConfigSslSniCertInfo, &set, sizeof(set), NULL); + if (ERROR_ALREADY_EXISTS == er) + { + hr = S_FALSE; + } + else + { + hr = HRESULT_FROM_WIN32(er); + } + + return hr; +} + +static HRESULT GetSniSslCert( + __in_z LPWSTR wzHost, + __in int nPort, + __out HTTP_SERVICE_CONFIG_SSL_SNI_SET** ppSet +) +{ + HRESULT hr = S_OK; + DWORD er = ERROR_SUCCESS; + HTTP_SERVICE_CONFIG_SSL_SNI_QUERY query = { }; + HTTP_SERVICE_CONFIG_SSL_SNI_SET* pSet = NULL; + ULONG cbSet = 0; + + *ppSet = NULL; + + query.QueryDesc = HttpServiceConfigQueryExact; + SetSniSslCertSetKey(&query.KeyDesc, wzHost, nPort); + + er = ::HttpQueryServiceConfiguration(NULL, HttpServiceConfigSslSniCertInfo, &query, sizeof(query), pSet, cbSet, &cbSet, NULL); + if (ERROR_INSUFFICIENT_BUFFER == er) + { + pSet = reinterpret_cast(MemAlloc(cbSet, TRUE)); + ExitOnNull(pSet, hr, E_OUTOFMEMORY, "Failed to allocate query SN SSL certificate buffer"); + + er = ::HttpQueryServiceConfiguration(NULL, HttpServiceConfigSslSniCertInfo, &query, sizeof(query), pSet, cbSet, &cbSet, NULL); + } + + if (ERROR_SUCCESS == er) + { + *ppSet = pSet; + pSet = NULL; + } + else if (ERROR_FILE_NOT_FOUND == er) + { + hr = S_FALSE; + } + else + { + hr = HRESULT_FROM_WIN32(er); + } + +LExit: + ReleaseMem(pSet); + + return hr; +} + +static HRESULT RemoveSniSslCert( + __in_z LPCWSTR /*wzId*/, + __in_z LPWSTR wzHost, + __in int iPort +) +{ + HRESULT hr = S_OK; + DWORD er = ERROR_SUCCESS; + HTTP_SERVICE_CONFIG_SSL_SNI_SET set = { }; + + SetSniSslCertSetKey(&set.KeyDesc, wzHost, iPort); + + er = ::HttpDeleteServiceConfiguration(NULL, HttpServiceConfigSslSniCertInfo, &set, sizeof(set), NULL); + if (ERROR_FILE_NOT_FOUND == er) + { + hr = S_FALSE; + } + else + { + hr = HRESULT_FROM_WIN32(er); + } + + return hr; +} + +static void SetSniSslCertSetKey( + __in HTTP_SERVICE_CONFIG_SSL_SNI_KEY* pKey, + __in_z LPWSTR wzHost, + __in int iPort +) +{ + pKey->Host = wzHost; + SOCKADDR_IN* pss = reinterpret_cast(&pKey->IpPort); + pss->sin_family = AF_INET; + pss->sin_port = htons(static_cast(iPort)); +} diff --git a/src/ext/Http/ca/wixhttpca.cpp b/src/ext/Http/ca/wixhttpca.cpp new file mode 100644 index 00000000..8c846ffc --- /dev/null +++ b/src/ext/Http/ca/wixhttpca.cpp @@ -0,0 +1,530 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +static HRESULT AppendUrlAce( + __in LPWSTR wzSecurityPrincipal, + __in int iRights, + __in LPWSTR* psczSDDL + ); +static HRESULT WriteHttpUrlReservation( + __in WCA_TODO action, + __in LPWSTR wzUrl, + __in LPWSTR wzSDDL, + __in int iHandleExisting, + __in LPWSTR* psczCustomActionData + ); +static HRESULT AddUrlReservation( + __in LPWSTR wzUrl, + __in LPWSTR wzSddl + ); +static HRESULT GetUrlReservation( + __in LPWSTR wzUrl, + __deref_out_z LPWSTR* psczSddl + ); +static HRESULT RemoveUrlReservation( + __in LPWSTR wzUrl + ); + +HTTPAPI_VERSION vcHttpVersion = HTTPAPI_VERSION_1; +ULONG vcHttpFlags = HTTP_INITIALIZE_CONFIG; + +LPCWSTR vcsHttpUrlReservationQuery = + L"SELECT `Wix4HttpUrlReservation`.`Wix4HttpUrlReservation`, `Wix4HttpUrlReservation`.`HandleExisting`, `Wix4HttpUrlReservation`.`Sddl`, `Wix4HttpUrlReservation`.`Url`, `Wix4HttpUrlReservation`.`Component_` " + L"FROM `Wix4HttpUrlReservation`"; +enum eHttpUrlReservationQuery { hurqId = 1, hurqHandleExisting, hurqSDDL, hurqUrl, hurqComponent }; + +LPCWSTR vcsHttpUrlAceQuery = + L"SELECT `Wix4HttpUrlAce`.`SecurityPrincipal`, `Wix4HttpUrlAce`.`Rights` " + L"FROM `Wix4HttpUrlAce` " + L"WHERE `Wix4HttpUrlAce`.`Wix4HttpUrlReservation_`=?"; +enum eHttpUrlAceQuery { huaqSecurityPrincipal = 1, huaqRights }; + +/****************************************************************** + SchedHttpUrlReservations - immediate custom action worker to + prepare configuring URL reservations. + +********************************************************************/ +static UINT SchedHttpUrlReservations( + __in MSIHANDLE hInstall, + __in WCA_TODO todoSched + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + BOOL fAceTableExists = FALSE; + BOOL fHttpInitialized = FALSE; + DWORD cUrlReservations = 0; + + PMSIHANDLE hView = NULL; + PMSIHANDLE hRec = NULL; + PMSIHANDLE hQueryReq = NULL; + PMSIHANDLE hAceView = NULL; + + LPWSTR sczCustomActionData = NULL; + LPWSTR sczRollbackCustomActionData = NULL; + + LPWSTR sczId = NULL; + LPWSTR sczComponent = NULL; + WCA_TODO todoComponent = WCA_TODO_UNKNOWN; + LPWSTR sczUrl = NULL; + LPWSTR sczSecurityPrincipal = NULL; + int iRights = 0; + int iHandleExisting = 0; + + LPWSTR sczExistingSDDL = NULL; + LPWSTR sczSDDL = NULL; + + // Initialize. + hr = WcaInitialize(hInstall, "SchedHttpUrlReservations"); + ExitOnFailure(hr, "Failed to initialize."); + + // Anything to do? + hr = WcaTableExists(L"Wix4HttpUrlReservation"); + ExitOnFailure(hr, "Failed to check if the Wix4HttpUrlReservation table exists."); + if (S_FALSE == hr) + { + WcaLog(LOGMSG_STANDARD, "Wix4HttpUrlReservation table doesn't exist, so there are no URL reservations to configure."); + ExitFunction(); + } + + hr = WcaTableExists(L"Wix4HttpUrlAce"); + ExitOnFailure(hr, "Failed to check if the Wix4HttpUrlAce table exists."); + fAceTableExists = S_OK == hr; + + // Query and loop through all the URL reservations. + hr = WcaOpenExecuteView(vcsHttpUrlReservationQuery, &hView); + ExitOnFailure(hr, "Failed to open view on the Wix4HttpUrlReservation table."); + + hr = HRESULT_FROM_WIN32(::HttpInitialize(vcHttpVersion, vcHttpFlags, NULL)); + ExitOnFailure(hr, "Failed to initialize HTTP Server configuration."); + + fHttpInitialized = TRUE; + + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + hr = WcaGetRecordString(hRec, hurqId, &sczId); + ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.Wix4HttpUrlReservation"); + + hr = WcaGetRecordString(hRec, hurqComponent, &sczComponent); + ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.Component_"); + + // Figure out what we're doing for this reservation, treating reinstall the same as install. + todoComponent = WcaGetComponentToDo(sczComponent); + if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) + { + WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d) for UrlReservation '%ls'.", sczComponent, todoComponent, todoSched, sczId); + continue; + } + + hr = WcaGetRecordFormattedString(hRec, hurqUrl, &sczUrl); + ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.Url"); + + hr = WcaGetRecordInteger(hRec, hurqHandleExisting, &iHandleExisting); + ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.HandleExisting"); + + if (::MsiRecordIsNull(hRec, hurqSDDL)) + { + hr = StrAllocString(&sczSDDL, L"D:", 2); + ExitOnFailure(hr, "Failed to allocate SDDL string."); + + // Skip creating the SDDL on uninstall, since it's never used and the lookup(s) could fail. + if (fAceTableExists && WCA_TODO_UNINSTALL != todoComponent) + { + hQueryReq = ::MsiCreateRecord(1); + hr = WcaSetRecordString(hQueryReq, 1, sczId); + ExitOnFailure(hr, "Failed to create record for querying Wix4HttpUrlAce table for reservation %ls", sczId); + + hr = WcaOpenView(vcsHttpUrlAceQuery, &hAceView); + ExitOnFailure(hr, "Failed to open view on Wix4HttpUrlAce table for reservation %ls", sczId); + hr = WcaExecuteView(hAceView, hQueryReq); + ExitOnFailure(hr, "Failed to execute view on Wix4HttpUrlAce table for reservation %ls", sczId); + + while (S_OK == (hr = WcaFetchRecord(hAceView, &hRec))) + { + hr = WcaGetRecordFormattedString(hRec, huaqSecurityPrincipal, &sczSecurityPrincipal); + ExitOnFailure(hr, "Failed to get Wix4HttpUrlAce.SecurityPrincipal"); + + hr = WcaGetRecordInteger(hRec, huaqRights, &iRights); + ExitOnFailure(hr, "Failed to get Wix4HttpUrlAce.Rights"); + + hr = AppendUrlAce(sczSecurityPrincipal, iRights, &sczSDDL); + ExitOnFailure(hr, "Failed to append URL ACE."); + } + + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failed to enumerate selected rows from Wix4HttpUrlAce table."); + } + } + else + { + hr = WcaGetRecordFormattedString(hRec, hurqSDDL, &sczSDDL); + ExitOnFailure(hr, "Failed to get Wix4HttpUrlReservation.SDDL"); + } + + hr = GetUrlReservation(sczUrl, &sczExistingSDDL); + ExitOnFailure(hr, "Failed to get the existing SDDL for %ls", sczUrl); + + hr = WriteHttpUrlReservation(todoComponent, sczUrl, sczExistingSDDL ? sczExistingSDDL : L"", iHandleExisting, &sczRollbackCustomActionData); + ExitOnFailure(hr, "Failed to write URL Reservation to rollback custom action data."); + + hr = WriteHttpUrlReservation(todoComponent, sczUrl, sczSDDL, iHandleExisting, &sczCustomActionData); + ExitOnFailure(hr, "Failed to write URL reservation to custom action data."); + ++cUrlReservations; + } + + // Reaching the end of the list is not an error. + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failure occurred while processing Wix4HttpUrlReservation table."); + + // Schedule ExecHttpUrlReservations if there's anything to do. + if (cUrlReservations) + { + WcaLog(LOGMSG_STANDARD, "Scheduling URL reservations (%ls)", sczCustomActionData); + WcaLog(LOGMSG_STANDARD, "Scheduling rollback URL reservations (%ls)", sczRollbackCustomActionData); + + if (WCA_TODO_INSTALL == todoSched) + { + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixRollbackHttpUrlReservationsInstall"), sczRollbackCustomActionData, cUrlReservations * COST_HTTP_URL_ACL); + ExitOnFailure(hr, "Failed to schedule install URL reservations rollback."); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixExecHttpUrlReservationsInstall"), sczCustomActionData, cUrlReservations * COST_HTTP_URL_ACL); + ExitOnFailure(hr, "Failed to schedule install URL reservations execution."); + } + else + { + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixRollbackHttpUrlReservationsUninstall"), sczRollbackCustomActionData, cUrlReservations * COST_HTTP_URL_ACL); + ExitOnFailure(hr, "Failed to schedule uninstall URL reservations rollback."); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WixExecHttpUrlReservationsUninstall"), sczCustomActionData, cUrlReservations * COST_HTTP_URL_ACL); + ExitOnFailure(hr, "Failed to schedule uninstall URL reservations execution."); + } + } + else + { + WcaLog(LOGMSG_STANDARD, "No URL reservations scheduled."); + } + +LExit: + ReleaseStr(sczSDDL); + ReleaseStr(sczExistingSDDL); + ReleaseStr(sczSecurityPrincipal); + ReleaseStr(sczUrl) + ReleaseStr(sczComponent); + ReleaseStr(sczId); + ReleaseStr(sczRollbackCustomActionData); + ReleaseStr(sczCustomActionData); + + if (fHttpInitialized) + { + ::HttpTerminate(vcHttpFlags, NULL); + } + + return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); +} + +static HRESULT AppendUrlAce( + __in LPWSTR wzSecurityPrincipal, + __in int iRights, + __in LPWSTR* psczSDDL + ) +{ + HRESULT hr = S_OK; + LPCWSTR wzSid = NULL; + LPWSTR sczSid = NULL; + + Assert(wzSecurityPrincipal && *wzSecurityPrincipal); + Assert(psczSDDL && *psczSDDL); + + // As documented in the xsd, if the first char is '*', then the rest of the string is a SID string, e.g. *S-1-5-18. + if (L'*' == wzSecurityPrincipal[0]) + { + wzSid = &wzSecurityPrincipal[1]; + } + else + { + hr = AclGetAccountSidStringEx(NULL, wzSecurityPrincipal, &sczSid); + ExitOnFailure(hr, "Failed to lookup the SID for account %ls", wzSecurityPrincipal); + + wzSid = sczSid; + } + + hr = StrAllocFormatted(psczSDDL, L"%ls(A;;%#x;;;%ls)", *psczSDDL, iRights, wzSid); + +LExit: + ReleaseStr(sczSid); + + return hr; +} + +static HRESULT WriteHttpUrlReservation( + __in WCA_TODO action, + __in LPWSTR wzUrl, + __in LPWSTR wzSDDL, + __in int iHandleExisting, + __in LPWSTR* psczCustomActionData + ) +{ + HRESULT hr = S_OK; + + hr = WcaWriteIntegerToCaData(action, psczCustomActionData); + ExitOnFailure(hr, "Failed to write action to custom action data."); + + hr = WcaWriteStringToCaData(wzUrl, psczCustomActionData); + ExitOnFailure(hr, "Failed to write URL to custom action data."); + + hr = WcaWriteStringToCaData(wzSDDL, psczCustomActionData); + ExitOnFailure(hr, "Failed to write SDDL to custom action data."); + + hr = WcaWriteIntegerToCaData(iHandleExisting, psczCustomActionData); + ExitOnFailure(hr, "Failed to write HandleExisting to custom action data.") + +LExit: + return hr; +} + +/****************************************************************** + SchedHttpUrlReservationsInstall - immediate custom action entry + point to prepare adding URL reservations. + +********************************************************************/ +extern "C" UINT __stdcall SchedHttpUrlReservationsInstall( + __in MSIHANDLE hInstall + ) +{ + return SchedHttpUrlReservations(hInstall, WCA_TODO_INSTALL); +} + +/****************************************************************** + SchedHttpUrlReservationsUninstall - immediate custom action entry + point to prepare removing URL reservations. + +********************************************************************/ +extern "C" UINT __stdcall SchedHttpUrlReservationsUninstall( + __in MSIHANDLE hInstall + ) +{ + return SchedHttpUrlReservations(hInstall, WCA_TODO_UNINSTALL); +} + +/****************************************************************** + ExecHttpUrlReservations - deferred custom action entry point to + register and remove URL reservations. + +********************************************************************/ +extern "C" UINT __stdcall ExecHttpUrlReservations( + __in MSIHANDLE hInstall + ) +{ + HRESULT hr = S_OK; + BOOL fHttpInitialized = FALSE; + LPWSTR sczCustomActionData = NULL; + LPWSTR wz = NULL; + int iTodo = WCA_TODO_UNKNOWN; + LPWSTR sczUrl = NULL; + LPWSTR sczSDDL = NULL; + eHandleExisting handleExisting = heIgnore; + BOOL fRollback = ::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK); + BOOL fRemove = FALSE; + BOOL fAdd = FALSE; + BOOL fFailOnExisting = FALSE; + + // Initialize. + hr = WcaInitialize(hInstall, "ExecHttpUrlReservations"); + ExitOnFailure(hr, "Failed to initialize."); + + hr = HRESULT_FROM_WIN32(::HttpInitialize(vcHttpVersion, vcHttpFlags, NULL)); + ExitOnFailure(hr, "Failed to initialize HTTP Server configuration."); + + fHttpInitialized = TRUE; + + hr = WcaGetProperty(L"CustomActionData", &sczCustomActionData); + ExitOnFailure(hr, "Failed to get CustomActionData."); + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", sczCustomActionData); + + if (!sczCustomActionData || !*sczCustomActionData) + { + WcaLog(LOGMSG_STANDARD, "No URL reservations to be executed."); + } + + wz = sczCustomActionData; + while (wz && *wz) + { + // Extract the custom action data and if rolling back, swap INSTALL and UNINSTALL. + hr = WcaReadIntegerFromCaData(&wz, &iTodo); + ExitOnFailure(hr, "Failed to read todo from custom action data."); + + hr = WcaReadStringFromCaData(&wz, &sczUrl); + ExitOnFailure(hr, "Failed to read Url from custom action data."); + + hr = WcaReadStringFromCaData(&wz, &sczSDDL); + ExitOnFailure(hr, "Failed to read SDDL from custom action data."); + + hr = WcaReadIntegerFromCaData(&wz, reinterpret_cast(&handleExisting)); + ExitOnFailure(hr, "Failed to read HandleExisting from custom action data."); + + switch (iTodo) + { + case WCA_TODO_INSTALL: + case WCA_TODO_REINSTALL: + fRemove = heReplace == handleExisting || fRollback; + fAdd = !fRollback || *sczSDDL; + fFailOnExisting = heFail == handleExisting && !fRollback; + break; + + case WCA_TODO_UNINSTALL: + fRemove = !fRollback; + fAdd = fRollback && *sczSDDL; + fFailOnExisting = FALSE; + break; + } + + if (fRemove) + { + WcaLog(LOGMSG_STANDARD, "Removing reservation for URL '%ls'", sczUrl); + hr = RemoveUrlReservation(sczUrl); + if (FAILED(hr)) + { + if (fRollback) + { + WcaLogError(hr, "Failed to remove reservation for rollback for URL '%ls'", sczUrl); + } + else + { + ExitOnFailure(hr, "Failed to remove reservation for URL '%ls'", sczUrl); + } + } + } + + if (fAdd) + { + WcaLog(LOGMSG_STANDARD, "Adding reservation for URL '%ls' with SDDL '%ls'", sczUrl, sczSDDL); + hr = AddUrlReservation(sczUrl, sczSDDL); + if (S_FALSE == hr && fFailOnExisting) + { + hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS); + } + if (FAILED(hr)) + { + if (fRollback) + { + WcaLogError(hr, "Failed to add reservation for rollback for URL '%ls' with SDDL '%ls'", sczUrl, sczSDDL); + } + else + { + ExitOnFailure(hr, "Failed to add reservation for URL '%ls' with SDDL '%ls'", sczUrl, sczSDDL); + } + } + } + } + +LExit: + ReleaseStr(sczSDDL); + ReleaseStr(sczUrl); + ReleaseStr(sczCustomActionData); + + if (fHttpInitialized) + { + ::HttpTerminate(vcHttpFlags, NULL); + } + + return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); +} + +static HRESULT AddUrlReservation( + __in LPWSTR wzUrl, + __in LPWSTR wzSddl + ) +{ + HRESULT hr = S_OK; + DWORD er = ERROR_SUCCESS; + HTTP_SERVICE_CONFIG_URLACL_SET set = { }; + + set.KeyDesc.pUrlPrefix = wzUrl; + set.ParamDesc.pStringSecurityDescriptor = wzSddl; + + er = ::HttpSetServiceConfiguration(NULL, HttpServiceConfigUrlAclInfo, &set, sizeof(set), NULL); + if (ERROR_ALREADY_EXISTS == er) + { + hr = S_FALSE; + } + else + { + hr = HRESULT_FROM_WIN32(er); + } + ExitOnFailure(hr, "Failed to add URL reservation: %ls, ACL: %ls", wzUrl, wzSddl); + +LExit: + return hr; +} + +static HRESULT GetUrlReservation( + __in LPWSTR wzUrl, + __deref_out_z LPWSTR* psczSddl + ) +{ + HRESULT hr = S_OK; + DWORD er = ERROR_SUCCESS; + HTTP_SERVICE_CONFIG_URLACL_QUERY query = { }; + HTTP_SERVICE_CONFIG_URLACL_SET* pSet = NULL; + ULONG cbSet = 0; + + query.QueryDesc = HttpServiceConfigQueryExact; + query.KeyDesc.pUrlPrefix = wzUrl; + + er = ::HttpQueryServiceConfiguration(NULL, HttpServiceConfigUrlAclInfo, &query, sizeof(query), pSet, cbSet, &cbSet, NULL); + if (ERROR_INSUFFICIENT_BUFFER == er) + { + pSet = reinterpret_cast(MemAlloc(cbSet, TRUE)); + ExitOnNull(pSet, hr, E_OUTOFMEMORY, "Failed to allocate query URLACL buffer."); + + er = ::HttpQueryServiceConfiguration(NULL, HttpServiceConfigUrlAclInfo, &query, sizeof(query), pSet, cbSet, &cbSet, NULL); + } + + if (ERROR_SUCCESS == er) + { + hr = StrAllocString(psczSddl, pSet->ParamDesc.pStringSecurityDescriptor, 0); + } + else if (ERROR_FILE_NOT_FOUND == er) + { + hr = S_FALSE; + } + else + { + hr = HRESULT_FROM_WIN32(er); + } + +LExit: + ReleaseMem(pSet); + + return hr; +} + +static HRESULT RemoveUrlReservation( + __in LPWSTR wzUrl + ) +{ + HRESULT hr = S_OK; + DWORD er = ERROR_SUCCESS; + HTTP_SERVICE_CONFIG_URLACL_SET set = { }; + + set.KeyDesc.pUrlPrefix = wzUrl; + + er = ::HttpDeleteServiceConfiguration(NULL, HttpServiceConfigUrlAclInfo, &set, sizeof(set), NULL); + if (ERROR_FILE_NOT_FOUND == er) + { + hr = S_FALSE; + } + else + { + hr = HRESULT_FROM_WIN32(er); + } + ExitOnFailure(hr, "Failed to remove URL reservation: %ls", wzUrl); + +LExit: + return hr; +} diff --git a/src/ext/Http/ca/wixhttpca.def b/src/ext/Http/ca/wixhttpca.def new file mode 100644 index 00000000..281c5631 --- /dev/null +++ b/src/ext/Http/ca/wixhttpca.def @@ -0,0 +1,12 @@ +; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +LIBRARY "httpca" + +EXPORTS + SchedHttpUrlReservationsInstall + SchedHttpUrlReservationsUninstall + ExecHttpUrlReservations + SchedHttpSniSslCertsInstall + SchedHttpSniSslCertsUninstall + ExecHttpSniSslCerts diff --git a/src/ext/Http/nuget.config b/src/ext/Http/nuget.config new file mode 100644 index 00000000..db7aba29 --- /dev/null +++ b/src/ext/Http/nuget.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Http/test/WixToolsetTest.Http/HttpExtensionFixture.cs b/src/ext/Http/test/WixToolsetTest.Http/HttpExtensionFixture.cs new file mode 100644 index 00000000..40b49327 --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/HttpExtensionFixture.cs @@ -0,0 +1,57 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.Http +{ + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Http; + using Xunit; + + public class HttpExtensionFixture + { + [Fact] + public void CanBuildUsingSniSssl() + { + var folder = TestData.Get("TestData", "SniSsl"); + var build = new Builder(folder, typeof(HttpExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "CustomAction", "Wix4HttpSniSslCert"); + WixAssert.CompareLineByLine(new[] + { + "CustomAction:Wix4ExecHttpSniSslCertsInstall_X86\t3073\tWix4HttpCA_X86\tExecHttpSniSslCerts\t", + "CustomAction:Wix4ExecHttpSniSslCertsUninstall_X86\t3073\tWix4HttpCA_X86\tExecHttpSniSslCerts\t", + "CustomAction:Wix4RollbackHttpSniSslCertsInstall_X86\t3329\tWix4HttpCA_X86\tExecHttpSniSslCerts\t", + "CustomAction:Wix4RollbackHttpSniSslCertsUninstall_X86\t3329\tWix4HttpCA_X86\tExecHttpSniSslCerts\t", + "CustomAction:Wix4SchedHttpSniSslCertsInstall_X86\t1\tWix4HttpCA_X86\tSchedHttpSniSslCertsInstall\t", + "CustomAction:Wix4SchedHttpSniSslCertsUninstall_X86\t1\tWix4HttpCA_X86\tSchedHttpSniSslCertsUninstall\t", + "Wix4HttpSniSslCert:sslC9YX6_H7UL_WGBx4DoDGI.Sj.D0\texample.com\t8080\t[SOME_THUMBPRINT]\t\t\t2\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo", + }, results); + } + + [Fact] + public void CanBuildUsingUrlReservation() + { + var folder = TestData.Get(@"TestData\UsingUrlReservation"); + var build = new Builder(folder, typeof(HttpExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "CustomAction", "Wix4HttpUrlAce", "Wix4HttpUrlReservation"); + WixAssert.CompareLineByLine(new[] + { + "CustomAction:Wix4ExecHttpUrlReservationsInstall_X86\t3073\tWix4HttpCA_X86\tExecHttpUrlReservations\t", + "CustomAction:Wix4ExecHttpUrlReservationsUninstall_X86\t3073\tWix4HttpCA_X86\tExecHttpUrlReservations\t", + "CustomAction:Wix4RollbackHttpUrlReservationsInstall_X86\t3329\tWix4HttpCA_X86\tExecHttpUrlReservations\t", + "CustomAction:Wix4RollbackHttpUrlReservationsUninstall_X86\t3329\tWix4HttpCA_X86\tExecHttpUrlReservations\t", + "CustomAction:Wix4SchedHttpUrlReservationsInstall_X86\t1\tWix4HttpCA_X86\tSchedHttpUrlReservationsInstall\t", + "CustomAction:Wix4SchedHttpUrlReservationsUninstall_X86\t1\tWix4HttpCA_X86\tSchedHttpUrlReservationsUninstall\t", + "Wix4HttpUrlAce:aceu5os2gQoblRmzwjt85LQf997uD4\turlO23FkY2xzEY54lY6E6sXFW6glXc\tNT SERVICE\\TestService\t268435456", + "Wix4HttpUrlReservation:urlO23FkY2xzEY54lY6E6sXFW6glXc\t0\t\thttp://+:80/vroot/\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo", + }, results); + } + + private static void Build(string[] args) + { + var result = WixRunner.Execute(args) + .AssertSuccess(); + } + } +} diff --git a/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/Package.en-us.wxl b/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/Package.wxs b/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/Package.wxs new file mode 100644 index 00000000..c85e9bba --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/Package.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/PackageComponents.wxs b/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/PackageComponents.wxs new file mode 100644 index 00000000..f0aae485 --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/PackageComponents.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/example.txt b/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/TestData/SniSsl/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.en-us.wxl b/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.wxs b/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.wxs new file mode 100644 index 00000000..bd31e81f --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/PackageComponents.wxs b/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/PackageComponents.wxs new file mode 100644 index 00000000..780d598b --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/PackageComponents.wxs @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/example.txt b/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/TestData/UsingUrlReservation/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/ext/Http/test/WixToolsetTest.Http/WixToolsetTest.Http.csproj b/src/ext/Http/test/WixToolsetTest.Http/WixToolsetTest.Http.csproj new file mode 100644 index 00000000..7e60e426 --- /dev/null +++ b/src/ext/Http/test/WixToolsetTest.Http/WixToolsetTest.Http.csproj @@ -0,0 +1,38 @@ + + + + + + netcoreapp3.1 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Http/wix.snk b/src/ext/Http/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/ext/Http/wix.snk differ diff --git a/src/ext/Http/wixext/HttpCompiler.cs b/src/ext/Http/wixext/HttpCompiler.cs new file mode 100644 index 00000000..6c572470 --- /dev/null +++ b/src/ext/Http/wixext/HttpCompiler.cs @@ -0,0 +1,383 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; + using WixToolset.Http.Symbols; + + /// + /// The compiler for the WiX Toolset Http Extension. + /// + public sealed class HttpCompiler : BaseCompilerExtension + { + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/http"; + + /// + /// Processes an element for the Compiler. + /// + /// Source line number for the parent element. + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "ServiceInstall": + var serviceInstallName = context["ServiceInstallName"]; + var serviceUser = String.IsNullOrEmpty(serviceInstallName) ? null : String.Concat("NT SERVICE\\", serviceInstallName); + var serviceComponentId = context["ServiceInstallComponentId"]; + + switch (element.Name.LocalName) + { + case "UrlReservation": + this.ParseUrlReservationElement(intermediate, section, element, serviceComponentId, serviceUser); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + case "Component": + string componentId = context["ComponentId"]; + + switch (element.Name.LocalName) + { + case "SniSslCertificate": + this.ParseSniSslCertificateElement(intermediate, section, element, componentId); + break; + + case "UrlReservation": + this.ParseUrlReservationElement(intermediate, section, element, componentId, null); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a SniSsl element. + /// + /// The element to parse. + /// Identifier of the component that owns this SNI SSL Certificate. + private void ParseSniSslCertificateElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + Identifier id = null; + string host = null; + string port = null; + string appId = null; + string store = null; + string thumbprint = null; + var handleExisting = HandleExisting.Replace; + string handleExistingValue = null; + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "AppId": + appId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "HandleExisting": + handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (handleExistingValue) + { + case "replace": + handleExisting = HandleExisting.Replace; + break; + case "ignore": + handleExisting = HandleExisting.Ignore; + break; + case "fail": + handleExisting = HandleExisting.Fail; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail")); + break; + } + break; + case "Host": + host = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Port": + port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Store": + store = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Thumbprint": + thumbprint = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.ParseHelper.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); + } + } + + // Need the element ID for child element processing, so generate now if not authored. + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("ssl", componentId, host, port); + } + + // Required attributes. + if (null == host) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Host")); + } + + if (null == port) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Port")); + } + + if (null == thumbprint) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Thumbprint")); + } + + // Parse unknown children. + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); + + if (!this.Messaging.EncounteredError) + { + section.AddSymbol(new WixHttpSniSslCertSymbol(sourceLineNumbers, id) + { + Host = host, + Port = port, + Thumbprint = thumbprint, + AppId = appId, + Store = store, + HandleExisting = handleExisting, + ComponentRef = componentId, + }); + + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpSniSslCertsInstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpSniSslCertsUninstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + } + } + + /// + /// Parses a UrlReservation element. + /// + /// The element to parse. + /// Identifier of the component that owns this URL reservation. + /// The security principal of the parent element (null if nested under Component). + private void ParseUrlReservationElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string securityPrincipal) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + Identifier id = null; + var handleExisting = HandleExisting.Replace; + string sddl = null; + string url = null; + var foundACE = false; + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "HandleExisting": + var handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (handleExistingValue) + { + case "replace": + handleExisting = HandleExisting.Replace; + break; + case "ignore": + handleExisting = HandleExisting.Ignore; + break; + case "fail": + handleExisting = HandleExisting.Fail; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail")); + break; + } + break; + case "Sddl": + sddl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Url": + url = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.ParseHelper.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); + } + } + + // Need the element ID for child element processing, so generate now if not authored. + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("url", componentId, securityPrincipal, url); + } + + // Parse UrlAce children. + foreach (var child in node.Elements()) + { + if (this.Namespace == child.Name.Namespace) + { + switch (child.Name.LocalName) + { + case "UrlAce": + if (null != sddl) + { + this.Messaging.Write(ErrorMessages.IllegalParentAttributeWhenNested(sourceLineNumbers, "UrlReservation", "Sddl", "UrlAce")); + } + else + { + foundACE = true; + this.ParseUrlAceElement(intermediate, section, child, id.Id, securityPrincipal); + } + break; + default: + this.ParseHelper.UnexpectedElement(node, child); + break; + } + } + else + { + this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); + } + } + + // Url is required. + if (null == url) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Url")); + } + + // Security is required. + if (null == sddl && !foundACE) + { + this.Messaging.Write(HttpErrors.NoSecuritySpecified(sourceLineNumbers)); + } + + if (!this.Messaging.EncounteredError) + { + section.AddSymbol(new WixHttpUrlReservationSymbol(sourceLineNumbers, id) + { + HandleExisting = handleExisting, + Sddl = sddl, + Url = url, + ComponentRef = componentId, + }); + + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpUrlReservationsInstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpUrlReservationsUninstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + } + } + + /// + /// Parses a UrlAce element. + /// + /// The element to parse. + /// The URL reservation ID. + /// The default security principal. + private void ParseUrlAceElement(Intermediate intermediate, IntermediateSection section, XElement node, string urlReservationId, string defaultSecurityPrincipal) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + Identifier id = null; + var securityPrincipal = defaultSecurityPrincipal; + var rights = HttpConstants.GENERIC_ALL; + string rightsValue = null; + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "SecurityPrincipal": + securityPrincipal = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Rights": + rightsValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (rightsValue) + { + case "all": + rights = HttpConstants.GENERIC_ALL; + break; + case "delegate": + rights = HttpConstants.GENERIC_WRITE; + break; + case "register": + rights = HttpConstants.GENERIC_EXECUTE; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Rights", rightsValue, "all", "delegate", "register")); + break; + } + break; + default: + this.ParseHelper.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); + } + } + + // Generate Id now if not authored. + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("ace", urlReservationId, securityPrincipal, rightsValue); + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); + + // SecurityPrincipal is required. + if (null == securityPrincipal) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SecurityPrincipal")); + } + + if (!this.Messaging.EncounteredError) + { + section.AddSymbol(new WixHttpUrlAceSymbol(sourceLineNumbers, id) + { + WixHttpUrlReservationRef = urlReservationId, + SecurityPrincipal = securityPrincipal, + Rights = rights, + }); + } + } + } +} diff --git a/src/ext/Http/wixext/HttpConstants.cs b/src/ext/Http/wixext/HttpConstants.cs new file mode 100644 index 00000000..5fb42d86 --- /dev/null +++ b/src/ext/Http/wixext/HttpConstants.cs @@ -0,0 +1,15 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using System; + + internal static class HttpConstants + { + // from winnt.h + public const int GENERIC_ALL = 0x10000000; + public const int GENERIC_EXECUTE = 0x20000000; + public const int GENERIC_WRITE = 0x40000000; + + } +} diff --git a/src/ext/Http/wixext/HttpDecompiler.cs b/src/ext/Http/wixext/HttpDecompiler.cs new file mode 100644 index 00000000..8991ec2f --- /dev/null +++ b/src/ext/Http/wixext/HttpDecompiler.cs @@ -0,0 +1,137 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ +#if TODO_CONSIDER_DECOMPILER + using System; + using System.Collections; + using System.Diagnostics; + using System.Globalization; + using WixToolset.Data; + using WixToolset.Extensibility; + using Http = WixToolset.Extensions.Serialize.Http; + using Wix = WixToolset.Data.Serialize; + + /// + /// The decompiler for the WiX Toolset Http Extension. + /// + public sealed class HttpDecompiler : DecompilerExtension + { + /// + /// Creates a decompiler for Http Extension. + /// + public HttpDecompiler() + { + this.TableDefinitions = HttpExtensionData.GetExtensionTableDefinitions(); + } + + /// + /// Get the extensions library to be removed. + /// + /// Table definitions for library. + /// Library to remove from decompiled output. + public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) + { + return HttpExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public override void DecompileTable(Table table) + { + switch (table.Name) + { + case "WixHttpUrlReservation": + this.DecompileWixHttpUrlReservationTable(table); + break; + case "WixHttpUrlAce": + this.DecompileWixHttpUrlAceTable(table); + break; + default: + base.DecompileTable(table); + break; + } + } + + /// + /// Decompile the WixHttpUrlReservation table. + /// + /// The table to decompile. + private void DecompileWixHttpUrlReservationTable(Table table) + { + foreach (Row row in table.Rows) + { + Http.UrlReservation urlReservation = new Http.UrlReservation(); + urlReservation.Id = (string)row[0]; + switch((int)row[1]) + { + case HttpConstants.heReplace: + default: + urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.replace; + break; + case HttpConstants.heIgnore: + urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.ignore; + break; + case HttpConstants.heFail: + urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.fail; + break; + } + urlReservation.Sddl = (string)row[2]; + urlReservation.Url = (string)row[3]; + + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]); + if (null != component) + { + component.AddChild(urlReservation); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); + } + this.Core.IndexElement(row, urlReservation); + } + } + + + /// + /// Decompile the WixHttpUrlAce table. + /// + /// The table to decompile. + private void DecompileWixHttpUrlAceTable(Table table) + { + foreach (Row row in table.Rows) + { + Http.UrlAce urlace = new Http.UrlAce(); + urlace.Id = (string)row[0]; + urlace.SecurityPrincipal = (string)row[2]; + switch (Convert.ToInt32(row[3])) + { + case HttpConstants.GENERIC_ALL: + default: + urlace.Rights = Http.UrlAce.RightsType.all; + break; + case HttpConstants.GENERIC_EXECUTE: + urlace.Rights = Http.UrlAce.RightsType.register; + break; + case HttpConstants.GENERIC_WRITE: + urlace.Rights = Http.UrlAce.RightsType.@delegate; + break; + } + + string reservationId = (string)row[1]; + Http.UrlReservation urlReservation = (Http.UrlReservation)this.Core.GetIndexedElement("WixHttpUrlReservation", reservationId); + if (null != urlReservation) + { + urlReservation.AddChild(urlace); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, urlace.Id, "WixHttpUrlReservation_", reservationId, "WixHttpUrlReservation")); + } + } + } + } +#endif +} diff --git a/src/ext/Http/wixext/HttpErrors.cs b/src/ext/Http/wixext/HttpErrors.cs new file mode 100644 index 00000000..e87adf54 --- /dev/null +++ b/src/ext/Http/wixext/HttpErrors.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using System; + using System.Resources; + using WixToolset.Data; + + public static class HttpErrors + { + public static Message NoSecuritySpecified(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.NoSecuritySpecified, "The UrlReservation element doesn't identify the security for the reservation. You must either specify the Sddl attribute, or provide child UrlAce elements."); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + NoSecuritySpecified = 6701, + } + } +} diff --git a/src/ext/Http/wixext/HttpExtensionData.cs b/src/ext/Http/wixext/HttpExtensionData.cs new file mode 100644 index 00000000..04e3dcee --- /dev/null +++ b/src/ext/Http/wixext/HttpExtensionData.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The WiX Toolset Http Extension. + /// + public sealed class HttpExtensionData : BaseExtensionData + { + /// + /// Gets the default culture. + /// + /// The default culture. + public override string DefaultCulture => "en-US"; + + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) + { + symbolDefinition = HttpSymbolDefinitions.ByName(name); + return symbolDefinition != null; + } + + public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) + { + return Intermediate.Load(typeof(HttpExtensionData).Assembly, "WixToolset.Http.http.wixlib", symbolDefinitions); + } + } +} diff --git a/src/ext/Http/wixext/HttpExtensionFactory.cs b/src/ext/Http/wixext/HttpExtensionFactory.cs new file mode 100644 index 00000000..ad7d84d0 --- /dev/null +++ b/src/ext/Http/wixext/HttpExtensionFactory.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class HttpExtensionFactory : BaseExtensionFactory + { + protected override IReadOnlyCollection ExtensionTypes => new[] + { + typeof(HttpCompiler), + typeof(HttpExtensionData), + typeof(HttpWindowsInstallerBackendBinderExtension), + }; + } +} diff --git a/src/ext/Http/wixext/HttpTableDefinitions.cs b/src/ext/Http/wixext/HttpTableDefinitions.cs new file mode 100644 index 00000000..431b9a33 --- /dev/null +++ b/src/ext/Http/wixext/HttpTableDefinitions.cs @@ -0,0 +1,60 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using WixToolset.Data.WindowsInstaller; + + public static class HttpTableDefinitions + { + public static readonly TableDefinition WixHttpSniSslCert = new TableDefinition( + "Wix4HttpSniSslCert", + HttpSymbolDefinitions.WixHttpSniSslCert, + new[] + { + new ColumnDefinition("Wix4HttpSniSslCert", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Host", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Host for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Port for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Thumbprint", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "humbprint of the SNI SSL certificate to find.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("AppId", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Optional application id for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Store", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Optional application id for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("HandleExisting", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 2, description: "The behavior when trying to install a SNI SSL certificate and it already exists."), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing the component that controls the URL reservation.", modularizeType: ColumnModularizeType.Column), + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition WixHttpUrlReservation = new TableDefinition( + "Wix4HttpUrlReservation", + HttpSymbolDefinitions.WixHttpUrlReservation, + new[] + { + new ColumnDefinition("Wix4HttpUrlReservation", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("HandleExisting", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 2, description: "The behavior when trying to install a URL reservation and it already exists."), + new ColumnDefinition("Sddl", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Security descriptor for the URL reservation.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Url", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "URL to be reserved.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing the component that controls the URL reservation.", modularizeType: ColumnModularizeType.Column), + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition WixHttpUrlAce = new TableDefinition( + "Wix4HttpUrlAce", + HttpSymbolDefinitions.WixHttpUrlAce, + new[] + { + new ColumnDefinition("Wix4HttpUrlAce", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("WixHttpUrlReservation_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "WixHttpUrlReservation", keyColumn: 1, description: "Foreign key into the WixHttpUrlReservation table.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SecurityPrincipal", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "The security principal for this ACE.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Rights", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 1073741824, description: "The rights for this ACE."), + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition[] All = new[] + { + WixHttpSniSslCert, + WixHttpUrlReservation, + WixHttpUrlAce, + }; + } +} diff --git a/src/ext/Http/wixext/HttpWindowsInstallerBackendBinderExtension.cs b/src/ext/Http/wixext/HttpWindowsInstallerBackendBinderExtension.cs new file mode 100644 index 00000000..8e4f1a96 --- /dev/null +++ b/src/ext/Http/wixext/HttpWindowsInstallerBackendBinderExtension.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using System.Collections.Generic; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility; + + public class HttpWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + public override IReadOnlyCollection TableDefinitions => HttpTableDefinitions.All; + } +} diff --git a/src/ext/Http/wixext/Symbols/HandleExisting.cs b/src/ext/Http/wixext/Symbols/HandleExisting.cs new file mode 100644 index 00000000..0d70cebc --- /dev/null +++ b/src/ext/Http/wixext/Symbols/HandleExisting.cs @@ -0,0 +1,14 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http.Symbols +{ + /// + /// Must match constants in wixhttpca.cpp + /// + public enum HandleExisting + { + Replace = 0, + Ignore = 1, + Fail = 2, + } +} diff --git a/src/ext/Http/wixext/Symbols/HttpSymbolDefinitions.cs b/src/ext/Http/wixext/Symbols/HttpSymbolDefinitions.cs new file mode 100644 index 00000000..2aa03468 --- /dev/null +++ b/src/ext/Http/wixext/Symbols/HttpSymbolDefinitions.cs @@ -0,0 +1,47 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using System; + using WixToolset.Data; + + public enum HttpSymbolDefinitionType + { + WixHttpSniSslCert, + WixHttpUrlAce, + WixHttpUrlReservation, + } + + public static partial class HttpSymbolDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateSymbolDefinition ByName(string name) + { + if (!Enum.TryParse(name, out HttpSymbolDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateSymbolDefinition ByType(HttpSymbolDefinitionType type) + { + switch (type) + { + case HttpSymbolDefinitionType.WixHttpSniSslCert: + return HttpSymbolDefinitions.WixHttpSniSslCert; + + case HttpSymbolDefinitionType.WixHttpUrlAce: + return HttpSymbolDefinitions.WixHttpUrlAce; + + case HttpSymbolDefinitionType.WixHttpUrlReservation: + return HttpSymbolDefinitions.WixHttpUrlReservation; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/ext/Http/wixext/Symbols/WixHttpSniSslCertSymbol.cs b/src/ext/Http/wixext/Symbols/WixHttpSniSslCertSymbol.cs new file mode 100644 index 00000000..ec67a089 --- /dev/null +++ b/src/ext/Http/wixext/Symbols/WixHttpSniSslCertSymbol.cs @@ -0,0 +1,95 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using WixToolset.Data; + using WixToolset.Http.Symbols; + + public static partial class HttpSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition WixHttpSniSslCert = new IntermediateSymbolDefinition( + HttpSymbolDefinitionType.WixHttpSniSslCert.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Host), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Port), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Thumbprint), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.AppId), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Store), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.HandleExisting), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.ComponentRef), IntermediateFieldType.String), + }, + typeof(WixHttpSniSslCertSymbol)); + } +} + +namespace WixToolset.Http.Symbols +{ + using WixToolset.Data; + + public enum WixHttpSniSslCertSymbolFields + { + Host, + Port, + Thumbprint, + AppId, + Store, + HandleExisting, + ComponentRef, + } + + public class WixHttpSniSslCertSymbol : IntermediateSymbol + { + public WixHttpSniSslCertSymbol() : base(HttpSymbolDefinitions.WixHttpSniSslCert, null, null) + { + } + + public WixHttpSniSslCertSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(HttpSymbolDefinitions.WixHttpSniSslCert, sourceLineNumber, id) + { + } + + public IntermediateField this[WixHttpSniSslCertSymbolFields index] => this.Fields[(int)index]; + + public string Host + { + get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Host].AsString(); + set => this.Set((int)WixHttpSniSslCertSymbolFields.Host, value); + } + + public string Port + { + get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Port].AsString(); + set => this.Set((int)WixHttpSniSslCertSymbolFields.Port, value); + } + + public string Thumbprint + { + get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Thumbprint].AsString(); + set => this.Set((int)WixHttpSniSslCertSymbolFields.Thumbprint, value); + } + + public string AppId + { + get => this.Fields[(int)WixHttpSniSslCertSymbolFields.AppId].AsString(); + set => this.Set((int)WixHttpSniSslCertSymbolFields.AppId, value); + } + + public string Store + { + get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Store].AsString(); + set => this.Set((int)WixHttpSniSslCertSymbolFields.Store, value); + } + + public HandleExisting HandleExisting + { + get => (HandleExisting)this.Fields[(int)WixHttpSniSslCertSymbolFields.HandleExisting].AsNumber(); + set => this.Set((int)WixHttpSniSslCertSymbolFields.HandleExisting, (int)value); + } + + public string ComponentRef + { + get => this.Fields[(int)WixHttpSniSslCertSymbolFields.ComponentRef].AsString(); + set => this.Set((int)WixHttpSniSslCertSymbolFields.ComponentRef, value); + } + } +} diff --git a/src/ext/Http/wixext/Symbols/WixHttpUrlAceSymbol.cs b/src/ext/Http/wixext/Symbols/WixHttpUrlAceSymbol.cs new file mode 100644 index 00000000..1d57bd52 --- /dev/null +++ b/src/ext/Http/wixext/Symbols/WixHttpUrlAceSymbol.cs @@ -0,0 +1,63 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using WixToolset.Data; + using WixToolset.Http.Symbols; + + public static partial class HttpSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition WixHttpUrlAce = new IntermediateSymbolDefinition( + HttpSymbolDefinitionType.WixHttpUrlAce.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixHttpUrlAceSymbolFields.WixHttpUrlReservationRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpUrlAceSymbolFields.SecurityPrincipal), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpUrlAceSymbolFields.Rights), IntermediateFieldType.Number), + }, + typeof(WixHttpUrlAceSymbol)); + } +} + +namespace WixToolset.Http.Symbols +{ + using WixToolset.Data; + + public enum WixHttpUrlAceSymbolFields + { + WixHttpUrlReservationRef, + SecurityPrincipal, + Rights, + } + + public class WixHttpUrlAceSymbol : IntermediateSymbol + { + public WixHttpUrlAceSymbol() : base(HttpSymbolDefinitions.WixHttpUrlAce, null, null) + { + } + + public WixHttpUrlAceSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(HttpSymbolDefinitions.WixHttpUrlAce, sourceLineNumber, id) + { + } + + public IntermediateField this[WixHttpUrlAceSymbolFields index] => this.Fields[(int)index]; + + public string WixHttpUrlReservationRef + { + get => this.Fields[(int)WixHttpUrlAceSymbolFields.WixHttpUrlReservationRef].AsString(); + set => this.Set((int)WixHttpUrlAceSymbolFields.WixHttpUrlReservationRef, value); + } + + public string SecurityPrincipal + { + get => this.Fields[(int)WixHttpUrlAceSymbolFields.SecurityPrincipal].AsString(); + set => this.Set((int)WixHttpUrlAceSymbolFields.SecurityPrincipal, value); + } + + public int Rights + { + get => this.Fields[(int)WixHttpUrlAceSymbolFields.Rights].AsNumber(); + set => this.Set((int)WixHttpUrlAceSymbolFields.Rights, value); + } + } +} \ No newline at end of file diff --git a/src/ext/Http/wixext/Symbols/WixHttpUrlReservationSymbol.cs b/src/ext/Http/wixext/Symbols/WixHttpUrlReservationSymbol.cs new file mode 100644 index 00000000..4aa4a5da --- /dev/null +++ b/src/ext/Http/wixext/Symbols/WixHttpUrlReservationSymbol.cs @@ -0,0 +1,71 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Http +{ + using WixToolset.Data; + using WixToolset.Http.Symbols; + + public static partial class HttpSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition WixHttpUrlReservation = new IntermediateSymbolDefinition( + HttpSymbolDefinitionType.WixHttpUrlReservation.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixHttpUrlReservationSymbolFields.HandleExisting), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixHttpUrlReservationSymbolFields.Sddl), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpUrlReservationSymbolFields.Url), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixHttpUrlReservationSymbolFields.ComponentRef), IntermediateFieldType.String), + }, + typeof(WixHttpUrlReservationSymbol)); + } +} + +namespace WixToolset.Http.Symbols +{ + using WixToolset.Data; + + public enum WixHttpUrlReservationSymbolFields + { + HandleExisting, + Sddl, + Url, + ComponentRef, + } + + public class WixHttpUrlReservationSymbol : IntermediateSymbol + { + public WixHttpUrlReservationSymbol() : base(HttpSymbolDefinitions.WixHttpUrlReservation, null, null) + { + } + + public WixHttpUrlReservationSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(HttpSymbolDefinitions.WixHttpUrlReservation, sourceLineNumber, id) + { + } + + public IntermediateField this[WixHttpUrlReservationSymbolFields index] => this.Fields[(int)index]; + + public HandleExisting HandleExisting + { + get => (HandleExisting)this.Fields[(int)WixHttpUrlReservationSymbolFields.HandleExisting].AsNumber(); + set => this.Set((int)WixHttpUrlReservationSymbolFields.HandleExisting, (int)value); + } + + public string Sddl + { + get => this.Fields[(int)WixHttpUrlReservationSymbolFields.Sddl].AsString(); + set => this.Set((int)WixHttpUrlReservationSymbolFields.Sddl, value); + } + + public string Url + { + get => this.Fields[(int)WixHttpUrlReservationSymbolFields.Url].AsString(); + set => this.Set((int)WixHttpUrlReservationSymbolFields.Url, value); + } + + public string ComponentRef + { + get => this.Fields[(int)WixHttpUrlReservationSymbolFields.ComponentRef].AsString(); + set => this.Set((int)WixHttpUrlReservationSymbolFields.ComponentRef, value); + } + } +} \ No newline at end of file diff --git a/src/ext/Http/wixext/WixToolset.Http.wixext.csproj b/src/ext/Http/wixext/WixToolset.Http.wixext.csproj new file mode 100644 index 00000000..089a51d0 --- /dev/null +++ b/src/ext/Http/wixext/WixToolset.Http.wixext.csproj @@ -0,0 +1,31 @@ + + + + + + netstandard2.0 + WixToolset.Http + WiX Toolset Http Extension + WiX Toolset Http Extension + true + build + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Http/wixext/WixToolset.Http.wixext.targets b/src/ext/Http/wixext/WixToolset.Http.wixext.targets new file mode 100644 index 00000000..254b0010 --- /dev/null +++ b/src/ext/Http/wixext/WixToolset.Http.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.Http.wixext.dll + + + + + diff --git a/src/ext/Http/wixlib/HttpExtension.wxs b/src/ext/Http/wixlib/HttpExtension.wxs new file mode 100644 index 00000000..e9717fc1 --- /dev/null +++ b/src/ext/Http/wixlib/HttpExtension.wxs @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/ext/Http/wixlib/HttpExtension_Platform.wxi b/src/ext/Http/wixlib/HttpExtension_Platform.wxi new file mode 100644 index 00000000..4f4a9e23 --- /dev/null +++ b/src/ext/Http/wixlib/HttpExtension_Platform.wxi @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Http/wixlib/HttpExtension_arm64.wxs b/src/ext/Http/wixlib/HttpExtension_arm64.wxs new file mode 100644 index 00000000..3c69a644 --- /dev/null +++ b/src/ext/Http/wixlib/HttpExtension_arm64.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Http/wixlib/HttpExtension_x64.wxs b/src/ext/Http/wixlib/HttpExtension_x64.wxs new file mode 100644 index 00000000..f66f0d6f --- /dev/null +++ b/src/ext/Http/wixlib/HttpExtension_x64.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Http/wixlib/HttpExtension_x86.wxs b/src/ext/Http/wixlib/HttpExtension_x86.wxs new file mode 100644 index 00000000..f76df25f --- /dev/null +++ b/src/ext/Http/wixlib/HttpExtension_x86.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Http/wixlib/caDecor.wxi b/src/ext/Http/wixlib/caDecor.wxi new file mode 100644 index 00000000..b1711518 --- /dev/null +++ b/src/ext/Http/wixlib/caDecor.wxi @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Http/wixlib/caerr.wxi b/src/ext/Http/wixlib/caerr.wxi new file mode 100644 index 00000000..ff7ec121 --- /dev/null +++ b/src/ext/Http/wixlib/caerr.wxi @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Http/wixlib/en-us.wxl b/src/ext/Http/wixlib/en-us.wxl new file mode 100644 index 00000000..22d74f78 --- /dev/null +++ b/src/ext/Http/wixlib/en-us.wxl @@ -0,0 +1,17 @@ + + + + Preparing to configure Windows HTTP Server + Preparing to configure Windows HTTP Server + Rolling back Windows HTTP Server configuration + Configuring Windows HTTP Server + Rolling back Windows HTTP Server configuration + Configuring Windows HTTP Server + + Preparing to configure Windows HTTP Server SSL + Preparing to configure Windows HTTP Server SSL + Rolling back Windows HTTP Server SSL configuration + Configuring Windows HTTP Server SSL + Rolling back Windows HTTP Server SSL configuration + Configuring Windows HTTP Server SSL + diff --git a/src/ext/Http/wixlib/http.wixproj b/src/ext/Http/wixlib/http.wixproj new file mode 100644 index 00000000..999b7334 --- /dev/null +++ b/src/ext/Http/wixlib/http.wixproj @@ -0,0 +1,24 @@ + + + + Library + true + en-us + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/global.json b/src/ext/global.json new file mode 100644 index 00000000..23dd3fa6 --- /dev/null +++ b/src/ext/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "WixToolset.Sdk": "4.0.0-build-0211" + } +} diff --git a/src/test/WixToolsetTest.Http/HttpExtensionFixture.cs b/src/test/WixToolsetTest.Http/HttpExtensionFixture.cs deleted file mode 100644 index 40b49327..00000000 --- a/src/test/WixToolsetTest.Http/HttpExtensionFixture.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolsetTest.Http -{ - using WixBuildTools.TestSupport; - using WixToolset.Core.TestPackage; - using WixToolset.Http; - using Xunit; - - public class HttpExtensionFixture - { - [Fact] - public void CanBuildUsingSniSssl() - { - var folder = TestData.Get("TestData", "SniSsl"); - var build = new Builder(folder, typeof(HttpExtensionFactory), new[] { folder }); - - var results = build.BuildAndQuery(Build, "CustomAction", "Wix4HttpSniSslCert"); - WixAssert.CompareLineByLine(new[] - { - "CustomAction:Wix4ExecHttpSniSslCertsInstall_X86\t3073\tWix4HttpCA_X86\tExecHttpSniSslCerts\t", - "CustomAction:Wix4ExecHttpSniSslCertsUninstall_X86\t3073\tWix4HttpCA_X86\tExecHttpSniSslCerts\t", - "CustomAction:Wix4RollbackHttpSniSslCertsInstall_X86\t3329\tWix4HttpCA_X86\tExecHttpSniSslCerts\t", - "CustomAction:Wix4RollbackHttpSniSslCertsUninstall_X86\t3329\tWix4HttpCA_X86\tExecHttpSniSslCerts\t", - "CustomAction:Wix4SchedHttpSniSslCertsInstall_X86\t1\tWix4HttpCA_X86\tSchedHttpSniSslCertsInstall\t", - "CustomAction:Wix4SchedHttpSniSslCertsUninstall_X86\t1\tWix4HttpCA_X86\tSchedHttpSniSslCertsUninstall\t", - "Wix4HttpSniSslCert:sslC9YX6_H7UL_WGBx4DoDGI.Sj.D0\texample.com\t8080\t[SOME_THUMBPRINT]\t\t\t2\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo", - }, results); - } - - [Fact] - public void CanBuildUsingUrlReservation() - { - var folder = TestData.Get(@"TestData\UsingUrlReservation"); - var build = new Builder(folder, typeof(HttpExtensionFactory), new[] { folder }); - - var results = build.BuildAndQuery(Build, "CustomAction", "Wix4HttpUrlAce", "Wix4HttpUrlReservation"); - WixAssert.CompareLineByLine(new[] - { - "CustomAction:Wix4ExecHttpUrlReservationsInstall_X86\t3073\tWix4HttpCA_X86\tExecHttpUrlReservations\t", - "CustomAction:Wix4ExecHttpUrlReservationsUninstall_X86\t3073\tWix4HttpCA_X86\tExecHttpUrlReservations\t", - "CustomAction:Wix4RollbackHttpUrlReservationsInstall_X86\t3329\tWix4HttpCA_X86\tExecHttpUrlReservations\t", - "CustomAction:Wix4RollbackHttpUrlReservationsUninstall_X86\t3329\tWix4HttpCA_X86\tExecHttpUrlReservations\t", - "CustomAction:Wix4SchedHttpUrlReservationsInstall_X86\t1\tWix4HttpCA_X86\tSchedHttpUrlReservationsInstall\t", - "CustomAction:Wix4SchedHttpUrlReservationsUninstall_X86\t1\tWix4HttpCA_X86\tSchedHttpUrlReservationsUninstall\t", - "Wix4HttpUrlAce:aceu5os2gQoblRmzwjt85LQf997uD4\turlO23FkY2xzEY54lY6E6sXFW6glXc\tNT SERVICE\\TestService\t268435456", - "Wix4HttpUrlReservation:urlO23FkY2xzEY54lY6E6sXFW6glXc\t0\t\thttp://+:80/vroot/\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo", - }, results); - } - - private static void Build(string[] args) - { - var result = WixRunner.Execute(args) - .AssertSuccess(); - } - } -} diff --git a/src/test/WixToolsetTest.Http/TestData/SniSsl/Package.en-us.wxl b/src/test/WixToolsetTest.Http/TestData/SniSsl/Package.en-us.wxl deleted file mode 100644 index 38c12ac1..00000000 --- a/src/test/WixToolsetTest.Http/TestData/SniSsl/Package.en-us.wxl +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - A newer version of [ProductName] is already installed. - MsiPackage - - diff --git a/src/test/WixToolsetTest.Http/TestData/SniSsl/Package.wxs b/src/test/WixToolsetTest.Http/TestData/SniSsl/Package.wxs deleted file mode 100644 index c85e9bba..00000000 --- a/src/test/WixToolsetTest.Http/TestData/SniSsl/Package.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Http/TestData/SniSsl/PackageComponents.wxs b/src/test/WixToolsetTest.Http/TestData/SniSsl/PackageComponents.wxs deleted file mode 100644 index f0aae485..00000000 --- a/src/test/WixToolsetTest.Http/TestData/SniSsl/PackageComponents.wxs +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Http/TestData/SniSsl/example.txt b/src/test/WixToolsetTest.Http/TestData/SniSsl/example.txt deleted file mode 100644 index 1b4ffe8a..00000000 --- a/src/test/WixToolsetTest.Http/TestData/SniSsl/example.txt +++ /dev/null @@ -1 +0,0 @@ -This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.en-us.wxl b/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.en-us.wxl deleted file mode 100644 index 38c12ac1..00000000 --- a/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.en-us.wxl +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - A newer version of [ProductName] is already installed. - MsiPackage - - diff --git a/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.wxs b/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.wxs deleted file mode 100644 index bd31e81f..00000000 --- a/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/Package.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/PackageComponents.wxs b/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/PackageComponents.wxs deleted file mode 100644 index 780d598b..00000000 --- a/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/PackageComponents.wxs +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/example.txt b/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/example.txt deleted file mode 100644 index 1b4ffe8a..00000000 --- a/src/test/WixToolsetTest.Http/TestData/UsingUrlReservation/example.txt +++ /dev/null @@ -1 +0,0 @@ -This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Http/WixToolsetTest.Http.csproj b/src/test/WixToolsetTest.Http/WixToolsetTest.Http.csproj deleted file mode 100644 index 7e60e426..00000000 --- a/src/test/WixToolsetTest.Http/WixToolsetTest.Http.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - netcoreapp3.1 - false - - - - NU1701 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/version.json b/src/version.json new file mode 100644 index 00000000..5f857771 --- /dev/null +++ b/src/version.json @@ -0,0 +1,11 @@ +{ + "version": "4.0", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} diff --git a/src/wix.snk b/src/wix.snk deleted file mode 100644 index 3908a66a..00000000 Binary files a/src/wix.snk and /dev/null differ diff --git a/src/wixext/HttpCompiler.cs b/src/wixext/HttpCompiler.cs deleted file mode 100644 index 6c572470..00000000 --- a/src/wixext/HttpCompiler.cs +++ /dev/null @@ -1,383 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using System; - using System.Collections.Generic; - using System.Xml.Linq; - using WixToolset.Data; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Data; - using WixToolset.Http.Symbols; - - /// - /// The compiler for the WiX Toolset Http Extension. - /// - public sealed class HttpCompiler : BaseCompilerExtension - { - public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/http"; - - /// - /// Processes an element for the Compiler. - /// - /// Source line number for the parent element. - /// Parent element of element to process. - /// Element to process. - /// Extra information about the context in which this element is being parsed. - public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) - { - switch (parentElement.Name.LocalName) - { - case "ServiceInstall": - var serviceInstallName = context["ServiceInstallName"]; - var serviceUser = String.IsNullOrEmpty(serviceInstallName) ? null : String.Concat("NT SERVICE\\", serviceInstallName); - var serviceComponentId = context["ServiceInstallComponentId"]; - - switch (element.Name.LocalName) - { - case "UrlReservation": - this.ParseUrlReservationElement(intermediate, section, element, serviceComponentId, serviceUser); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - break; - case "Component": - string componentId = context["ComponentId"]; - - switch (element.Name.LocalName) - { - case "SniSslCertificate": - this.ParseSniSslCertificateElement(intermediate, section, element, componentId); - break; - - case "UrlReservation": - this.ParseUrlReservationElement(intermediate, section, element, componentId, null); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - } - - /// - /// Parses a SniSsl element. - /// - /// The element to parse. - /// Identifier of the component that owns this SNI SSL Certificate. - private void ParseSniSslCertificateElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); - Identifier id = null; - string host = null; - string port = null; - string appId = null; - string store = null; - string thumbprint = null; - var handleExisting = HandleExisting.Replace; - string handleExistingValue = null; - - foreach (var attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "AppId": - appId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "HandleExisting": - handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - switch (handleExistingValue) - { - case "replace": - handleExisting = HandleExisting.Replace; - break; - case "ignore": - handleExisting = HandleExisting.Ignore; - break; - case "fail": - handleExisting = HandleExisting.Fail; - break; - default: - this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail")); - break; - } - break; - case "Host": - host = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Port": - port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Store": - store = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Thumbprint": - thumbprint = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.ParseHelper.UnexpectedAttribute(node, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); - } - } - - // Need the element ID for child element processing, so generate now if not authored. - if (null == id) - { - id = this.ParseHelper.CreateIdentifier("ssl", componentId, host, port); - } - - // Required attributes. - if (null == host) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Host")); - } - - if (null == port) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Port")); - } - - if (null == thumbprint) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Thumbprint")); - } - - // Parse unknown children. - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - - if (!this.Messaging.EncounteredError) - { - section.AddSymbol(new WixHttpSniSslCertSymbol(sourceLineNumbers, id) - { - Host = host, - Port = port, - Thumbprint = thumbprint, - AppId = appId, - Store = store, - HandleExisting = handleExisting, - ComponentRef = componentId, - }); - - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpSniSslCertsInstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpSniSslCertsUninstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); - } - } - - /// - /// Parses a UrlReservation element. - /// - /// The element to parse. - /// Identifier of the component that owns this URL reservation. - /// The security principal of the parent element (null if nested under Component). - private void ParseUrlReservationElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string securityPrincipal) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); - Identifier id = null; - var handleExisting = HandleExisting.Replace; - string sddl = null; - string url = null; - var foundACE = false; - - foreach (var attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "HandleExisting": - var handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - switch (handleExistingValue) - { - case "replace": - handleExisting = HandleExisting.Replace; - break; - case "ignore": - handleExisting = HandleExisting.Ignore; - break; - case "fail": - handleExisting = HandleExisting.Fail; - break; - default: - this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail")); - break; - } - break; - case "Sddl": - sddl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Url": - url = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.ParseHelper.UnexpectedAttribute(node, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); - } - } - - // Need the element ID for child element processing, so generate now if not authored. - if (null == id) - { - id = this.ParseHelper.CreateIdentifier("url", componentId, securityPrincipal, url); - } - - // Parse UrlAce children. - foreach (var child in node.Elements()) - { - if (this.Namespace == child.Name.Namespace) - { - switch (child.Name.LocalName) - { - case "UrlAce": - if (null != sddl) - { - this.Messaging.Write(ErrorMessages.IllegalParentAttributeWhenNested(sourceLineNumbers, "UrlReservation", "Sddl", "UrlAce")); - } - else - { - foundACE = true; - this.ParseUrlAceElement(intermediate, section, child, id.Id, securityPrincipal); - } - break; - default: - this.ParseHelper.UnexpectedElement(node, child); - break; - } - } - else - { - this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); - } - } - - // Url is required. - if (null == url) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Url")); - } - - // Security is required. - if (null == sddl && !foundACE) - { - this.Messaging.Write(HttpErrors.NoSecuritySpecified(sourceLineNumbers)); - } - - if (!this.Messaging.EncounteredError) - { - section.AddSymbol(new WixHttpUrlReservationSymbol(sourceLineNumbers, id) - { - HandleExisting = handleExisting, - Sddl = sddl, - Url = url, - ComponentRef = componentId, - }); - - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpUrlReservationsInstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpUrlReservationsUninstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); - } - } - - /// - /// Parses a UrlAce element. - /// - /// The element to parse. - /// The URL reservation ID. - /// The default security principal. - private void ParseUrlAceElement(Intermediate intermediate, IntermediateSection section, XElement node, string urlReservationId, string defaultSecurityPrincipal) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); - Identifier id = null; - var securityPrincipal = defaultSecurityPrincipal; - var rights = HttpConstants.GENERIC_ALL; - string rightsValue = null; - - foreach (var attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "SecurityPrincipal": - securityPrincipal = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Rights": - rightsValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - switch (rightsValue) - { - case "all": - rights = HttpConstants.GENERIC_ALL; - break; - case "delegate": - rights = HttpConstants.GENERIC_WRITE; - break; - case "register": - rights = HttpConstants.GENERIC_EXECUTE; - break; - default: - this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Rights", rightsValue, "all", "delegate", "register")); - break; - } - break; - default: - this.ParseHelper.UnexpectedAttribute(node, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); - } - } - - // Generate Id now if not authored. - if (null == id) - { - id = this.ParseHelper.CreateIdentifier("ace", urlReservationId, securityPrincipal, rightsValue); - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - - // SecurityPrincipal is required. - if (null == securityPrincipal) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SecurityPrincipal")); - } - - if (!this.Messaging.EncounteredError) - { - section.AddSymbol(new WixHttpUrlAceSymbol(sourceLineNumbers, id) - { - WixHttpUrlReservationRef = urlReservationId, - SecurityPrincipal = securityPrincipal, - Rights = rights, - }); - } - } - } -} diff --git a/src/wixext/HttpConstants.cs b/src/wixext/HttpConstants.cs deleted file mode 100644 index 5fb42d86..00000000 --- a/src/wixext/HttpConstants.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using System; - - internal static class HttpConstants - { - // from winnt.h - public const int GENERIC_ALL = 0x10000000; - public const int GENERIC_EXECUTE = 0x20000000; - public const int GENERIC_WRITE = 0x40000000; - - } -} diff --git a/src/wixext/HttpDecompiler.cs b/src/wixext/HttpDecompiler.cs deleted file mode 100644 index 8991ec2f..00000000 --- a/src/wixext/HttpDecompiler.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ -#if TODO_CONSIDER_DECOMPILER - using System; - using System.Collections; - using System.Diagnostics; - using System.Globalization; - using WixToolset.Data; - using WixToolset.Extensibility; - using Http = WixToolset.Extensions.Serialize.Http; - using Wix = WixToolset.Data.Serialize; - - /// - /// The decompiler for the WiX Toolset Http Extension. - /// - public sealed class HttpDecompiler : DecompilerExtension - { - /// - /// Creates a decompiler for Http Extension. - /// - public HttpDecompiler() - { - this.TableDefinitions = HttpExtensionData.GetExtensionTableDefinitions(); - } - - /// - /// Get the extensions library to be removed. - /// - /// Table definitions for library. - /// Library to remove from decompiled output. - public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) - { - return HttpExtensionData.GetExtensionLibrary(tableDefinitions); - } - - /// - /// Decompiles an extension table. - /// - /// The table to decompile. - public override void DecompileTable(Table table) - { - switch (table.Name) - { - case "WixHttpUrlReservation": - this.DecompileWixHttpUrlReservationTable(table); - break; - case "WixHttpUrlAce": - this.DecompileWixHttpUrlAceTable(table); - break; - default: - base.DecompileTable(table); - break; - } - } - - /// - /// Decompile the WixHttpUrlReservation table. - /// - /// The table to decompile. - private void DecompileWixHttpUrlReservationTable(Table table) - { - foreach (Row row in table.Rows) - { - Http.UrlReservation urlReservation = new Http.UrlReservation(); - urlReservation.Id = (string)row[0]; - switch((int)row[1]) - { - case HttpConstants.heReplace: - default: - urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.replace; - break; - case HttpConstants.heIgnore: - urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.ignore; - break; - case HttpConstants.heFail: - urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.fail; - break; - } - urlReservation.Sddl = (string)row[2]; - urlReservation.Url = (string)row[3]; - - Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]); - if (null != component) - { - component.AddChild(urlReservation); - } - else - { - this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); - } - this.Core.IndexElement(row, urlReservation); - } - } - - - /// - /// Decompile the WixHttpUrlAce table. - /// - /// The table to decompile. - private void DecompileWixHttpUrlAceTable(Table table) - { - foreach (Row row in table.Rows) - { - Http.UrlAce urlace = new Http.UrlAce(); - urlace.Id = (string)row[0]; - urlace.SecurityPrincipal = (string)row[2]; - switch (Convert.ToInt32(row[3])) - { - case HttpConstants.GENERIC_ALL: - default: - urlace.Rights = Http.UrlAce.RightsType.all; - break; - case HttpConstants.GENERIC_EXECUTE: - urlace.Rights = Http.UrlAce.RightsType.register; - break; - case HttpConstants.GENERIC_WRITE: - urlace.Rights = Http.UrlAce.RightsType.@delegate; - break; - } - - string reservationId = (string)row[1]; - Http.UrlReservation urlReservation = (Http.UrlReservation)this.Core.GetIndexedElement("WixHttpUrlReservation", reservationId); - if (null != urlReservation) - { - urlReservation.AddChild(urlace); - } - else - { - this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, urlace.Id, "WixHttpUrlReservation_", reservationId, "WixHttpUrlReservation")); - } - } - } - } -#endif -} diff --git a/src/wixext/HttpErrors.cs b/src/wixext/HttpErrors.cs deleted file mode 100644 index e87adf54..00000000 --- a/src/wixext/HttpErrors.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using System; - using System.Resources; - using WixToolset.Data; - - public static class HttpErrors - { - public static Message NoSecuritySpecified(SourceLineNumber sourceLineNumbers) - { - return Message(sourceLineNumbers, Ids.NoSecuritySpecified, "The UrlReservation element doesn't identify the security for the reservation. You must either specify the Sddl attribute, or provide child UrlAce elements."); - } - - private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) - { - return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); - } - - private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) - { - return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); - } - - public enum Ids - { - NoSecuritySpecified = 6701, - } - } -} diff --git a/src/wixext/HttpExtensionData.cs b/src/wixext/HttpExtensionData.cs deleted file mode 100644 index 04e3dcee..00000000 --- a/src/wixext/HttpExtensionData.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using WixToolset.Data; - using WixToolset.Extensibility; - - /// - /// The WiX Toolset Http Extension. - /// - public sealed class HttpExtensionData : BaseExtensionData - { - /// - /// Gets the default culture. - /// - /// The default culture. - public override string DefaultCulture => "en-US"; - - public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) - { - symbolDefinition = HttpSymbolDefinitions.ByName(name); - return symbolDefinition != null; - } - - public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) - { - return Intermediate.Load(typeof(HttpExtensionData).Assembly, "WixToolset.Http.http.wixlib", symbolDefinitions); - } - } -} diff --git a/src/wixext/HttpExtensionFactory.cs b/src/wixext/HttpExtensionFactory.cs deleted file mode 100644 index ad7d84d0..00000000 --- a/src/wixext/HttpExtensionFactory.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using System; - using System.Collections.Generic; - using WixToolset.Extensibility; - - public class HttpExtensionFactory : BaseExtensionFactory - { - protected override IReadOnlyCollection ExtensionTypes => new[] - { - typeof(HttpCompiler), - typeof(HttpExtensionData), - typeof(HttpWindowsInstallerBackendBinderExtension), - }; - } -} diff --git a/src/wixext/HttpTableDefinitions.cs b/src/wixext/HttpTableDefinitions.cs deleted file mode 100644 index 431b9a33..00000000 --- a/src/wixext/HttpTableDefinitions.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using WixToolset.Data.WindowsInstaller; - - public static class HttpTableDefinitions - { - public static readonly TableDefinition WixHttpSniSslCert = new TableDefinition( - "Wix4HttpSniSslCert", - HttpSymbolDefinitions.WixHttpSniSslCert, - new[] - { - new ColumnDefinition("Wix4HttpSniSslCert", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Host", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Host for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Port for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Thumbprint", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "humbprint of the SNI SSL certificate to find.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("AppId", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Optional application id for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Store", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Optional application id for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("HandleExisting", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 2, description: "The behavior when trying to install a SNI SSL certificate and it already exists."), - new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing the component that controls the URL reservation.", modularizeType: ColumnModularizeType.Column), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition WixHttpUrlReservation = new TableDefinition( - "Wix4HttpUrlReservation", - HttpSymbolDefinitions.WixHttpUrlReservation, - new[] - { - new ColumnDefinition("Wix4HttpUrlReservation", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("HandleExisting", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 2, description: "The behavior when trying to install a URL reservation and it already exists."), - new ColumnDefinition("Sddl", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Security descriptor for the URL reservation.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Url", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "URL to be reserved.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing the component that controls the URL reservation.", modularizeType: ColumnModularizeType.Column), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition WixHttpUrlAce = new TableDefinition( - "Wix4HttpUrlAce", - HttpSymbolDefinitions.WixHttpUrlAce, - new[] - { - new ColumnDefinition("Wix4HttpUrlAce", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("WixHttpUrlReservation_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "WixHttpUrlReservation", keyColumn: 1, description: "Foreign key into the WixHttpUrlReservation table.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("SecurityPrincipal", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "The security principal for this ACE.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Rights", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 1073741824, description: "The rights for this ACE."), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition[] All = new[] - { - WixHttpSniSslCert, - WixHttpUrlReservation, - WixHttpUrlAce, - }; - } -} diff --git a/src/wixext/HttpWindowsInstallerBackendBinderExtension.cs b/src/wixext/HttpWindowsInstallerBackendBinderExtension.cs deleted file mode 100644 index 8e4f1a96..00000000 --- a/src/wixext/HttpWindowsInstallerBackendBinderExtension.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using System.Collections.Generic; - using WixToolset.Data.WindowsInstaller; - using WixToolset.Extensibility; - - public class HttpWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension - { - public override IReadOnlyCollection TableDefinitions => HttpTableDefinitions.All; - } -} diff --git a/src/wixext/Symbols/HandleExisting.cs b/src/wixext/Symbols/HandleExisting.cs deleted file mode 100644 index 0d70cebc..00000000 --- a/src/wixext/Symbols/HandleExisting.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http.Symbols -{ - /// - /// Must match constants in wixhttpca.cpp - /// - public enum HandleExisting - { - Replace = 0, - Ignore = 1, - Fail = 2, - } -} diff --git a/src/wixext/Symbols/HttpSymbolDefinitions.cs b/src/wixext/Symbols/HttpSymbolDefinitions.cs deleted file mode 100644 index 2aa03468..00000000 --- a/src/wixext/Symbols/HttpSymbolDefinitions.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using System; - using WixToolset.Data; - - public enum HttpSymbolDefinitionType - { - WixHttpSniSslCert, - WixHttpUrlAce, - WixHttpUrlReservation, - } - - public static partial class HttpSymbolDefinitions - { - public static readonly Version Version = new Version("4.0.0"); - - public static IntermediateSymbolDefinition ByName(string name) - { - if (!Enum.TryParse(name, out HttpSymbolDefinitionType type)) - { - return null; - } - - return ByType(type); - } - - public static IntermediateSymbolDefinition ByType(HttpSymbolDefinitionType type) - { - switch (type) - { - case HttpSymbolDefinitionType.WixHttpSniSslCert: - return HttpSymbolDefinitions.WixHttpSniSslCert; - - case HttpSymbolDefinitionType.WixHttpUrlAce: - return HttpSymbolDefinitions.WixHttpUrlAce; - - case HttpSymbolDefinitionType.WixHttpUrlReservation: - return HttpSymbolDefinitions.WixHttpUrlReservation; - - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } - } - } -} diff --git a/src/wixext/Symbols/WixHttpSniSslCertSymbol.cs b/src/wixext/Symbols/WixHttpSniSslCertSymbol.cs deleted file mode 100644 index ec67a089..00000000 --- a/src/wixext/Symbols/WixHttpSniSslCertSymbol.cs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using WixToolset.Data; - using WixToolset.Http.Symbols; - - public static partial class HttpSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition WixHttpSniSslCert = new IntermediateSymbolDefinition( - HttpSymbolDefinitionType.WixHttpSniSslCert.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Host), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Port), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Thumbprint), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.AppId), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Store), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.HandleExisting), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.ComponentRef), IntermediateFieldType.String), - }, - typeof(WixHttpSniSslCertSymbol)); - } -} - -namespace WixToolset.Http.Symbols -{ - using WixToolset.Data; - - public enum WixHttpSniSslCertSymbolFields - { - Host, - Port, - Thumbprint, - AppId, - Store, - HandleExisting, - ComponentRef, - } - - public class WixHttpSniSslCertSymbol : IntermediateSymbol - { - public WixHttpSniSslCertSymbol() : base(HttpSymbolDefinitions.WixHttpSniSslCert, null, null) - { - } - - public WixHttpSniSslCertSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(HttpSymbolDefinitions.WixHttpSniSslCert, sourceLineNumber, id) - { - } - - public IntermediateField this[WixHttpSniSslCertSymbolFields index] => this.Fields[(int)index]; - - public string Host - { - get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Host].AsString(); - set => this.Set((int)WixHttpSniSslCertSymbolFields.Host, value); - } - - public string Port - { - get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Port].AsString(); - set => this.Set((int)WixHttpSniSslCertSymbolFields.Port, value); - } - - public string Thumbprint - { - get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Thumbprint].AsString(); - set => this.Set((int)WixHttpSniSslCertSymbolFields.Thumbprint, value); - } - - public string AppId - { - get => this.Fields[(int)WixHttpSniSslCertSymbolFields.AppId].AsString(); - set => this.Set((int)WixHttpSniSslCertSymbolFields.AppId, value); - } - - public string Store - { - get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Store].AsString(); - set => this.Set((int)WixHttpSniSslCertSymbolFields.Store, value); - } - - public HandleExisting HandleExisting - { - get => (HandleExisting)this.Fields[(int)WixHttpSniSslCertSymbolFields.HandleExisting].AsNumber(); - set => this.Set((int)WixHttpSniSslCertSymbolFields.HandleExisting, (int)value); - } - - public string ComponentRef - { - get => this.Fields[(int)WixHttpSniSslCertSymbolFields.ComponentRef].AsString(); - set => this.Set((int)WixHttpSniSslCertSymbolFields.ComponentRef, value); - } - } -} diff --git a/src/wixext/Symbols/WixHttpUrlAceSymbol.cs b/src/wixext/Symbols/WixHttpUrlAceSymbol.cs deleted file mode 100644 index 1d57bd52..00000000 --- a/src/wixext/Symbols/WixHttpUrlAceSymbol.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using WixToolset.Data; - using WixToolset.Http.Symbols; - - public static partial class HttpSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition WixHttpUrlAce = new IntermediateSymbolDefinition( - HttpSymbolDefinitionType.WixHttpUrlAce.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(WixHttpUrlAceSymbolFields.WixHttpUrlReservationRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpUrlAceSymbolFields.SecurityPrincipal), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpUrlAceSymbolFields.Rights), IntermediateFieldType.Number), - }, - typeof(WixHttpUrlAceSymbol)); - } -} - -namespace WixToolset.Http.Symbols -{ - using WixToolset.Data; - - public enum WixHttpUrlAceSymbolFields - { - WixHttpUrlReservationRef, - SecurityPrincipal, - Rights, - } - - public class WixHttpUrlAceSymbol : IntermediateSymbol - { - public WixHttpUrlAceSymbol() : base(HttpSymbolDefinitions.WixHttpUrlAce, null, null) - { - } - - public WixHttpUrlAceSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(HttpSymbolDefinitions.WixHttpUrlAce, sourceLineNumber, id) - { - } - - public IntermediateField this[WixHttpUrlAceSymbolFields index] => this.Fields[(int)index]; - - public string WixHttpUrlReservationRef - { - get => this.Fields[(int)WixHttpUrlAceSymbolFields.WixHttpUrlReservationRef].AsString(); - set => this.Set((int)WixHttpUrlAceSymbolFields.WixHttpUrlReservationRef, value); - } - - public string SecurityPrincipal - { - get => this.Fields[(int)WixHttpUrlAceSymbolFields.SecurityPrincipal].AsString(); - set => this.Set((int)WixHttpUrlAceSymbolFields.SecurityPrincipal, value); - } - - public int Rights - { - get => this.Fields[(int)WixHttpUrlAceSymbolFields.Rights].AsNumber(); - set => this.Set((int)WixHttpUrlAceSymbolFields.Rights, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Symbols/WixHttpUrlReservationSymbol.cs b/src/wixext/Symbols/WixHttpUrlReservationSymbol.cs deleted file mode 100644 index 4aa4a5da..00000000 --- a/src/wixext/Symbols/WixHttpUrlReservationSymbol.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Http -{ - using WixToolset.Data; - using WixToolset.Http.Symbols; - - public static partial class HttpSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition WixHttpUrlReservation = new IntermediateSymbolDefinition( - HttpSymbolDefinitionType.WixHttpUrlReservation.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(WixHttpUrlReservationSymbolFields.HandleExisting), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixHttpUrlReservationSymbolFields.Sddl), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpUrlReservationSymbolFields.Url), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixHttpUrlReservationSymbolFields.ComponentRef), IntermediateFieldType.String), - }, - typeof(WixHttpUrlReservationSymbol)); - } -} - -namespace WixToolset.Http.Symbols -{ - using WixToolset.Data; - - public enum WixHttpUrlReservationSymbolFields - { - HandleExisting, - Sddl, - Url, - ComponentRef, - } - - public class WixHttpUrlReservationSymbol : IntermediateSymbol - { - public WixHttpUrlReservationSymbol() : base(HttpSymbolDefinitions.WixHttpUrlReservation, null, null) - { - } - - public WixHttpUrlReservationSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(HttpSymbolDefinitions.WixHttpUrlReservation, sourceLineNumber, id) - { - } - - public IntermediateField this[WixHttpUrlReservationSymbolFields index] => this.Fields[(int)index]; - - public HandleExisting HandleExisting - { - get => (HandleExisting)this.Fields[(int)WixHttpUrlReservationSymbolFields.HandleExisting].AsNumber(); - set => this.Set((int)WixHttpUrlReservationSymbolFields.HandleExisting, (int)value); - } - - public string Sddl - { - get => this.Fields[(int)WixHttpUrlReservationSymbolFields.Sddl].AsString(); - set => this.Set((int)WixHttpUrlReservationSymbolFields.Sddl, value); - } - - public string Url - { - get => this.Fields[(int)WixHttpUrlReservationSymbolFields.Url].AsString(); - set => this.Set((int)WixHttpUrlReservationSymbolFields.Url, value); - } - - public string ComponentRef - { - get => this.Fields[(int)WixHttpUrlReservationSymbolFields.ComponentRef].AsString(); - set => this.Set((int)WixHttpUrlReservationSymbolFields.ComponentRef, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/WixToolset.Http.wixext.csproj b/src/wixext/WixToolset.Http.wixext.csproj deleted file mode 100644 index 089a51d0..00000000 --- a/src/wixext/WixToolset.Http.wixext.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - netstandard2.0 - WixToolset.Http - WiX Toolset Http Extension - WiX Toolset Http Extension - true - build - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixext/WixToolset.Http.wixext.targets b/src/wixext/WixToolset.Http.wixext.targets deleted file mode 100644 index 254b0010..00000000 --- a/src/wixext/WixToolset.Http.wixext.targets +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\tools\WixToolset.Http.wixext.dll - - - - - diff --git a/src/wixlib/HttpExtension.wxs b/src/wixlib/HttpExtension.wxs deleted file mode 100644 index e9717fc1..00000000 --- a/src/wixlib/HttpExtension.wxs +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/wixlib/HttpExtension_Platform.wxi b/src/wixlib/HttpExtension_Platform.wxi deleted file mode 100644 index 4f4a9e23..00000000 --- a/src/wixlib/HttpExtension_Platform.wxi +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/HttpExtension_arm64.wxs b/src/wixlib/HttpExtension_arm64.wxs deleted file mode 100644 index 3c69a644..00000000 --- a/src/wixlib/HttpExtension_arm64.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/HttpExtension_x64.wxs b/src/wixlib/HttpExtension_x64.wxs deleted file mode 100644 index f66f0d6f..00000000 --- a/src/wixlib/HttpExtension_x64.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/HttpExtension_x86.wxs b/src/wixlib/HttpExtension_x86.wxs deleted file mode 100644 index f76df25f..00000000 --- a/src/wixlib/HttpExtension_x86.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/caDecor.wxi b/src/wixlib/caDecor.wxi deleted file mode 100644 index b1711518..00000000 --- a/src/wixlib/caDecor.wxi +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/caerr.wxi b/src/wixlib/caerr.wxi deleted file mode 100644 index ff7ec121..00000000 --- a/src/wixlib/caerr.wxi +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/wixlib/en-us.wxl b/src/wixlib/en-us.wxl deleted file mode 100644 index 22d74f78..00000000 --- a/src/wixlib/en-us.wxl +++ /dev/null @@ -1,17 +0,0 @@ - - - - Preparing to configure Windows HTTP Server - Preparing to configure Windows HTTP Server - Rolling back Windows HTTP Server configuration - Configuring Windows HTTP Server - Rolling back Windows HTTP Server configuration - Configuring Windows HTTP Server - - Preparing to configure Windows HTTP Server SSL - Preparing to configure Windows HTTP Server SSL - Rolling back Windows HTTP Server SSL configuration - Configuring Windows HTTP Server SSL - Rolling back Windows HTTP Server SSL configuration - Configuring Windows HTTP Server SSL - diff --git a/src/wixlib/http.wixproj b/src/wixlib/http.wixproj deleted file mode 100644 index 999b7334..00000000 --- a/src/wixlib/http.wixproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Library - true - en-us - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/version.json b/version.json deleted file mode 100644 index 5f857771..00000000 --- a/version.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "4.0", - "publicReleaseRefSpec": [ - "^refs/heads/master$" - ], - "cloudBuild": { - "buildNumber": { - "enabled": true - } - } -} -- cgit v1.2.3-55-g6feb