Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1ll authored and unknown committed Mar 27, 2014
1 parent 6d3eb87 commit f26556f
Show file tree
Hide file tree
Showing 12 changed files with 738 additions and 2 deletions.
63 changes: 63 additions & 0 deletions Installer/Installer.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.8</ProductVersion>
<ProjectGuid>{8a36cbc1-ddf7-4419-ad3f-f741f7df5a2f}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>iis_stripheaders_module_1.0.0_x64</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DefineConstants>Debug</DefineConstants>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NativeCodeModule\NativeCodeModule.vcxproj">
<Name>NativeCodeModule</Name>
<Project>{b697a6de-b20a-4dc3-90be-9d31de1d6bdf}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUtilExtension">
<HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
<Name>WixUtilExtension</Name>
</WixExtension>
</ItemGroup>
<ItemGroup>
<Content Include="stripHeaders_schema.xml" />
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
112 changes: 112 additions & 0 deletions Installer/Product.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="CAAD1749-4F20-4572-A771-0312B9D21678" Name="IIS StripHeaders module" Language="1033" Version="1.0.0.0" Manufacturer="Dionach Ltd" UpgradeCode="FDFC59AA-E51F-4394-B9AA-5DA92C84A2ED">
<Package Id="461D0767-054B-4EFA-BB53-6B8E12C556B2" Description="IIS StripHeaders module installer" InstallerVersion="200" Languages="1033" SummaryCodepage="1252" Compressed="yes" InstallScope="perMachine" />
<!-- Prevent downgrades -->
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!-- Make sure installer is built as a single msi -->
<MediaTemplate EmbedCab="yes" />
<!-- Prevent restart manager or the files in use dialog being displayed on uninstall -->
<Property Id="MSIRESTARTMANAGERCONTROL" Value="Disable"/>
<!-- Ensure OS is high enough to support IIS 7.0 and above -->
<Condition Message="This module is only supported on Windows Vista, Windows Server 2008, or higher.">
<![CDATA[Installed OR (VersionNT >= 600)]]>
</Condition>
<!-- Ensure operating system is 64bit -->
<Condition Message="You are attempting to run the 64-bit installer on a 32-bit version of Windows.">
<![CDATA[Msix64]]>
</Condition>
<!-- Ensure IIS is installed -->
<Property Id="IISVERSION">
<DirectorySearch Id="IISVersion" Path="[SystemFolder]\inetsrv">
<FileSearch Name="w3wp.exe" MinVersion="7.0"/>
</DirectorySearch>
</Property>
<Condition Message="This module is only supported on systems running IIS 7.0 or above.">
<![CDATA[Installed OR IISVERSION]]>
</Condition>
<!-- Ensure appcmd is available to install and remove modules -->
<Property Id="APPCMDVERSION">
<DirectorySearch Id="APPCMDVersion" Path="[SystemFolder]\inetsrv">
<FileSearch Name="appcmd.exe" MinVersion="7.0"/>
</DirectorySearch>
</Property>
<Condition Message="This module requires the IIS appcmd.exe command line tool in order to enable the module.">
<![CDATA[Installed OR APPCMDVERSION]]>
</Condition>
<!-- Define the directory structure -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="System64Folder">
<Directory Id="INETSRVDIR" Name="inetsrv">
<Directory Id="CONFIGDIR" Name="config">
<Directory Id="SCHEMADIR" Name="schema"/>
</Directory>
</Directory>
</Directory>
</Directory>
<!-- Add files and registry values -->
<DirectoryRef Id="INETSRVDIR">
<!-- Add the stripheaders.dll module -->
<Component Id="stripheaders.dll" Guid="4BBF0D80-2CE8-4EC3-BDDD-93786BE2258C">
<File Source="$(var.NativeCodeModule.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<!-- Add the registry key to disbale the Microsoft-HTTPAPI Server header -->
<Component Id="HTTPAPIHeaderRegistryEntry" Guid="18C15683-E20E-4C6E-B4BC-2770F68D54DE">
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\services\HTTP\Parameters">
<RegistryValue Type="integer" Name="DisableServerHeader" Value="1" KeyPath="yes"/>
</RegistryKey>
</Component>
</DirectoryRef>
<DirectoryRef Id="SCHEMADIR">
<!-- Add the stripHeaders custom IIS schema for configuration -->
<Component Id="stripHeaders_schema.xml" Guid="3AA6B36D-4028-4F68-90CD-BF881235590D">
<File Source="stripHeaders_schema.xml" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="CONFIGDIR">
<!-- Add configuration to applicationHost.config -->
<Component Id="APPLICATIONHOSTXML" Guid="E08C1CC0-7657-4E13-A7B9-A4A906F43586">
<!-- A fake folder is required to allow the installer to build this component -->
<CreateFolder/>
<!-- Create the "section" element in the system.webserver node to register the custom stripHeaders schema -->
<util:XmlConfig Id="AddSectionElement" File="[CONFIGDIR]\applicationHost.config" Action="create" Node="element" ElementPath="configuration/configSections/sectionGroup[\[]@name='system.webServer'[\]]" Name="section" On="install" Sequence="1001" />
<!-- Add necessary attributes to the "section" element -->
<util:XmlConfig Id="AddSectionName" File="[CONFIGDIR]\applicationHost.config" ElementId="AddSectionElement" Name="name" Value="stripHeaders" Sequence="1002" />
<util:XmlConfig Id="AddSectionAppHostOnly" File="[CONFIGDIR]\applicationHost.config" ElementId="AddSectionElement" Name="allowDefinition" Value="AppHostOnly" Sequence="1003" />
<util:XmlConfig Id="AddSectionoverrideModeDefault" File="[CONFIGDIR]\applicationHost.config" ElementId="AddSectionElement" Name="overrideModeDefault" Value="Deny" Sequence="1004" />
<!-- Add default configuration to remove common headers -->
<util:XmlConfig Id="AddStripHeadersElement" File="[CONFIGDIR]\applicationHost.config" Action="create" Node="element" ElementPath="/configuration/system.webServer" Name="stripHeaders" On="install" Sequence="1006" />
<util:XmlConfig Id="AddServerHeaderElement" File="[CONFIGDIR]\applicationHost.config" Action="create" Node="element" ElementPath="/configuration/system.webServer/stripHeaders" Name="header" On="install" Sequence="1007" />
<util:XmlConfig Id="AddServerHeaderName" File="[CONFIGDIR]\applicationHost.config" ElementId="AddServerHeaderElement" Name="name" Value="Server" Sequence="1008" />
<util:XmlConfig Id="AddXPoweredByHeaderElement" File="[CONFIGDIR]\applicationHost.config" Action="create" Node="element" ElementPath="/configuration/system.webServer/stripHeaders" Name="header" On="install" Sequence="1009" />
<util:XmlConfig Id="AddXPoweredByHeaderName" File="[CONFIGDIR]\applicationHost.config" ElementId="AddXPoweredByHeaderElement" Name="name" Value="X-Powered-By" Sequence="1010" />
<util:XmlConfig Id="AddXAspnetVersionHeaderElement" File="[CONFIGDIR]\applicationHost.config" Action="create" Node="element" ElementPath="/configuration/system.webServer/stripHeaders" Name="header" On="install" Sequence="1009" />
<util:XmlConfig Id="AddXAspnetVersionHeaderName" File="[CONFIGDIR]\applicationHost.config" ElementId="AddXAspnetVersionHeaderElement" Name="name" Value="X-Aspnet-Version" Sequence="1010" />
<!-- Remove custom schema and any configured headers on uninstall -->
<util:XmlConfig Id="SchemaRemove" File="[CONFIGDIR]\applicationHost.config" Action="delete" Node="element" VerifyPath="section[\[]@name='stripHeaders'[\]]" ElementPath="configuration/configSections/sectionGroup[\[]@name='system.webServer'[\]]" On="uninstall" Sequence="1001" />
<util:XmlConfig Id="ConfigurationRemove" File="[CONFIGDIR]\applicationHost.config" Action="delete" Node="element" VerifyPath="stripHeaders" ElementPath="/configuration/system.webServer" On="uninstall" Sequence="1002" />
</Component>
</DirectoryRef>
<!-- install the files and registry values defined above -->
<Feature Id="MainInstall" Title="Main Install" Level="1">
<ComponentRef Id="stripheaders.dll" />
<ComponentRef Id="HTTPAPIHeaderRegistryEntry" />
<ComponentRef Id="stripHeaders_schema.xml" />
<ComponentRef Id="APPLICATIONHOSTXML" />
</Feature>
<!--Run custom actions to install and uninstall modules using appcmd -->
<InstallExecuteSequence>
<!-- If the package is installed, always uninstall module using appcmd to prevent IIS locking the dll. Run as soon as the install has validated -->
<Custom Action='QtExecUninstallModuleCMD' Before="QtExecUninstallModule">Installed</Custom>
<Custom Action="QtExecUninstallModule" Before="InstallValidate">Installed</Custom>
<!-- Always install the module using appcmd, as it will be uninstalled to prevent IIS locking the dll. Run after installation is complete -->
<Custom Action='QtExecInstallModuleCMD' Before="QtExecInstallModule">Installed AND NOT REMOVE OR NOT Installed</Custom>
<Custom Action="QtExecInstallModule" After="InstallFinalize" >Installed AND NOT REMOVE OR NOT Installed</Custom>
</InstallExecuteSequence>
<!-- Custom action command definitions. Not checking return values as this causes the package install/upgrade/uninstall to fail if an administrator has manually altered the StipHeaders module registration in IIS manager -->
<CustomAction Id="QtExecUninstallModuleCMD" Execute="immediate" Property="QtExec64CmdLine" Value="&quot;[WindowsFolder]system32\inetsrv\appcmd.exe&quot; uninstall module StripHeadersModule" />
<CustomAction Id="QtExecUninstallModule" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="ignore"/>
<CustomAction Id="QtExecInstallModuleCMD" Execute="immediate" Property="QtExec64CmdLine" Value="&quot;[WindowsFolder]system32\inetsrv\appcmd.exe&quot; install module /name:StripHeadersModule /image:%windir%\system32\inetsrv\stripheaders.dll /add:true /lock:true" />
<CustomAction Id="QtExecInstallModule" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="ignore"/>
</Product>
</Wix>
18 changes: 18 additions & 0 deletions Installer/stripHeaders_schema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
IIS StripHeaders configuration schema.
** Please DO NOT edit this file yourself. **
If you want to add configuration sections to the schema, you may place
them in .xml files similar to this one, in this directory. They will be
picked up automatically on startup.
-->

<configSchema>
<sectionSchema name="system.webServer/stripHeaders">
<collection addElement="header" clearElement="clear" removeElement="remove">
<attribute name="name" type="string" required="true" isUniqueKey="true"/>
</collection>
</sectionSchema>
</configSchema>
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014,
Copyright (c) 2014, Dionach Ltd
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -11,7 +11,7 @@ modification, are permitted provided that the following conditions are met:
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the {organization} nor the names of its
* Neither the name of the Dionach Ltd nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

Expand Down
Loading

0 comments on commit f26556f

Please sign in to comment.