diff options
Diffstat (limited to 'src/ext/Iis/ca/scasched.cpp')
| -rw-r--r-- | src/ext/Iis/ca/scasched.cpp | 823 |
1 files changed, 823 insertions, 0 deletions
diff --git a/src/ext/Iis/ca/scasched.cpp b/src/ext/Iis/ca/scasched.cpp new file mode 100644 index 00000000..de021275 --- /dev/null +++ b/src/ext/Iis/ca/scasched.cpp | |||
| @@ -0,0 +1,823 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | |||
| 5 | const int ConfigureIIsCost = 8; | ||
| 6 | const int WriteMetabaseChangesCost = 20; | ||
| 7 | const int WriteIIS7ConfigChangesCost = 20; | ||
| 8 | |||
| 9 | // sql queries | ||
| 10 | LPCWSTR vcsUserDeferredQuery = L"SELECT `User`, `Component_`, `Name`, `Domain`, `Password` FROM `User`"; | ||
| 11 | |||
| 12 | LPCWSTR vcsWebSvcExtQuery = L"SELECT `Component_`, `File`, `Description`, `Group`, `Attributes` FROM `IIsWebServiceExtension`"; | ||
| 13 | |||
| 14 | LPCWSTR vcsAppPoolQuery = L"SELECT `AppPool`, `Name`, `Component_`, `Attributes`, `User_`, `RecycleMinutes`, `RecycleRequests`, `RecycleTimes`, `VirtualMemory`, `PrivateMemory`, `IdleTimeout`, `QueueLimit`, `CPUMon`, `MaxProc`, `ManagedRuntimeVersion`, `ManagedPipelineMode` FROM `IIsAppPool`"; | ||
| 15 | |||
| 16 | LPCWSTR vcsComponentAttrQuery = L"SELECT `Component`,`Attributes` FROM `Component`"; | ||
| 17 | |||
| 18 | LPCWSTR vcsMimeMapQuery = L"SELECT `MimeMap`, `ParentType`, `ParentValue`, `MimeType`, `Extension` FROM `IIsMimeMap`"; | ||
| 19 | |||
| 20 | LPCWSTR vcsHttpHeaderQuery = L"SELECT `Name`, `ParentType`, `ParentValue`, `Value`, `Attributes` FROM `IIsHttpHeader` ORDER BY `Sequence`"; | ||
| 21 | |||
| 22 | LPCWSTR vcsWebErrorQuery = | ||
| 23 | L"SELECT `ErrorCode`, `SubCode`, `ParentType`, `ParentValue`, `File`, `URL` " | ||
| 24 | L"FROM `IIsWebError` ORDER BY `ErrorCode`, `SubCode`"; | ||
| 25 | |||
| 26 | LPCWSTR vcsWebDirPropertiesQuery = L"SELECT `DirProperties`, `Access`, `Authorization`, `AnonymousUser_`, `IIsControlledPassword`, `LogVisits`, `Index`, `DefaultDoc`, `AspDetailedError`, `HttpExpires`, `CacheControlMaxAge`, `CacheControlCustom`, `NoCustomError`, `AccessSSLFlags`, `AuthenticationProviders` " | ||
| 27 | L"FROM `IIsWebDirProperties`"; | ||
| 28 | |||
| 29 | LPCWSTR vcsSslCertificateQuery = L"SELECT `Certificate`.`StoreName`, `CertificateHash`.`Hash`, `IIsWebSiteCertificates`.`Web_` FROM `Certificate`, `CertificateHash`, `IIsWebSiteCertificates` WHERE `Certificate`.`Certificate`=`CertificateHash`.`Certificate_` AND `CertificateHash`.`Certificate_`=`IIsWebSiteCertificates`.`Certificate_`"; | ||
| 30 | |||
| 31 | LPCWSTR vcsWebLogQuery = L"SELECT `Log`, `Format` " | ||
| 32 | L"FROM `IIsWebLog`"; | ||
| 33 | |||
| 34 | LPCWSTR vcsWebApplicationQuery = L"SELECT `Name`, `Isolation`, `AllowSessions`, `SessionTimeout`, " | ||
| 35 | L"`Buffer`, `ParentPaths`, `DefaultScript`, `ScriptTimeout`, " | ||
| 36 | L"`ServerDebugging`, `ClientDebugging`, `AppPool_`, `Application` " | ||
| 37 | L"FROM `IIsWebApplication`"; | ||
| 38 | |||
| 39 | LPCWSTR vcsWebAppExtensionQuery = L"SELECT `Extension`, `Verbs`, `Executable`, `Attributes`, `Application_` FROM `IIsWebApplicationExtension`"; | ||
| 40 | |||
| 41 | LPCWSTR vcsWebQuery = L"SELECT `Web`, `Component_`, `Id`, `Description`, `ConnectionTimeout`, `Directory_`, `State`, `Attributes`, `DirProperties_`, `Application_`, " | ||
| 42 | L"`Address`, `IP`, `Port`, `Header`, `Secure`, `Log_` FROM `IIsWebSite`, `IIsWebAddress` " | ||
| 43 | L"WHERE `KeyAddress_`=`Address` ORDER BY `Sequence`"; | ||
| 44 | |||
| 45 | LPCWSTR vcsWebAddressQuery = L"SELECT `Address`, `Web_`, `IP`, `Port`, `Header`, `Secure` " | ||
| 46 | L"FROM `IIsWebAddress`"; | ||
| 47 | |||
| 48 | LPCWSTR vcsWebBaseQuery = L"SELECT `Web`, `Id`, `IP`, `Port`, `Header`, `Secure`, `Description` " | ||
| 49 | L"FROM `IIsWebSite`, `IIsWebAddress` " | ||
| 50 | L"WHERE `KeyAddress_`=`Address`"; | ||
| 51 | |||
| 52 | LPCWSTR vcsWebDirQuery = L"SELECT `Web_`, `WebDir`, `Component_`, `Path`, `DirProperties_`, `Application_` " | ||
| 53 | L"FROM `IIsWebDir`"; | ||
| 54 | |||
| 55 | LPCWSTR vcsVDirQuery = L"SELECT `Web_`, `VirtualDir`, `Component_`, `Alias`, `Directory_`, `DirProperties_`, `Application_` " | ||
| 56 | L"FROM `IIsWebVirtualDir`"; | ||
| 57 | |||
| 58 | LPCWSTR vcsFilterQuery = L"SELECT `Web_`, `Name`, `Component_`, `Path`, `Description`, `Flags`, `LoadOrder` FROM `IIsFilter` ORDER BY `Web_`"; | ||
| 59 | |||
| 60 | LPCWSTR vcsPropertyQuery = L"SELECT `Property`, `Component_`, `Attributes`, `Value` " | ||
| 61 | L"FROM `IIsProperty`"; | ||
| 62 | |||
| 63 | #define IIS7CONDITION L"VersionNT >= 600" | ||
| 64 | #define USEIIS7CONDITION IIS7CONDITION L"AND NOT UseIis6Compatibility" | ||
| 65 | |||
| 66 | /******************************************************************** | ||
| 67 | ConfigureIIs - CUSTOM ACTION ENTRY POINT for installing IIs settings | ||
| 68 | |||
| 69 | ********************************************************************/ | ||
| 70 | extern "C" UINT __stdcall ConfigureIIs( | ||
| 71 | __in MSIHANDLE hInstall | ||
| 72 | ) | ||
| 73 | { | ||
| 74 | //AssertSz(FALSE, "debug ConfigureIIs here"); | ||
| 75 | HRESULT hr = S_OK; | ||
| 76 | UINT er = ERROR_SUCCESS; | ||
| 77 | LPWSTR pwzScriptKey = NULL; | ||
| 78 | LPWSTR pwzBackupId = NULL; | ||
| 79 | LPWSTR pwzCustomActionData = NULL; // CustomActionData for ConfigureIIs custom action | ||
| 80 | |||
| 81 | // initialize | ||
| 82 | hr = WcaInitialize(hInstall, "ConfigureIIs"); | ||
| 83 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 84 | |||
| 85 | // check for the prerequsite tables | ||
| 86 | if (S_OK != WcaTableExists(L"IIsWebSite") && S_OK != WcaTableExists(L"IIsFilter") && S_OK != WcaTableExists(L"IIsProperty") && | ||
| 87 | S_OK != WcaTableExists(L"IIsWebServiceExtension") && S_OK != WcaTableExists(L"IIsAppPool")) | ||
| 88 | { | ||
| 89 | WcaLog(LOGMSG_VERBOSE, "skipping IIs CustomAction, no IIsWebSite table, no IIsFilter table, no IIsProperty table, no IIsWebServiceExtension, and no IIsAppPool table"); | ||
| 90 | ExitFunction1(hr = S_FALSE); | ||
| 91 | } | ||
| 92 | |||
| 93 | // Get a CaScript key | ||
| 94 | hr = WcaCaScriptCreateKey(&pwzScriptKey); | ||
| 95 | ExitOnFailure(hr, "Failed to get encoding key."); | ||
| 96 | |||
| 97 | // Generate a unique string to be used for this product's transaction | ||
| 98 | // This prevents a name collision when doing a major upgrade | ||
| 99 | hr = WcaGetProperty(L"ProductCode", &pwzBackupId); | ||
| 100 | ExitOnFailure(hr, "failed to get ProductCode"); | ||
| 101 | |||
| 102 | hr = StrAllocConcat(&pwzBackupId, L"ScaConfigureIIs", 0); | ||
| 103 | ExitOnFailure(hr, "failed to concat ScaConfigureIIs"); | ||
| 104 | |||
| 105 | // make sure the operations below are wrapped in a "transaction" | ||
| 106 | // use IIS7 transaction logic even if using Iis6 compat because Backup/Restore don't work with metabase compatibility | ||
| 107 | if (MSICONDITION_TRUE == ::MsiEvaluateConditionW(hInstall, IIS7CONDITION)) | ||
| 108 | { | ||
| 109 | hr = ScaIIS7ConfigTransaction(pwzBackupId); | ||
| 110 | MessageExitOnFailure(hr, msierrIISFailedSchedTransaction, "failed to start IIS7 transaction"); | ||
| 111 | } | ||
| 112 | else | ||
| 113 | { | ||
| 114 | hr = ScaMetabaseTransaction(pwzBackupId); | ||
| 115 | MessageExitOnFailure(hr, msierrIISFailedSchedTransaction, "failed to start IIS transaction"); | ||
| 116 | } | ||
| 117 | |||
| 118 | // Write the CaScript key to the ConfigureIIS custom action data | ||
| 119 | hr = WcaWriteStringToCaData(pwzScriptKey, &pwzCustomActionData); | ||
| 120 | ExitOnFailure(hr, "Failed to add encoding key to CustomActionData."); | ||
| 121 | |||
| 122 | // Wrap vcsUserDeferredQuery to send to deferred CA | ||
| 123 | if (S_OK == WcaTableExists(L"User")) | ||
| 124 | { | ||
| 125 | hr = WcaWrapQuery(vcsUserDeferredQuery, &pwzCustomActionData, efmcColumn3 | efmcColumn4 | efmcColumn5, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 126 | ExitOnFailure(hr, "Failed to wrap User query"); | ||
| 127 | } | ||
| 128 | else | ||
| 129 | { | ||
| 130 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 131 | ExitOnFailure(hr, "Failed to wrap User empty query"); | ||
| 132 | } | ||
| 133 | |||
| 134 | // Wrap vcsWebSvcExtQuery to send to deferred CA | ||
| 135 | if (S_OK == WcaTableExists(L"IIsWebServiceExtension")) | ||
| 136 | { | ||
| 137 | hr = WcaWrapQuery(vcsWebSvcExtQuery, &pwzCustomActionData, efmcColumn2 | efmcColumn3 | efmcColumn4, 1, 0xFFFFFFFF); | ||
| 138 | ExitOnFailure(hr, "Failed to wrap IIsWebServiceExtension query"); | ||
| 139 | } | ||
| 140 | else | ||
| 141 | { | ||
| 142 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 143 | ExitOnFailure(hr, "Failed to wrap IIsWebServiceExtension empty query"); | ||
| 144 | } | ||
| 145 | |||
| 146 | // Wrap vcsAppPoolQuery to send to deferred CA | ||
| 147 | if (S_OK == WcaTableExists(L"IIsAppPool")) | ||
| 148 | { | ||
| 149 | hr = WcaWrapQuery(vcsAppPoolQuery, &pwzCustomActionData, efmcColumn2 | efmcColumn15 | efmcColumn16, 3, 0xFFFFFFFF); | ||
| 150 | ExitOnFailure(hr, "Failed to wrap IIsAppPool query"); | ||
| 151 | |||
| 152 | hr = WcaWrapQuery(vcsComponentAttrQuery, &pwzCustomActionData, 0, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 153 | ExitOnFailure(hr, "Failed to wrap Component query"); | ||
| 154 | } | ||
| 155 | else | ||
| 156 | { | ||
| 157 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 158 | ExitOnFailure(hr, "Failed to wrap IIsAppPool empty query"); | ||
| 159 | } | ||
| 160 | |||
| 161 | // Wrap vcsMimeMapQuery to send to deferred CA | ||
| 162 | if (S_OK == WcaTableExists(L"IIsMimeMap")) | ||
| 163 | { | ||
| 164 | hr = WcaWrapQuery(vcsMimeMapQuery, &pwzCustomActionData, efmcColumn4 | efmcColumn5, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 165 | ExitOnFailure(hr, "Failed to wrap IIsMimeMap query"); | ||
| 166 | } | ||
| 167 | else | ||
| 168 | { | ||
| 169 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 170 | ExitOnFailure(hr, "Failed to wrap IIsMimeMap empty query"); | ||
| 171 | } | ||
| 172 | |||
| 173 | // Wrap vcsHttpHeaderQuery to send to deferred CA | ||
| 174 | if (S_OK == WcaTableExists(L"IIsHttpHeader")) | ||
| 175 | { | ||
| 176 | hr = WcaWrapQuery(vcsHttpHeaderQuery, &pwzCustomActionData, efmcColumn1 | efmcColumn4, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 177 | ExitOnFailure(hr, "Failed to wrap IIsHttpHeader query"); | ||
| 178 | } | ||
| 179 | else | ||
| 180 | { | ||
| 181 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 182 | ExitOnFailure(hr, "Failed to wrap IIsHttpHeader empty query"); | ||
| 183 | } | ||
| 184 | |||
| 185 | // Wrap vcsWebErrorQuery to send to deferred CA | ||
| 186 | if (S_OK == WcaTableExists(L"IIsWebError")) | ||
| 187 | { | ||
| 188 | hr = WcaWrapQuery(vcsWebErrorQuery, &pwzCustomActionData, efmcColumn5 | efmcColumn6, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 189 | ExitOnFailure(hr, "Failed to wrap IIsWebError query"); | ||
| 190 | } | ||
| 191 | else | ||
| 192 | { | ||
| 193 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 194 | ExitOnFailure(hr, "Failed to wrap IIsWebError empty query"); | ||
| 195 | } | ||
| 196 | |||
| 197 | // Wrap vcsWebDirPropertiesQuery to send to deferred CA | ||
| 198 | if (S_OK == WcaTableExists(L"IIsWebDirProperties")) | ||
| 199 | { | ||
| 200 | hr = WcaWrapQuery(vcsWebDirPropertiesQuery, &pwzCustomActionData, efmcColumn8 | efmcColumn10 | efmcColumn12 | efmcColumn15, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 201 | ExitOnFailure(hr, "Failed to wrap IIsWebDirProperties query"); | ||
| 202 | } | ||
| 203 | else | ||
| 204 | { | ||
| 205 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 206 | ExitOnFailure(hr, "Failed to wrap IIsWebDirProperties empty query"); | ||
| 207 | } | ||
| 208 | |||
| 209 | // Wrap vcsSslCertificateQuery to send to deferred CA | ||
| 210 | if (S_OK == WcaTableExists(L"Certificate") && S_OK == WcaTableExists(L"CertificateHash") && S_OK == WcaTableExists(L"IIsWebSiteCertificates")) | ||
| 211 | { | ||
| 212 | hr = WcaWrapQuery(vcsSslCertificateQuery, &pwzCustomActionData, 0, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 213 | ExitOnFailure(hr, "Failed to wrap SslCertificate query"); | ||
| 214 | } | ||
| 215 | else | ||
| 216 | { | ||
| 217 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 218 | ExitOnFailure(hr, "Failed to wrap SslCertificate empty query"); | ||
| 219 | } | ||
| 220 | |||
| 221 | // Wrap vcsWebLogQuery to send to deferred CA | ||
| 222 | if (S_OK == WcaTableExists(L"IIsWebLog")) | ||
| 223 | { | ||
| 224 | hr = WcaWrapQuery(vcsWebLogQuery, &pwzCustomActionData, efmcColumn2, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 225 | ExitOnFailure(hr, "Failed to wrap IIsWebLog query"); | ||
| 226 | } | ||
| 227 | else | ||
| 228 | { | ||
| 229 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 230 | ExitOnFailure(hr, "Failed to wrap IIsWebLog empty query"); | ||
| 231 | } | ||
| 232 | |||
| 233 | // Wrap vcsWebApplicationQuery to send to deferred CA | ||
| 234 | if (S_OK == WcaTableExists(L"IIsWebApplication")) | ||
| 235 | { | ||
| 236 | hr = WcaWrapQuery(vcsWebApplicationQuery, &pwzCustomActionData, efmcColumn1, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 237 | ExitOnFailure(hr, "Failed to wrap IIsWebApplication query"); | ||
| 238 | } | ||
| 239 | else | ||
| 240 | { | ||
| 241 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 242 | ExitOnFailure(hr, "Failed to wrap IIsWebApplication empty query"); | ||
| 243 | } | ||
| 244 | |||
| 245 | // Wrap vcsWebAppExtensionQuery to send to deferred CA | ||
| 246 | if (S_OK == WcaTableExists(L"IIsWebApplicationExtension")) | ||
| 247 | { | ||
| 248 | hr = WcaWrapQuery(vcsWebAppExtensionQuery, &pwzCustomActionData, efmcColumn2 | efmcColumn3, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 249 | ExitOnFailure(hr, "Failed to wrap IIsWebApplicationExtension query"); | ||
| 250 | } | ||
| 251 | else | ||
| 252 | { | ||
| 253 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 254 | ExitOnFailure(hr, "Failed to wrap IIsWebApplicationExtension empty query"); | ||
| 255 | } | ||
| 256 | |||
| 257 | // Wrap vcsWebQuery, vcsWebAddressQuery, and vcsWebBaseQuery to send to deferred CA | ||
| 258 | if (S_OK == WcaTableExists(L"IIsWebAddress") && S_OK == WcaTableExists(L"IIsWebSite")) | ||
| 259 | { | ||
| 260 | hr = WcaWrapQuery(vcsWebQuery, &pwzCustomActionData, efmcColumn3 | efmcColumn4 | efmcColumn12 | efmcColumn13 | efmcColumn14, 2, 6); | ||
| 261 | ExitOnFailure(hr, "Failed to wrap IIsWebSite query"); | ||
| 262 | |||
| 263 | hr = WcaWrapQuery(vcsWebAddressQuery, &pwzCustomActionData, efmcColumn3 | efmcColumn4 | efmcColumn5, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 264 | ExitOnFailure(hr, "Failed to wrap IIsWebAddress query"); | ||
| 265 | |||
| 266 | hr = WcaWrapQuery(vcsWebBaseQuery, &pwzCustomActionData, efmcColumn2 | efmcColumn3 | efmcColumn4 | efmcColumn5 | efmcColumn7, 0xFFFFFFFF, 0xFFFFFFFF); | ||
| 267 | ExitOnFailure(hr, "Failed to wrap IIsWebBase query"); | ||
| 268 | } | ||
| 269 | else | ||
| 270 | { | ||
| 271 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 272 | ExitOnFailure(hr, "Failed to wrap IIsWebSite empty query"); | ||
| 273 | |||
| 274 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 275 | ExitOnFailure(hr, "Failed to wrap IIsWebAddress empty query"); | ||
| 276 | |||
| 277 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 278 | ExitOnFailure(hr, "Failed to wrap IIsWebBase empty query"); | ||
| 279 | } | ||
| 280 | |||
| 281 | // Wrap vcsWebDirQuery to send to deferred CA | ||
| 282 | if (S_OK == WcaTableExists(L"IIsWebDir")) | ||
| 283 | { | ||
| 284 | hr = WcaWrapQuery(vcsWebDirQuery, &pwzCustomActionData, efmcColumn4, 3, 0xFFFFFFFF); | ||
| 285 | ExitOnFailure(hr, "Failed to wrap IIsWebDir query"); | ||
| 286 | } | ||
| 287 | else | ||
| 288 | { | ||
| 289 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 290 | ExitOnFailure(hr, "Failed to wrap IIsWebDir empty query"); | ||
| 291 | } | ||
| 292 | |||
| 293 | // Wrap vcsVDirQuery to send to deferred CA | ||
| 294 | if (S_OK == WcaTableExists(L"IIsWebVirtualDir")) | ||
| 295 | { | ||
| 296 | hr = WcaWrapQuery(vcsVDirQuery, &pwzCustomActionData, efmcColumn4, 3, 5); | ||
| 297 | ExitOnFailure(hr, "Failed to wrap IIsWebVirtualDir query"); | ||
| 298 | } | ||
| 299 | else | ||
| 300 | { | ||
| 301 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 302 | ExitOnFailure(hr, "Failed to wrap IIsWebVirtualDir empty query"); | ||
| 303 | } | ||
| 304 | |||
| 305 | // Wrap vcsFilterQuery to send to deferred CA | ||
| 306 | if (S_OK == WcaTableExists(L"IIsFilter")) | ||
| 307 | { | ||
| 308 | hr = WcaWrapQuery(vcsFilterQuery, &pwzCustomActionData, efmcColumn4 | efmcColumn5, 3, 0xFFFFFFFF); | ||
| 309 | ExitOnFailure(hr, "Failed to wrap IIsFilter query"); | ||
| 310 | } | ||
| 311 | else | ||
| 312 | { | ||
| 313 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 314 | ExitOnFailure(hr, "Failed to wrap IIsFilter empty query"); | ||
| 315 | } | ||
| 316 | |||
| 317 | // Wrap vcsPropertyQuery to send to deferred CA | ||
| 318 | if (S_OK == WcaTableExists(L"IIsProperty")) | ||
| 319 | { | ||
| 320 | hr = WcaWrapQuery(vcsPropertyQuery, &pwzCustomActionData, efmcColumn4, 2, 0xFFFFFFFF); | ||
| 321 | ExitOnFailure(hr, "Failed to wrap IIsProperty query"); | ||
| 322 | } | ||
| 323 | else | ||
| 324 | { | ||
| 325 | hr = WcaWrapEmptyQuery(&pwzCustomActionData); | ||
| 326 | ExitOnFailure(hr, "Failed to wrap IIsProperty empty query"); | ||
| 327 | } | ||
| 328 | |||
| 329 | if (MSICONDITION_TRUE == ::MsiEvaluateConditionW(hInstall, USEIIS7CONDITION)) | ||
| 330 | { | ||
| 331 | // This must remain trace only, CA data may contain password | ||
| 332 | WcaLog(LOGMSG_TRACEONLY, "Custom Action Data for ConfigureIIS7Exec will be: %ls", pwzCustomActionData); | ||
| 333 | |||
| 334 | hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ConfigureIIs7Exec"), pwzCustomActionData, ConfigureIIsCost); | ||
| 335 | ExitOnFailure(hr, "Failed to schedule ConfigureIIs7Exec custom action"); | ||
| 336 | |||
| 337 | ReleaseNullStr(pwzCustomActionData); | ||
| 338 | |||
| 339 | // Write the CaScript key to the ConfigureIIS custom action data | ||
| 340 | hr = WcaWriteStringToCaData(pwzScriptKey, &pwzCustomActionData); | ||
| 341 | ExitOnFailure(hr, "Failed to add script key to CustomActionData."); | ||
| 342 | |||
| 343 | hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WriteIIS7ConfigChanges"), pwzCustomActionData, WriteIIS7ConfigChangesCost); | ||
| 344 | ExitOnFailure(hr, "Failed to schedule WriteMetabaseChanges custom action"); | ||
| 345 | } | ||
| 346 | else | ||
| 347 | { | ||
| 348 | // This must remain trace only, CA data may contain password | ||
| 349 | WcaLog(LOGMSG_TRACEONLY, "Custom Action Data for ConfigureIISExec will be: %ls", pwzCustomActionData); | ||
| 350 | |||
| 351 | hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ConfigureIIsExec"), pwzCustomActionData, ConfigureIIsCost); | ||
| 352 | ExitOnFailure(hr, "Failed to schedule ConfigureIISExec custom action"); | ||
| 353 | |||
| 354 | ReleaseNullStr(pwzCustomActionData); | ||
| 355 | |||
| 356 | // Write the CaScript key to the ConfigureIIS custom action data | ||
| 357 | hr = WcaWriteStringToCaData(pwzScriptKey, &pwzCustomActionData); | ||
| 358 | ExitOnFailure(hr, "Failed to add script key to CustomActionData."); | ||
| 359 | |||
| 360 | hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WriteMetabaseChanges"), pwzCustomActionData, WriteMetabaseChangesCost); | ||
| 361 | ExitOnFailure(hr, "Failed to schedule WriteMetabaseChanges custom action"); | ||
| 362 | } | ||
| 363 | |||
| 364 | LExit: | ||
| 365 | ReleaseStr(pwzScriptKey); | ||
| 366 | ReleaseStr(pwzBackupId); | ||
| 367 | ReleaseStr(pwzCustomActionData); | ||
| 368 | |||
| 369 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 370 | return WcaFinalize(er); | ||
| 371 | } | ||
| 372 | |||
| 373 | /******************************************************************** | ||
| 374 | ConfigureIIsExec - custom action for installing IIs settings - table | ||
| 375 | data will be wrapped and passed in from immediate CA | ||
| 376 | ReadIIsTables | ||
| 377 | |||
| 378 | ********************************************************************/ | ||
| 379 | extern "C" UINT __stdcall ConfigureIIsExec( | ||
| 380 | __in MSIHANDLE hInstall | ||
| 381 | ) | ||
| 382 | { | ||
| 383 | //AssertSz(FALSE, "debug ConfigureIIsExec here"); | ||
| 384 | HRESULT hr = S_OK; | ||
| 385 | UINT er = ERROR_SUCCESS; | ||
| 386 | |||
| 387 | BOOL fInitializedCom = FALSE; | ||
| 388 | IMSAdminBase* piMetabase = NULL; | ||
| 389 | |||
| 390 | SCA_WEB* pswList = NULL; | ||
| 391 | SCA_WEBDIR* pswdList = NULL; | ||
| 392 | SCA_VDIR* psvdList = NULL; | ||
| 393 | SCA_FILTER* psfList = NULL; | ||
| 394 | SCA_APPPOOL *psapList = NULL; | ||
| 395 | SCA_MIMEMAP* psmmList = NULL; | ||
| 396 | SCA_HTTP_HEADER* pshhList = NULL; | ||
| 397 | SCA_PROPERTY *pspList = NULL; | ||
| 398 | SCA_WEBSVCEXT* psWseList = NULL; | ||
| 399 | SCA_WEB_ERROR* psweList = NULL; | ||
| 400 | |||
| 401 | LPWSTR pwzScriptKey = NULL; | ||
| 402 | LPWSTR pwzCustomActionData = NULL; | ||
| 403 | |||
| 404 | WCA_WRAPQUERY_HANDLE hUserQuery = NULL; | ||
| 405 | WCA_WRAPQUERY_HANDLE hWebBaseQuery = NULL; | ||
| 406 | WCA_WRAPQUERY_HANDLE hWebDirPropQuery = NULL; | ||
| 407 | WCA_WRAPQUERY_HANDLE hSslCertQuery = NULL; | ||
| 408 | WCA_WRAPQUERY_HANDLE hWebLogQuery = NULL; | ||
| 409 | WCA_WRAPQUERY_HANDLE hWebAppQuery = NULL; | ||
| 410 | WCA_WRAPQUERY_HANDLE hWebAppExtQuery = NULL; | ||
| 411 | |||
| 412 | // initialize | ||
| 413 | hr = WcaInitialize(hInstall, "ConfigureIIsExec"); | ||
| 414 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 415 | |||
| 416 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 417 | ExitOnFailure(hr, "failed to get CustomActionData"); | ||
| 418 | |||
| 419 | // Get the CaScript key | ||
| 420 | hr = WcaReadStringFromCaData(&pwzCustomActionData, &pwzScriptKey); | ||
| 421 | ExitOnFailure(hr, "Failed to get CaScript key from custom action data"); | ||
| 422 | |||
| 423 | hr = ::CoInitialize(NULL); | ||
| 424 | ExitOnFailure(hr, "failed to initialize COM"); | ||
| 425 | fInitializedCom = TRUE; | ||
| 426 | |||
| 427 | // if IIS was uninstalled (thus no IID_IMSAdminBase) allow the | ||
| 428 | // user to still uninstall this package by clicking "Ignore" | ||
| 429 | do | ||
| 430 | { | ||
| 431 | hr = ::CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void**)&piMetabase); | ||
| 432 | if (FAILED(hr)) | ||
| 433 | { | ||
| 434 | WcaLog(LOGMSG_STANDARD, "failed to get IID_IMSAdminBase Object"); | ||
| 435 | er = WcaErrorMessage(msierrIISCannotConnect, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0); | ||
| 436 | switch (er) | ||
| 437 | { | ||
| 438 | case IDABORT: | ||
| 439 | ExitFunction(); // bail with the error result from the CoCreate to kick off a rollback | ||
| 440 | case IDRETRY: | ||
| 441 | hr = S_FALSE; // hit me, baby, one more time | ||
| 442 | break; | ||
| 443 | case IDIGNORE: | ||
| 444 | __fallthrough; | ||
| 445 | default: | ||
| 446 | WcaLog(LOGMSG_STANDARD, "ignoring absent IIS"); | ||
| 447 | // We need to write the empty script to communicate to other deferred CA that there is noting to do. | ||
| 448 | hr = ScaWriteConfigurationScript(pwzScriptKey); | ||
| 449 | ExitOnFailure(hr, "failed to schedule metabase configuration"); | ||
| 450 | |||
| 451 | ExitFunction1(hr = S_OK); // pretend everything is okay | ||
| 452 | break; | ||
| 453 | } | ||
| 454 | } | ||
| 455 | } while (S_FALSE == hr); | ||
| 456 | |||
| 457 | // read the msi tables | ||
| 458 | hr = WcaBeginUnwrapQuery(&hUserQuery, &pwzCustomActionData); | ||
| 459 | ExitOnFailure(hr, "Failed to unwrap user query"); | ||
| 460 | |||
| 461 | hr = ScaWebSvcExtRead(&psWseList, &pwzCustomActionData); | ||
| 462 | MessageExitOnFailure(hr, msierrIISFailedReadWebSvcExt, "failed while processing WebServiceExtensions"); | ||
| 463 | |||
| 464 | hr = ScaAppPoolRead(&psapList, hUserQuery, &pwzCustomActionData); | ||
| 465 | MessageExitOnFailure(hr, msierrIISFailedReadAppPool, "failed while processing WebAppPools"); | ||
| 466 | |||
| 467 | // MimeMap, Error and HttpHeader need to be read before the virtual directory and web read | ||
| 468 | hr = ScaMimeMapRead(&psmmList, &pwzCustomActionData); | ||
| 469 | MessageExitOnFailure(hr, msierrIISFailedReadMimeMap, "failed while processing MimeMaps"); | ||
| 470 | |||
| 471 | hr = ScaHttpHeaderRead(&pshhList, &pwzCustomActionData); | ||
| 472 | MessageExitOnFailure(hr, msierrIISFailedReadHttpHeader, "failed while processing HttpHeaders"); | ||
| 473 | |||
| 474 | hr = ScaWebErrorRead(&psweList, &pwzCustomActionData); | ||
| 475 | MessageExitOnFailure(hr, msierrIISFailedReadWebError, "failed while processing WebErrors"); | ||
| 476 | |||
| 477 | hr = WcaBeginUnwrapQuery(&hWebDirPropQuery, &pwzCustomActionData); | ||
| 478 | ExitOnFailure(hr, "Failed to unwrap web dir properties query"); | ||
| 479 | |||
| 480 | hr = WcaBeginUnwrapQuery(&hSslCertQuery, &pwzCustomActionData); | ||
| 481 | ExitOnFailure(hr, "Failed to unwrap ssl certificate query"); | ||
| 482 | |||
| 483 | hr = WcaBeginUnwrapQuery(&hWebLogQuery, &pwzCustomActionData); | ||
| 484 | ExitOnFailure(hr, "Failed to unwrap web log query"); | ||
| 485 | |||
| 486 | hr = WcaBeginUnwrapQuery(&hWebAppQuery, &pwzCustomActionData); | ||
| 487 | ExitOnFailure(hr, "Failed to unwrap web application query"); | ||
| 488 | |||
| 489 | hr = WcaBeginUnwrapQuery(&hWebAppExtQuery, &pwzCustomActionData); | ||
| 490 | ExitOnFailure(hr, "Failed to unwrap web application extension query"); | ||
| 491 | |||
| 492 | hr = ScaWebsRead(piMetabase, &psmmList, &pswList, &pshhList, &psweList, hUserQuery, hWebDirPropQuery, hSslCertQuery, hWebLogQuery, hWebAppQuery, hWebAppExtQuery, &pwzCustomActionData); | ||
| 493 | MessageExitOnFailure(hr, msierrIISFailedReadWebSite, "failed while processing WebSites"); | ||
| 494 | |||
| 495 | hr = WcaBeginUnwrapQuery(&hWebBaseQuery, &pwzCustomActionData); | ||
| 496 | ExitOnFailure(hr, "Failed to unwrap web base query"); | ||
| 497 | |||
| 498 | hr = ScaWebDirsRead(piMetabase, pswList, hUserQuery, hWebBaseQuery, hWebDirPropQuery, hWebAppQuery, hWebAppExtQuery, &pwzCustomActionData, &pswdList); | ||
| 499 | MessageExitOnFailure(hr, msierrIISFailedReadWebDirs, "failed while processing WebDirs"); | ||
| 500 | |||
| 501 | hr = ScaVirtualDirsRead(piMetabase, pswList, &psvdList, &psmmList, &pshhList, &psweList, hUserQuery, hWebBaseQuery, hWebDirPropQuery, hWebAppQuery, hWebAppExtQuery, &pwzCustomActionData); | ||
| 502 | MessageExitOnFailure(hr, msierrIISFailedReadVDirs, "failed while processing WebVirtualDirs"); | ||
| 503 | |||
| 504 | hr = ScaFiltersRead(piMetabase, pswList, hWebBaseQuery, &psfList, &pwzCustomActionData); | ||
| 505 | MessageExitOnFailure(hr, msierrIISFailedReadFilters, "failed while processing WebFilters"); | ||
| 506 | |||
| 507 | hr = ScaPropertyRead(&pspList, &pwzCustomActionData); | ||
| 508 | MessageExitOnFailure(hr, msierrIISFailedReadProp, "failed while processing WebProperties"); | ||
| 509 | |||
| 510 | // do uninstall actions (order is important!) | ||
| 511 | hr = ScaPropertyUninstall(piMetabase, pspList); | ||
| 512 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallProp, "failed to uninstall IIS properties"); | ||
| 513 | |||
| 514 | hr = ScaFiltersUninstall(piMetabase, psfList); | ||
| 515 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallFilters, "failed to schedule uninstall of filters"); | ||
| 516 | |||
| 517 | hr = ScaVirtualDirsUninstall(piMetabase, psvdList); | ||
| 518 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallVDirs, "failed to schedule uninstall of virtual directories"); | ||
| 519 | |||
| 520 | hr = ScaWebDirsUninstall(piMetabase, pswdList); | ||
| 521 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallWebDirs, "failed to schedule uninstall of web directories"); | ||
| 522 | |||
| 523 | hr = ScaWebsUninstall(piMetabase, pswList); | ||
| 524 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallWebs, "failed to schedule uninstall of webs"); | ||
| 525 | |||
| 526 | hr = ScaAppPoolUninstall(piMetabase, psapList); | ||
| 527 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallAppPool, "failed to schedule uninstall of AppPools"); | ||
| 528 | |||
| 529 | |||
| 530 | // do install actions (order is important!) | ||
| 531 | // ScaWebSvcExtCommit contains both uninstall and install actions. | ||
| 532 | hr = ScaWebSvcExtCommit(piMetabase, psWseList); | ||
| 533 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallWebSvcExt, "failed to schedule install/uninstall of WebSvcExt"); | ||
| 534 | |||
| 535 | hr = ScaAppPoolInstall(piMetabase, psapList); | ||
| 536 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallAppPool, "failed to schedule install of AppPools"); | ||
| 537 | |||
| 538 | hr = ScaWebsInstall(piMetabase, pswList, psapList); | ||
| 539 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallWebs, "failed to schedule install of webs"); | ||
| 540 | |||
| 541 | hr = ScaWebDirsInstall(piMetabase, pswdList, psapList); | ||
| 542 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallWebDirs, "failed to schedule install of web directories"); | ||
| 543 | |||
| 544 | hr = ScaVirtualDirsInstall(piMetabase, psvdList, psapList); | ||
| 545 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallVDirs, "failed to schedule install of virtual directories"); | ||
| 546 | |||
| 547 | hr = ScaFiltersInstall(piMetabase, psfList); | ||
| 548 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallFilters, "failed to schedule install of filters"); | ||
| 549 | |||
| 550 | hr = ScaPropertyInstall(piMetabase, pspList); | ||
| 551 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallProp, "failed to schedule install of properties"); | ||
| 552 | |||
| 553 | hr = ScaWriteConfigurationScript(pwzScriptKey); | ||
| 554 | ExitOnFailure(hr, "failed to schedule metabase configuration"); | ||
| 555 | |||
| 556 | LExit: | ||
| 557 | ReleaseStr(pwzScriptKey); | ||
| 558 | ReleaseStr(pwzCustomActionData); | ||
| 559 | |||
| 560 | WcaFinishUnwrapQuery(hUserQuery); | ||
| 561 | WcaFinishUnwrapQuery(hWebBaseQuery); | ||
| 562 | WcaFinishUnwrapQuery(hWebDirPropQuery); | ||
| 563 | WcaFinishUnwrapQuery(hSslCertQuery); | ||
| 564 | WcaFinishUnwrapQuery(hWebLogQuery); | ||
| 565 | WcaFinishUnwrapQuery(hWebAppQuery); | ||
| 566 | WcaFinishUnwrapQuery(hWebAppExtQuery); | ||
| 567 | |||
| 568 | if (psWseList) | ||
| 569 | { | ||
| 570 | ScaWebSvcExtFreeList(psWseList); | ||
| 571 | } | ||
| 572 | |||
| 573 | if (psfList) | ||
| 574 | { | ||
| 575 | ScaFiltersFreeList(psfList); | ||
| 576 | } | ||
| 577 | |||
| 578 | if (psvdList) | ||
| 579 | { | ||
| 580 | ScaVirtualDirsFreeList(psvdList); | ||
| 581 | } | ||
| 582 | |||
| 583 | if (pswdList) | ||
| 584 | { | ||
| 585 | ScaWebDirsFreeList(pswdList); | ||
| 586 | } | ||
| 587 | |||
| 588 | if (pswList) | ||
| 589 | { | ||
| 590 | ScaWebsFreeList(pswList); | ||
| 591 | } | ||
| 592 | |||
| 593 | if (psmmList) | ||
| 594 | { | ||
| 595 | ScaMimeMapCheckList(psmmList); | ||
| 596 | ScaMimeMapFreeList(psmmList); | ||
| 597 | } | ||
| 598 | |||
| 599 | if (pshhList) | ||
| 600 | { | ||
| 601 | ScaHttpHeaderCheckList(pshhList); | ||
| 602 | ScaHttpHeaderFreeList(pshhList); | ||
| 603 | } | ||
| 604 | |||
| 605 | if (psweList) | ||
| 606 | { | ||
| 607 | ScaWebErrorCheckList(psweList); | ||
| 608 | ScaWebErrorFreeList(psweList); | ||
| 609 | } | ||
| 610 | |||
| 611 | ReleaseObject(piMetabase); | ||
| 612 | |||
| 613 | if (fInitializedCom) | ||
| 614 | { | ||
| 615 | ::CoUninitialize(); | ||
| 616 | } | ||
| 617 | |||
| 618 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 619 | return WcaFinalize(er); | ||
| 620 | } | ||
| 621 | |||
| 622 | |||
| 623 | /******************************************************************** | ||
| 624 | ConfigureIIs - CUSTOM ACTION ENTRY POINT for installing IIs settings | ||
| 625 | |||
| 626 | ********************************************************************/ | ||
| 627 | extern "C" UINT __stdcall ConfigureIIs7Exec( | ||
| 628 | __in MSIHANDLE hInstall | ||
| 629 | ) | ||
| 630 | { | ||
| 631 | //AssertSz(FALSE, "debug ConfigureIIs7Exec here"); | ||
| 632 | HRESULT hr = S_OK; | ||
| 633 | UINT er = ERROR_SUCCESS; | ||
| 634 | |||
| 635 | LPWSTR pwzScriptKey = NULL; | ||
| 636 | LPWSTR pwzCustomActionData = NULL; | ||
| 637 | |||
| 638 | SCA_WEB7* pswList = NULL; | ||
| 639 | SCA_WEBDIR7* pswdList = NULL; | ||
| 640 | SCA_VDIR7* psvdList = NULL; | ||
| 641 | SCA_FILTER* psfList = NULL; | ||
| 642 | SCA_APPPOOL *psapList = NULL; | ||
| 643 | SCA_MIMEMAP* psmmList = NULL; | ||
| 644 | SCA_HTTP_HEADER* pshhList = NULL; | ||
| 645 | SCA_PROPERTY *pspList = NULL; | ||
| 646 | SCA_WEBSVCEXT* psWseList = NULL; | ||
| 647 | SCA_WEB_ERROR* psweList = NULL; | ||
| 648 | |||
| 649 | WCA_WRAPQUERY_HANDLE hUserQuery = NULL; | ||
| 650 | WCA_WRAPQUERY_HANDLE hWebBaseQuery = NULL; | ||
| 651 | WCA_WRAPQUERY_HANDLE hWebDirPropQuery = NULL; | ||
| 652 | WCA_WRAPQUERY_HANDLE hSslCertQuery = NULL; | ||
| 653 | WCA_WRAPQUERY_HANDLE hWebLogQuery = NULL; | ||
| 654 | WCA_WRAPQUERY_HANDLE hWebAppQuery = NULL; | ||
| 655 | WCA_WRAPQUERY_HANDLE hWebAppExtQuery = NULL; | ||
| 656 | |||
| 657 | // initialize | ||
| 658 | hr = WcaInitialize(hInstall, "ConfigureIIs7Exec"); | ||
| 659 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 660 | |||
| 661 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 662 | ExitOnFailure(hr, "failed to get CustomActionData"); | ||
| 663 | |||
| 664 | // Get the CaScript key | ||
| 665 | hr = WcaReadStringFromCaData(&pwzCustomActionData, &pwzScriptKey); | ||
| 666 | ExitOnFailure(hr, "Failed to get CaScript key from custom action data"); | ||
| 667 | |||
| 668 | // read the msi tables | ||
| 669 | hr = WcaBeginUnwrapQuery(&hUserQuery, &pwzCustomActionData); | ||
| 670 | ExitOnFailure(hr, "Failed to unwrap user query"); | ||
| 671 | |||
| 672 | hr = ScaWebSvcExtRead(&psWseList, &pwzCustomActionData); | ||
| 673 | MessageExitOnFailure(hr, msierrIISFailedReadWebSvcExt, "failed while processing WebServiceExtensions"); | ||
| 674 | |||
| 675 | hr = ScaAppPoolRead(&psapList, hUserQuery, &pwzCustomActionData); | ||
| 676 | MessageExitOnFailure(hr, msierrIISFailedReadAppPool, "failed while processing WebAppPools"); | ||
| 677 | |||
| 678 | // MimeMap, Error and HttpHeader need to be read before the virtual directory and web read | ||
| 679 | hr = ScaMimeMapRead(&psmmList, &pwzCustomActionData); | ||
| 680 | MessageExitOnFailure(hr, msierrIISFailedReadMimeMap, "failed while processing MimeMaps"); | ||
| 681 | |||
| 682 | hr = ScaHttpHeaderRead(&pshhList, &pwzCustomActionData); | ||
| 683 | MessageExitOnFailure(hr, msierrIISFailedReadHttpHeader, "failed while processing HttpHeaders"); | ||
| 684 | |||
| 685 | hr = ScaWebErrorRead(&psweList, &pwzCustomActionData); | ||
| 686 | MessageExitOnFailure(hr, msierrIISFailedReadWebError, "failed while processing WebErrors"); | ||
| 687 | |||
| 688 | hr = WcaBeginUnwrapQuery(&hWebDirPropQuery, &pwzCustomActionData); | ||
| 689 | ExitOnFailure(hr, "Failed to unwrap web dir properties query"); | ||
| 690 | |||
| 691 | hr = WcaBeginUnwrapQuery(&hSslCertQuery, &pwzCustomActionData); | ||
| 692 | ExitOnFailure(hr, "Failed to unwrap ssl certificate query"); | ||
| 693 | |||
| 694 | hr = WcaBeginUnwrapQuery(&hWebLogQuery, &pwzCustomActionData); | ||
| 695 | ExitOnFailure(hr, "Failed to unwrap web log query"); | ||
| 696 | |||
| 697 | hr = WcaBeginUnwrapQuery(&hWebAppQuery, &pwzCustomActionData); | ||
| 698 | ExitOnFailure(hr, "Failed to unwrap web application query"); | ||
| 699 | |||
| 700 | hr = WcaBeginUnwrapQuery(&hWebAppExtQuery, &pwzCustomActionData); | ||
| 701 | ExitOnFailure(hr, "Failed to unwrap web application extension query"); | ||
| 702 | |||
| 703 | hr = ScaWebsRead7(&pswList, &pshhList, &psweList, hUserQuery, hWebDirPropQuery, hSslCertQuery, hWebLogQuery, hWebAppQuery, hWebAppExtQuery, &pwzCustomActionData); | ||
| 704 | MessageExitOnFailure(hr, msierrIISFailedReadWebSite, "failed while processing WebSites"); | ||
| 705 | |||
| 706 | hr = WcaBeginUnwrapQuery(&hWebBaseQuery, &pwzCustomActionData); | ||
| 707 | ExitOnFailure(hr, "Failed to unwrap web base query"); | ||
| 708 | |||
| 709 | hr = ScaWebDirsRead7(pswList, hUserQuery, hWebBaseQuery, hWebDirPropQuery, hWebAppQuery, hWebAppExtQuery, &pwzCustomActionData, &pswdList); | ||
| 710 | MessageExitOnFailure(hr, msierrIISFailedReadWebDirs, "failed while processing WebDirs"); | ||
| 711 | |||
| 712 | hr = ScaVirtualDirsRead7(pswList, &psvdList, &psmmList, &pshhList, &psweList, hUserQuery, hWebBaseQuery, hWebDirPropQuery, hWebAppQuery, hWebAppExtQuery, &pwzCustomActionData); | ||
| 713 | MessageExitOnFailure(hr, msierrIISFailedReadVDirs, "failed while processing WebVirtualDirs"); | ||
| 714 | |||
| 715 | hr = ScaFiltersRead7(pswList, hWebBaseQuery, &psfList, &pwzCustomActionData); | ||
| 716 | MessageExitOnFailure(hr, msierrIISFailedReadFilters, "failed while processing WebFilters"); | ||
| 717 | |||
| 718 | hr = ScaPropertyRead(&pspList, &pwzCustomActionData); | ||
| 719 | MessageExitOnFailure(hr, msierrIISFailedReadProp, "failed while processing WebProperties"); | ||
| 720 | |||
| 721 | // do uninstall actions (order is important!) | ||
| 722 | hr = ScaPropertyUninstall7(pspList); | ||
| 723 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallProp, "failed to uninstall IIS properties"); | ||
| 724 | |||
| 725 | hr = ScaFiltersUninstall7(psfList); | ||
| 726 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallFilters, "failed to schedule uninstall of filters"); | ||
| 727 | |||
| 728 | hr = ScaVirtualDirsUninstall7(psvdList); | ||
| 729 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallVDirs, "failed to schedule uninstall of virtual directories"); | ||
| 730 | |||
| 731 | hr = ScaWebDirsUninstall7(pswdList); | ||
| 732 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallWebDirs, "failed to schedule uninstall of web directories"); | ||
| 733 | |||
| 734 | hr = ScaWebsUninstall7(pswList); | ||
| 735 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallWebs, "failed to schedule uninstall of webs"); | ||
| 736 | |||
| 737 | hr = ScaAppPoolUninstall7(psapList); | ||
| 738 | MessageExitOnFailure(hr, msierrIISFailedSchedUninstallAppPool, "failed to schedule uninstall of AppPools"); | ||
| 739 | |||
| 740 | |||
| 741 | // do install actions (order is important!) | ||
| 742 | // ScaWebSvcExtCommit contains both uninstall and install actions. | ||
| 743 | hr = ScaWebSvcExtCommit7(psWseList); | ||
| 744 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallWebSvcExt, "failed to schedule install/uninstall of WebSvcExt"); | ||
| 745 | |||
| 746 | hr = ScaAppPoolInstall7(psapList); | ||
| 747 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallAppPool, "failed to schedule install of AppPools"); | ||
| 748 | |||
| 749 | hr = ScaWebsInstall7(pswList, psapList); | ||
| 750 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallWebs, "failed to schedule install of webs"); | ||
| 751 | |||
| 752 | hr = ScaWebDirsInstall7(pswdList, psapList); | ||
| 753 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallWebDirs, "failed to schedule install of web directories"); | ||
| 754 | |||
| 755 | hr = ScaVirtualDirsInstall7(psvdList, psapList); | ||
| 756 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallVDirs, "failed to schedule install of virtual directories"); | ||
| 757 | |||
| 758 | hr = ScaFiltersInstall7(psfList); | ||
| 759 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallFilters, "failed to schedule install of filters"); | ||
| 760 | |||
| 761 | hr = ScaPropertyInstall7(pspList); | ||
| 762 | MessageExitOnFailure(hr, msierrIISFailedSchedInstallProp, "failed to schedule install of properties"); | ||
| 763 | |||
| 764 | hr = ScaWriteConfigurationScript(pwzScriptKey); | ||
| 765 | ExitOnFailure(hr, "failed to schedule metabase configuration"); | ||
| 766 | |||
| 767 | LExit: | ||
| 768 | ReleaseNullStr(pwzScriptKey); | ||
| 769 | ReleaseNullStr(pwzCustomActionData); | ||
| 770 | |||
| 771 | WcaFinishUnwrapQuery(hUserQuery); | ||
| 772 | WcaFinishUnwrapQuery(hWebBaseQuery); | ||
| 773 | WcaFinishUnwrapQuery(hWebDirPropQuery); | ||
| 774 | WcaFinishUnwrapQuery(hSslCertQuery); | ||
| 775 | WcaFinishUnwrapQuery(hWebLogQuery); | ||
| 776 | WcaFinishUnwrapQuery(hWebAppQuery); | ||
| 777 | WcaFinishUnwrapQuery(hWebAppExtQuery); | ||
| 778 | |||
| 779 | if (psWseList) | ||
| 780 | { | ||
| 781 | ScaWebSvcExtFreeList(psWseList); | ||
| 782 | } | ||
| 783 | |||
| 784 | if (psfList) | ||
| 785 | { | ||
| 786 | ScaFiltersFreeList(psfList); | ||
| 787 | } | ||
| 788 | |||
| 789 | if (psvdList) | ||
| 790 | { | ||
| 791 | ScaVirtualDirsFreeList7(psvdList); | ||
| 792 | } | ||
| 793 | |||
| 794 | if (pswdList) | ||
| 795 | { | ||
| 796 | ScaWebDirsFreeList7(pswdList); | ||
| 797 | } | ||
| 798 | |||
| 799 | if (pswList) | ||
| 800 | { | ||
| 801 | ScaWebsFreeList7(pswList); | ||
| 802 | } | ||
| 803 | |||
| 804 | if (psmmList) | ||
| 805 | { | ||
| 806 | ScaMimeMapFreeList(psmmList); | ||
| 807 | } | ||
| 808 | |||
| 809 | if (pshhList) | ||
| 810 | { | ||
| 811 | ScaHttpHeaderCheckList(pshhList); | ||
| 812 | ScaHttpHeaderFreeList(pshhList); | ||
| 813 | } | ||
| 814 | |||
| 815 | if (psweList) | ||
| 816 | { | ||
| 817 | ScaWebErrorCheckList(psweList); | ||
| 818 | ScaWebErrorFreeList(psweList); | ||
| 819 | } | ||
| 820 | |||
| 821 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 822 | return WcaFinalize(er); | ||
| 823 | } | ||
