Skip to content

Commit

Permalink
Add DirBrowseFlags to IisWebDirProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
bevanweiss committed Jan 23, 2025
1 parent 523c66a commit c856313
Show file tree
Hide file tree
Showing 16 changed files with 788 additions and 336 deletions.
1 change: 1 addition & 0 deletions src/ext/Iis/ca/sca.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ enum IIS_CONFIG_ACTION
IIS_DIRPROP_CACHECUST,
IIS_DIRPROP_NOCUSTERROR,
IIS_DIRPROP_LOGVISITS,
IIS_DIRPROP_BROWSEFLAGS,
IIS_DIRPROP_END,
IIS_WEBLOG,
IIS_FILTER_BEGIN,
Expand Down
2 changes: 1 addition & 1 deletion src/ext/Iis/ca/scasched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LPCWSTR vcsWebErrorQuery =
L"SELECT `ErrorCode`, `SubCode`, `ParentType`, `ParentValue`, `File`, `URL` "
L"FROM `Wix4IIsWebError` ORDER BY `ErrorCode`, `SubCode`";

LPCWSTR vcsWebDirPropertiesQuery = L"SELECT `DirProperties`, `Access`, `Authorization`, `AnonymousUser_`, `IIsControlledPassword`, `LogVisits`, `Index`, `DefaultDoc`, `AspDetailedError`, `HttpExpires`, `CacheControlMaxAge`, `CacheControlCustom`, `NoCustomError`, `AccessSSLFlags`, `AuthenticationProviders` "
LPCWSTR vcsWebDirPropertiesQuery = L"SELECT `DirProperties`, `Access`, `Authorization`, `AnonymousUser_`, `IIsControlledPassword`, `LogVisits`, `Index`, `DefaultDoc`, `AspDetailedError`, `HttpExpires`, `CacheControlMaxAge`, `CacheControlCustom`, `NoCustomError`, `AccessSSLFlags`, `AuthenticationProviders`, `DirBrowseFlags`"
L"FROM `Wix4IIsWebDirProperties`";

LPCWSTR vcsSslCertificateQuery = L"SELECT `Wix4Certificate`.`StoreName`, `Wix4CertificateHash`.`Hash`, `Wix4IIsWebSiteCertificates`.`Web_` FROM `Wix4Certificate`, `Wix4CertificateHash`, `Wix4IIsWebSiteCertificates` WHERE `Wix4Certificate`.`Certificate`=`Wix4CertificateHash`.`Certificate_` AND `Wix4CertificateHash`.`Certificate_`=`Wix4IIsWebSiteCertificates`.`Certificate_`";
Expand Down
22 changes: 21 additions & 1 deletion src/ext/Iis/ca/scawebprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "precomp.h"

// sql queries
enum eWebDirPropertiesQuery { wpqProperties = 1, wpqAccess, wpqAuthorization, wpqUser, wpqControlledPassword, wpqLogVisits, wpqIndex, wpqDefaultDoc, wpqAspDetailedError, wpqHttpExp, wpqCCMaxAge, wpqCCCustom, wpqNoCustomError, wpqAccessSSLFlags, wpqAuthenticationProviders };
enum eWebDirPropertiesQuery { wpqProperties = 1, wpqAccess, wpqAuthorization, wpqUser, wpqControlledPassword, wpqLogVisits, wpqIndex, wpqDefaultDoc, wpqAspDetailedError, wpqHttpExp, wpqCCMaxAge, wpqCCCustom, wpqNoCustomError, wpqAccessSSLFlags, wpqAuthenticationProviders, wpqDirBrowseFlags };

HRESULT ScaGetWebDirProperties(
__in LPCWSTR wzProperties,
Expand Down Expand Up @@ -154,6 +154,9 @@ HRESULT ScaGetWebDirProperties(
{
pswp->wzAuthenticationProviders[0] = L'\0';
}

hr = WcaGetRecordInteger(hRec, wpqDirBrowseFlags, &pswp->iDirBrowseFlags);
ExitOnFailure(hr, "failed to get IIsWebDirProperties.DirBrowseFlags");
}
else if (E_NOMOREITEMS == hr)
{
Expand Down Expand Up @@ -296,6 +299,23 @@ HRESULT ScaWriteWebDirProperties(
ExitOnFailure(hr, "Failed to write AuthenticationProviders for Web");
}

if (MSI_NULL_INTEGER != pswp->iDirBrowseFlags)
{
DWORD dwDirBrowseFlags = 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowDate) ? MD_DIRBROW_SHOW_DATE : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowExtension) ? MD_DIRBROW_SHOW_EXTENSION : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowLongDate) ? MD_DIRBROW_LONG_DATE : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowSize) ? MD_DIRBROW_SHOW_SIZE : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowTime) ? MD_DIRBROW_SHOW_TIME : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbEnableDefaultDoc) ? MD_DIRBROW_LOADDEFAULT : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbEnableDirBrowsing) ? MD_DIRBROW_ENABLED : 0;

// we XOR the flags, we only update things if they should be non-default
dwDirBrowseFlags ^= MD_DIRBROW_SHOW_DATE | MD_DIRBROW_SHOW_TIME | MD_DIRBROW_SHOW_SIZE | MD_DIRBROW_SHOW_EXTENSION | MD_DIRBROW_LONG_DATE | MD_DIRBROW_LOADDEFAULT;
hr = ScaWriteMetabaseValue(piMetabase, wzRootOfWeb, NULL, MD_DIRECTORY_BROWSING, METADATA_INHERIT, IIS_MD_UT_FILE, DWORD_METADATA, (LPVOID)((DWORD_PTR)dwDirBrowseFlags));
ExitOnFailure(hr, "Failed to write AccessSSLFlags for Web");
}

LExit:
return hr;
}
14 changes: 14 additions & 0 deletions src/ext/Iis/ca/scawebprop.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
// global sql queries provided for optimization
extern LPCWSTR vcsWebDirPropertiesQuery;

// enumerations
enum eWebDirBrowseFlags
{
wedbDirBrowseShowDate = 1 << 0,
wedbDirBrowseShowExtension = 1 << 1,
wedbDirBrowseShowLongDate = 1 << 2,
wedbDirBrowseShowSize = 1 << 3,
wedbDirBrowseShowTime = 1 << 4,
wedbEnableDefaultDoc = 1 << 5,
wedbEnableDirBrowsing = 1 << 6,
};


// structs
struct SCA_WEB_PROPERTIES
Expand Down Expand Up @@ -40,6 +52,8 @@ struct SCA_WEB_PROPERTIES

int iAccessSSLFlags;

int iDirBrowseFlags;

WCHAR wzAuthenticationProviders[MAX_DARWIN_COLUMN + 1];
};

Expand Down
21 changes: 21 additions & 0 deletions src/ext/Iis/ca/scawebprop7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,27 @@ HRESULT ScaWriteWebDirProperties7(
hr = ScaWriteConfigString(wz);
ExitOnFailure(hr, "Failed to write AuthenticationProviders for Web");
}

if (MSI_NULL_INTEGER != pswp->iDirBrowseFlags)
{
DWORD dwDirBrowseFlags = 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowDate) ? MD_DIRBROW_SHOW_DATE : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowExtension) ? MD_DIRBROW_SHOW_EXTENSION : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowLongDate) ? MD_DIRBROW_LONG_DATE : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowSize) ? MD_DIRBROW_SHOW_SIZE : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbDirBrowseShowTime) ? MD_DIRBROW_SHOW_TIME : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbEnableDefaultDoc) ? MD_DIRBROW_LOADDEFAULT : 0;
dwDirBrowseFlags |= (pswp->iDirBrowseFlags & wedbEnableDirBrowsing) ? MD_DIRBROW_ENABLED : 0;

// we XOR the flags, we only update things if they should be non-default
dwDirBrowseFlags ^= MD_DIRBROW_SHOW_DATE | MD_DIRBROW_SHOW_TIME | MD_DIRBROW_SHOW_SIZE | MD_DIRBROW_SHOW_EXTENSION | MD_DIRBROW_LONG_DATE | MD_DIRBROW_LOADDEFAULT;

hr = ScaWriteConfigID(IIS_DIRPROP_BROWSEFLAGS);
ExitOnFailure(hr, "Failed to write DirProp BrowseFlags id");
hr = ScaWriteConfigInteger(dwDirBrowseFlags);
ExitOnFailure(hr, "Failed to write DirBrowseFlags for Web");
}

//End of Dir Properties
hr = ScaWriteConfigID(IIS_DIRPROP_END);
ExitOnFailure(hr, "Failed to write DirProp end id");
Expand Down
77 changes: 77 additions & 0 deletions src/ext/Iis/test/WixToolsetTest.Iis/IisExtensionFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,83 @@ public void CanBuildUsingIIs()
}, results);
}

[Fact]
public void CanBuildWebDirProperties()
{
var folder = TestData.Get(@"TestData\WebDirProperties");
var build = new Builder(folder, typeof(IisExtensionFactory), new[] { folder });

var results = build.BuildAndQuery(Build, validate: true, "Wix4IIsWebSite", "Wix4IIsWebDir", "Wix4IIsWebDirProperties");
WixAssert.CompareLineByLine(new[]
{
"Wix4IIsWebDir:TestDirAccessSSL\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestAccessSSL\tTestAccessSSL\t",
"Wix4IIsWebDir:TestDirAccessSSL128\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestAccessSSL128\tTestAccessSSL128\t",
"Wix4IIsWebDir:TestDirAccessSSLMapCert\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestAccessSSLMapCert\tTestAccessSSLMapCert\t",
"Wix4IIsWebDir:TestDirAccessSSLNegotiateCert\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestAccessSSLNegotiateCert\tTestAccessSSLNegotiateCert\t",
"Wix4IIsWebDir:TestDirAccessSSLRequireCert\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestAccessSSLRequireCert\tTestAccessSSLRequireCert\t",
"Wix4IIsWebDir:TestDirAnonymousAccess\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestAnonymousAccess\tTestAnonymousAccess\t",
"Wix4IIsWebDir:TestDirAspDetailedError\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestAspDetailedError\tTestAspDetailedError\t",
"Wix4IIsWebDir:TestDirAuthenticationProviders\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestAuthenticationProviders\tTestAuthenticationProviders\t",
"Wix4IIsWebDir:TestDirBasicAuthentication\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestBasicAuthentication\tTestBasicAuthentication\t",
"Wix4IIsWebDir:TestDirCacheControlCustom\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestCacheControlCustom\tTestCacheControlCustom\t",
"Wix4IIsWebDir:TestDirCacheControlMaxAge\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestCacheControlMaxAge\tTestCacheControlMaxAge\t",
//"Wix4IIsWebDir:TestDirCacheControlMaxAgeNull\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestCacheControlMaxAgeNull\tTestCacheControlMaxAgeNull\t",
"Wix4IIsWebDir:TestDirClearCustomError\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestClearCustomError\tTestClearCustomError\t",
"Wix4IIsWebDir:TestDirDefaultDocuments\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestDefaultDocuments\tTestDefaultDocuments\t",
"Wix4IIsWebDir:TestDirDigestAuthentication\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestDigestAuthentication\tTestDigestAuthentication\t",
"Wix4IIsWebDir:TestDirDirBrowseShowDate\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestDirBrowseShowDate\tTestDirBrowseShowDate\t",
"Wix4IIsWebDir:TestDirDirBrowseShowExtension\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestDirBrowseShowExtension\tTestDirBrowseShowExtension\t",
"Wix4IIsWebDir:TestDirDirBrowseShowLongDate\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestDirBrowseShowLongDate\tTestDirBrowseShowLongDate\t",
"Wix4IIsWebDir:TestDirDirBrowseShowSize\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestDirBrowseShowSize\tTestDirBrowseShowSize\t",
"Wix4IIsWebDir:TestDirDirBrowseShowTime\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestDirBrowseShowTime\tTestDirBrowseShowTime\t",
"Wix4IIsWebDir:TestDirEnableDefaultDoc\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestEnableDefaultDoc\tTestEnableDefaultDoc\t",
"Wix4IIsWebDir:TestDirEnableDirBrowsing\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestEnableDirBrowsing\tTestEnableDirBrowsing\t",
"Wix4IIsWebDir:TestDirExecute\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestExecute\tTestExecute\t",
"Wix4IIsWebDir:TestDirHttpExpires\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestHttpExpires\tTestHttpExpires\t",
"Wix4IIsWebDir:TestDirIIsControlledPassword\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestIIsControlledPassword\tTestIIsControlledPassword\t",
"Wix4IIsWebDir:TestDirIndex\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestIndex\tTestIndex\t",
"Wix4IIsWebDir:TestDirLogVisits\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestLogVisits\tTestLogVisits\t",
"Wix4IIsWebDir:TestDirPassportAuthentication\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestPassportAuthentication\tTestPassportAuthentication\t",
"Wix4IIsWebDir:TestDirRead\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestRead\tTestRead\t",
"Wix4IIsWebDir:TestDirScript\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestScript\tTestScript\t",
"Wix4IIsWebDir:TestDirWindowsAuthentication\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestWindowsAuthentication\tTestWindowsAuthentication\t",
"Wix4IIsWebDir:TestDirWrite\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest\tTestWrite\tTestWrite\t",
"Wix4IIsWebDirProperties:TestAccessSSL\t\t\t\t0\t\t\t\t\t\t\t\t\t8\t\t",
"Wix4IIsWebDirProperties:TestAccessSSL128\t\t\t\t0\t\t\t\t\t\t\t\t\t256\t\t",
"Wix4IIsWebDirProperties:TestAccessSSLMapCert\t\t\t\t0\t\t\t\t\t\t\t\t\t128\t\t",
"Wix4IIsWebDirProperties:TestAccessSSLNegotiateCert\t\t\t\t0\t\t\t\t\t\t\t\t\t32\t\t",
"Wix4IIsWebDirProperties:TestAccessSSLRequireCert\t\t\t\t0\t\t\t\t\t\t\t\t\t64\t\t",
"Wix4IIsWebDirProperties:TestAnonymousAccess\t\t1\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestAspDetailedError\t\t\t\t0\t\t\t\t1\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestAuthenticationProviders\t\t\t\t0\t\t\t\t\t\t\t\t\t\tNTLM\t",
"Wix4IIsWebDirProperties:TestBasicAuthentication\t\t2\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestCacheControlCustom\t\t\t\t0\t\t\t\t\t\t\tCacheControl\t\t\t\t",
"Wix4IIsWebDirProperties:TestCacheControlMaxAge\t\t\t\t0\t\t\t\t\t\t-1\t\t\t\t\t",
//"Wix4IIsWebDirProperties:TestCacheControlMaxAgeNull\t\t\t\t0\t\t\t\t\t\t4294967295\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestClearCustomError\t\t\t\t0\t\t\t\t\t\t\t\t1\t\t\t",
"Wix4IIsWebDirProperties:TestDefaultDocuments\t\t\t\t0\t\t\tDefaultDocument.html,index.html,index.htm\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestDigestAuthentication\t\t16\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestDirBrowseShowDate\t\t\t\t0\t\t\t\t\t\t\t\t\t\t\t1",
"Wix4IIsWebDirProperties:TestDirBrowseShowExtension\t\t\t\t0\t\t\t\t\t\t\t\t\t\t\t2",
"Wix4IIsWebDirProperties:TestDirBrowseShowLongDate\t\t\t\t0\t\t\t\t\t\t\t\t\t\t\t4",
"Wix4IIsWebDirProperties:TestDirBrowseShowSize\t\t\t\t0\t\t\t\t\t\t\t\t\t\t\t8",
"Wix4IIsWebDirProperties:TestDirBrowseShowTime\t\t\t\t0\t\t\t\t\t\t\t\t\t\t\t16",
"Wix4IIsWebDirProperties:TestEnableDefaultDoc\t\t\t\t0\t\t\t\t\t\t\t\t\t\t\t32",
"Wix4IIsWebDirProperties:TestEnableDirBrowsing\t\t\t\t0\t\t\t\t\t\t\t\t\t\t\t64",
"Wix4IIsWebDirProperties:TestExecute\t4\t\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestHttpExpires\t\t\t\t0\t\t\t\t\tyes\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestIIsControlledPassword\t\t\t\t1\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestIndex\t\t\t\t0\t\t1\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestLogVisits\t\t\t\t0\t1\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestPassportAuthentication\t\t64\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestRead\t1\t\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestScript\t512\t\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestWindowsAuthentication\t\t4\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebDirProperties:TestWrite\t2\t\t\t0\t\t\t\t\t\t\t\t\t\t\t",
"Wix4IIsWebSite:Test\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tTest web server\t\tTestWebSiteProductDirectory\t2\t2\tTestAddress\t\t\t\t\t",
}, results);
}

private static void Build(string[] args)
{
var newArgs = args.ToList();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!--
This file contains the declaration of all the localizable strings.
-->
<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">

<String Id="DowngradeError" Value="A newer version of [ProductName] is already installed." />
<String Id="FeatureTitle" Value="MsiPackage" />

</WixLocalization>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />

<Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Package>

<Fragment>
<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLFOLDER" Name="MsiPackage">
<Directory Id="TestWebSiteProductDirectory" />
</Directory>
</StandardDirectory>
</Fragment>
</Wix>
Loading

0 comments on commit c856313

Please sign in to comment.