diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-03 17:50:50 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-07 19:44:36 -0500 |
| commit | 68ec803fc7f48bb0e0463dc45f6ce40e1f07dbf5 (patch) | |
| tree | b40803c4ba8d5312ed3d95c66778c2bc87cf0de9 /src/burn/engine/cache.cpp | |
| parent | 8810aa8908ed7887616d86dd5fb821fcfa92f444 (diff) | |
| download | wix-68ec803fc7f48bb0e0463dc45f6ce40e1f07dbf5.tar.gz wix-68ec803fc7f48bb0e0463dc45f6ce40e1f07dbf5.tar.bz2 wix-68ec803fc7f48bb0e0463dc45f6ce40e1f07dbf5.zip | |
Make sure base paths are fully qualified in Burn.
Diffstat (limited to 'src/burn/engine/cache.cpp')
| -rw-r--r-- | src/burn/engine/cache.cpp | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/burn/engine/cache.cpp b/src/burn/engine/cache.cpp index 5eacb20d..cf9de1c3 100644 --- a/src/burn/engine/cache.cpp +++ b/src/burn/engine/cache.cpp | |||
| @@ -188,13 +188,18 @@ extern "C" HRESULT CacheInitialize( | |||
| 188 | hr = PolcReadString(POLICY_BURN_REGISTRY_PATH, L"PackageCache", NULL, &pCache->sczCurrentMachinePackageCache); | 188 | hr = PolcReadString(POLICY_BURN_REGISTRY_PATH, L"PackageCache", NULL, &pCache->sczCurrentMachinePackageCache); |
| 189 | ExitOnFailure(hr, "Failed to read PackageCache policy directory."); | 189 | ExitOnFailure(hr, "Failed to read PackageCache policy directory."); |
| 190 | 190 | ||
| 191 | if (pCache->sczCurrentMachinePackageCache) | 191 | if (pCache->sczCurrentMachinePackageCache && PathIsFullyQualified(pCache->sczCurrentMachinePackageCache)) |
| 192 | { | 192 | { |
| 193 | hr = PathBackslashTerminate(&pCache->sczCurrentMachinePackageCache); | 193 | hr = PathBackslashTerminate(&pCache->sczCurrentMachinePackageCache); |
| 194 | ExitOnFailure(hr, "Failed to backslash terminate redirected per-machine package cache directory name."); | 194 | ExitOnFailure(hr, "Failed to backslash terminate redirected per-machine package cache directory name."); |
| 195 | } | 195 | } |
| 196 | else | 196 | else |
| 197 | { | 197 | { |
| 198 | if (pCache->sczCurrentMachinePackageCache) | ||
| 199 | { | ||
| 200 | LogErrorId(E_INVALIDARG, MSG_INVALID_POLICY_MACHINE_PACKAGE_CACHE, pCache->sczCurrentMachinePackageCache, NULL, NULL); | ||
| 201 | } | ||
| 202 | |||
| 198 | hr = StrAllocString(&pCache->sczCurrentMachinePackageCache, pCache->sczDefaultMachinePackageCache, 0); | 203 | hr = StrAllocString(&pCache->sczCurrentMachinePackageCache, pCache->sczDefaultMachinePackageCache, 0); |
| 199 | ExitOnFailure(hr, "Failed to copy default package cache directory to current package cache directory."); | 204 | ExitOnFailure(hr, "Failed to copy default package cache directory to current package cache directory."); |
| 200 | } | 205 | } |
| @@ -251,7 +256,7 @@ extern "C" HRESULT CacheInitializeSources( | |||
| 251 | hr = CacheGetCompletedPath(pCache, pRegistration->fPerMachine, pRegistration->sczId, &sczCompletedFolder); | 256 | hr = CacheGetCompletedPath(pCache, pRegistration->fPerMachine, pRegistration->sczId, &sczCompletedFolder); |
| 252 | ExitOnFailure(hr, "Failed to get completed path for bundle."); | 257 | ExitOnFailure(hr, "Failed to get completed path for bundle."); |
| 253 | 258 | ||
| 254 | hr = PathConcatRelativeToBase(sczCompletedFolder, pRegistration->sczExecutableName, &sczCompletedPath); | 259 | hr = PathConcatRelativeToFullyQualifiedBase(sczCompletedFolder, pRegistration->sczExecutableName, &sczCompletedPath); |
| 255 | ExitOnFailure(hr, "Failed to combine working path with engine file name."); | 260 | ExitOnFailure(hr, "Failed to combine working path with engine file name."); |
| 256 | 261 | ||
| 257 | hr = PathCompareCanonicalized(sczCurrentPath, sczCompletedPath, &fPathEqual); | 262 | hr = PathCompareCanonicalized(sczCurrentPath, sczCompletedPath, &fPathEqual); |
| @@ -342,15 +347,16 @@ extern "C" HRESULT CacheEnsureBaseWorkingFolder( | |||
| 342 | { | 347 | { |
| 343 | for (DWORD i = 0; i < pCache->cPotentialBaseWorkingFolders; ++i) | 348 | for (DWORD i = 0; i < pCache->cPotentialBaseWorkingFolders; ++i) |
| 344 | { | 349 | { |
| 345 | hr = PathConcatRelativeToBase(pCache->rgsczPotentialBaseWorkingFolders[i], pCache->wzGuid, &sczPotential); | 350 | hr = PathConcatRelativeToFullyQualifiedBase(pCache->rgsczPotentialBaseWorkingFolders[i], pCache->wzGuid, &sczPotential); |
| 346 | ExitOnFailure(hr, "Failed to append random guid on to potential path for working folder."); | ||
| 347 | |||
| 348 | hr = DirEnsureExists(sczPotential, NULL); | ||
| 349 | if (SUCCEEDED(hr)) | 351 | if (SUCCEEDED(hr)) |
| 350 | { | 352 | { |
| 351 | pCache->sczBaseWorkingFolder = sczPotential; | 353 | hr = DirEnsureExists(sczPotential, NULL); |
| 352 | sczPotential = NULL; | 354 | if (SUCCEEDED(hr)) |
| 353 | break; | 355 | { |
| 356 | pCache->sczBaseWorkingFolder = sczPotential; | ||
| 357 | sczPotential = NULL; | ||
| 358 | break; | ||
| 359 | } | ||
| 354 | } | 360 | } |
| 355 | 361 | ||
| 356 | LogErrorId(hr, MSG_INVALID_BASE_WORKING_FOLDER, sczPotential, NULL, NULL); | 362 | LogErrorId(hr, MSG_INVALID_BASE_WORKING_FOLDER, sczPotential, NULL, NULL); |
| @@ -414,7 +420,7 @@ extern "C" HRESULT CacheCalculateBundleLayoutWorkingPath( | |||
| 414 | 420 | ||
| 415 | HRESULT hr = S_OK; | 421 | HRESULT hr = S_OK; |
| 416 | 422 | ||
| 417 | hr = PathConcatRelativeToBase(pCache->sczAcquisitionFolder, wzBundleId, psczWorkingPath); | 423 | hr = PathConcatRelativeToFullyQualifiedBase(pCache->sczAcquisitionFolder, wzBundleId, psczWorkingPath); |
| 418 | ExitOnFailure(hr, "Failed to append bundle id for bundle layout working path."); | 424 | ExitOnFailure(hr, "Failed to append bundle id for bundle layout working path."); |
| 419 | 425 | ||
| 420 | LExit: | 426 | LExit: |
| @@ -431,7 +437,7 @@ extern "C" HRESULT CacheCalculatePayloadWorkingPath( | |||
| 431 | 437 | ||
| 432 | HRESULT hr = S_OK; | 438 | HRESULT hr = S_OK; |
| 433 | 439 | ||
| 434 | hr = PathConcatRelativeToBase(pCache->sczAcquisitionFolder, pPayload->sczKey, psczWorkingPath); | 440 | hr = PathConcatRelativeToFullyQualifiedBase(pCache->sczAcquisitionFolder, pPayload->sczKey, psczWorkingPath); |
| 435 | ExitOnFailure(hr, "Failed to append Id as payload unverified path."); | 441 | ExitOnFailure(hr, "Failed to append Id as payload unverified path."); |
| 436 | 442 | ||
| 437 | LExit: | 443 | LExit: |
| @@ -448,7 +454,7 @@ extern "C" HRESULT CacheCalculateContainerWorkingPath( | |||
| 448 | 454 | ||
| 449 | HRESULT hr = S_OK; | 455 | HRESULT hr = S_OK; |
| 450 | 456 | ||
| 451 | hr = PathConcatRelativeToBase(pCache->sczAcquisitionFolder, pContainer->sczHash, psczWorkingPath); | 457 | hr = PathConcatRelativeToFullyQualifiedBase(pCache->sczAcquisitionFolder, pContainer->sczHash, psczWorkingPath); |
| 452 | ExitOnFailure(hr, "Failed to append hash as container unverified path."); | 458 | ExitOnFailure(hr, "Failed to append hash as container unverified path."); |
| 453 | 459 | ||
| 454 | LExit: | 460 | LExit: |
| @@ -503,7 +509,7 @@ extern "C" HRESULT CacheGetCompletedPath( | |||
| 503 | // GetRootPath returns S_FALSE if the package cache is redirected elsewhere. | 509 | // GetRootPath returns S_FALSE if the package cache is redirected elsewhere. |
| 504 | fRedirected = S_FALSE == hr; | 510 | fRedirected = S_FALSE == hr; |
| 505 | 511 | ||
| 506 | hr = PathConcatRelativeToBase(sczRootPath, wzCacheId, &sczCurrentCompletedPath); | 512 | hr = PathConcatRelativeToFullyQualifiedBase(sczRootPath, wzCacheId, &sczCurrentCompletedPath); |
| 507 | ExitOnFailure(hr, "Failed to construct cache path."); | 513 | ExitOnFailure(hr, "Failed to construct cache path."); |
| 508 | 514 | ||
| 509 | hr = PathBackslashTerminate(&sczCurrentCompletedPath); | 515 | hr = PathBackslashTerminate(&sczCurrentCompletedPath); |
| @@ -516,7 +522,7 @@ extern "C" HRESULT CacheGetCompletedPath( | |||
| 516 | hr = GetRootPath(pCache, fPerMachine, FALSE, &sczRootPath); | 522 | hr = GetRootPath(pCache, fPerMachine, FALSE, &sczRootPath); |
| 517 | ExitOnFailure(hr, "Failed to get old %hs package cache root directory.", fPerMachine ? "per-machine" : "per-user"); | 523 | ExitOnFailure(hr, "Failed to get old %hs package cache root directory.", fPerMachine ? "per-machine" : "per-user"); |
| 518 | 524 | ||
| 519 | hr = PathConcatRelativeToBase(sczRootPath, wzCacheId, &sczDefaultCompletedPath); | 525 | hr = PathConcatRelativeToFullyQualifiedBase(sczRootPath, wzCacheId, &sczDefaultCompletedPath); |
| 520 | ExitOnFailure(hr, "Failed to construct cache path."); | 526 | ExitOnFailure(hr, "Failed to construct cache path."); |
| 521 | 527 | ||
| 522 | hr = PathBackslashTerminate(&sczDefaultCompletedPath); | 528 | hr = PathBackslashTerminate(&sczDefaultCompletedPath); |
| @@ -957,7 +963,7 @@ extern "C" HRESULT CacheLayoutBundle( | |||
| 957 | HRESULT hr = S_OK; | 963 | HRESULT hr = S_OK; |
| 958 | LPWSTR sczTargetPath = NULL; | 964 | LPWSTR sczTargetPath = NULL; |
| 959 | 965 | ||
| 960 | hr = PathConcatRelativeToBase(wzLayoutDirectory, wzExecutableName, &sczTargetPath); | 966 | hr = PathConcatRelativeToFullyQualifiedBase(wzLayoutDirectory, wzExecutableName, &sczTargetPath); |
| 961 | ExitOnFailure(hr, "Failed to combine completed path with engine file name for layout."); | 967 | ExitOnFailure(hr, "Failed to combine completed path with engine file name for layout."); |
| 962 | 968 | ||
| 963 | LogStringLine(REPORT_STANDARD, "Layout bundle from: '%ls' to: '%ls'", wzSourceBundlePath, sczTargetPath); | 969 | LogStringLine(REPORT_STANDARD, "Layout bundle from: '%ls' to: '%ls'", wzSourceBundlePath, sczTargetPath); |
| @@ -992,7 +998,7 @@ extern "C" HRESULT CacheCompleteBundle( | |||
| 992 | hr = CreateCompletedPath(pCache, fPerMachine, wzBundleId, NULL, &sczTargetDirectory); | 998 | hr = CreateCompletedPath(pCache, fPerMachine, wzBundleId, NULL, &sczTargetDirectory); |
| 993 | ExitOnFailure(hr, "Failed to create completed cache path for bundle."); | 999 | ExitOnFailure(hr, "Failed to create completed cache path for bundle."); |
| 994 | 1000 | ||
| 995 | hr = PathConcatRelativeToBase(sczTargetDirectory, wzExecutableName, &sczTargetPath); | 1001 | hr = PathConcatRelativeToFullyQualifiedBase(sczTargetDirectory, wzExecutableName, &sczTargetPath); |
| 996 | ExitOnFailure(hr, "Failed to combine completed path with engine file name."); | 1002 | ExitOnFailure(hr, "Failed to combine completed path with engine file name."); |
| 997 | 1003 | ||
| 998 | // We can't just use wzExecutablePath because we needed to call CreateCompletedPath to ensure that the destination was secured. | 1004 | // We can't just use wzExecutablePath because we needed to call CreateCompletedPath to ensure that the destination was secured. |
| @@ -1045,7 +1051,7 @@ extern "C" HRESULT CacheLayoutContainer( | |||
| 1045 | HRESULT hr = S_OK; | 1051 | HRESULT hr = S_OK; |
| 1046 | LPWSTR sczCachedPath = NULL; | 1052 | LPWSTR sczCachedPath = NULL; |
| 1047 | 1053 | ||
| 1048 | hr = PathConcatRelativeToBase(wzLayoutDirectory, pContainer->sczFilePath, &sczCachedPath); | 1054 | hr = PathConcatRelativeToFullyQualifiedBase(wzLayoutDirectory, pContainer->sczFilePath, &sczCachedPath); |
| 1049 | ExitOnFailure(hr, "Failed to concat complete cached path."); | 1055 | ExitOnFailure(hr, "Failed to concat complete cached path."); |
| 1050 | 1056 | ||
| 1051 | hr = VerifyThenTransferContainer(pContainer, sczCachedPath, wzUnverifiedContainerPath, fMove, pfnCacheMessageHandler, pfnProgress, pContext); | 1057 | hr = VerifyThenTransferContainer(pContainer, sczCachedPath, wzUnverifiedContainerPath, fMove, pfnCacheMessageHandler, pfnProgress, pContext); |
| @@ -1070,7 +1076,7 @@ extern "C" HRESULT CacheLayoutPayload( | |||
| 1070 | HRESULT hr = S_OK; | 1076 | HRESULT hr = S_OK; |
| 1071 | LPWSTR sczCachedPath = NULL; | 1077 | LPWSTR sczCachedPath = NULL; |
| 1072 | 1078 | ||
| 1073 | hr = PathConcatRelativeToBase(wzLayoutDirectory, pPayload->sczFilePath, &sczCachedPath); | 1079 | hr = PathConcatRelativeToFullyQualifiedBase(wzLayoutDirectory, pPayload->sczFilePath, &sczCachedPath); |
| 1074 | ExitOnFailure(hr, "Failed to concat complete cached path."); | 1080 | ExitOnFailure(hr, "Failed to concat complete cached path."); |
| 1075 | 1081 | ||
| 1076 | hr = VerifyThenTransferPayload(pPayload, sczCachedPath, wzUnverifiedPayloadPath, fMove, pfnCacheMessageHandler, pfnProgress, pContext); | 1082 | hr = VerifyThenTransferPayload(pPayload, sczCachedPath, wzUnverifiedPayloadPath, fMove, pfnCacheMessageHandler, pfnProgress, pContext); |
| @@ -1165,7 +1171,7 @@ extern "C" HRESULT CacheVerifyContainer( | |||
| 1165 | HRESULT hr = S_OK; | 1171 | HRESULT hr = S_OK; |
| 1166 | LPWSTR sczCachedPath = NULL; | 1172 | LPWSTR sczCachedPath = NULL; |
| 1167 | 1173 | ||
| 1168 | hr = PathConcatRelativeToBase(wzCachedDirectory, pContainer->sczFilePath, &sczCachedPath); | 1174 | hr = PathConcatRelativeToFullyQualifiedBase(wzCachedDirectory, pContainer->sczFilePath, &sczCachedPath); |
| 1169 | ExitOnFailure(hr, "Failed to concat complete cached path."); | 1175 | ExitOnFailure(hr, "Failed to concat complete cached path."); |
| 1170 | 1176 | ||
| 1171 | hr = VerifyFileAgainstContainer(pContainer, sczCachedPath, TRUE, BURN_CACHE_STEP_HASH_TO_SKIP_ACQUIRE, pfnCacheMessageHandler, pfnProgress, pContext); | 1177 | hr = VerifyFileAgainstContainer(pContainer, sczCachedPath, TRUE, BURN_CACHE_STEP_HASH_TO_SKIP_ACQUIRE, pfnCacheMessageHandler, pfnProgress, pContext); |
| @@ -1187,7 +1193,7 @@ extern "C" HRESULT CacheVerifyPayload( | |||
| 1187 | HRESULT hr = S_OK; | 1193 | HRESULT hr = S_OK; |
| 1188 | LPWSTR sczCachedPath = NULL; | 1194 | LPWSTR sczCachedPath = NULL; |
| 1189 | 1195 | ||
| 1190 | hr = PathConcatRelativeToBase(wzCachedDirectory, pPayload->sczFilePath, &sczCachedPath); | 1196 | hr = PathConcatRelativeToFullyQualifiedBase(wzCachedDirectory, pPayload->sczFilePath, &sczCachedPath); |
| 1191 | ExitOnFailure(hr, "Failed to concat complete cached path."); | 1197 | ExitOnFailure(hr, "Failed to concat complete cached path."); |
| 1192 | 1198 | ||
| 1193 | hr = VerifyFileAgainstPayload(pPayload, sczCachedPath, TRUE, BURN_CACHE_STEP_HASH_TO_SKIP_ACQUIRE, pfnCacheMessageHandler, pfnProgress, pContext); | 1199 | hr = VerifyFileAgainstPayload(pPayload, sczCachedPath, TRUE, BURN_CACHE_STEP_HASH_TO_SKIP_ACQUIRE, pfnCacheMessageHandler, pfnProgress, pContext); |
| @@ -1478,7 +1484,7 @@ static HRESULT CalculateWorkingFolders( | |||
| 1478 | pCache->wzGuid[GUID_STRING_LENGTH - 1] = L'\\'; | 1484 | pCache->wzGuid[GUID_STRING_LENGTH - 1] = L'\\'; |
| 1479 | pCache->wzGuid[GUID_STRING_LENGTH] = L'\0'; | 1485 | pCache->wzGuid[GUID_STRING_LENGTH] = L'\0'; |
| 1480 | 1486 | ||
| 1481 | hr = PathConcatRelativeToBase(sczBaseAcquisitionPath, pCache->wzGuid, &pCache->sczAcquisitionFolder); | 1487 | hr = PathConcatRelativeToFullyQualifiedBase(sczBaseAcquisitionPath, pCache->wzGuid, &pCache->sczAcquisitionFolder); |
| 1482 | ExitOnFailure(hr, "Failed to append random guid on to temp path for acquisition folder."); | 1488 | ExitOnFailure(hr, "Failed to append random guid on to temp path for acquisition folder."); |
| 1483 | 1489 | ||
| 1484 | LExit: | 1490 | LExit: |
| @@ -1626,7 +1632,7 @@ static HRESULT CreateCompletedPath( | |||
| 1626 | else | 1632 | else |
| 1627 | { | 1633 | { |
| 1628 | // Get the cache completed file path. | 1634 | // Get the cache completed file path. |
| 1629 | hr = PathConcatRelativeToBase(sczCacheDirectory, wzFilePath, &sczCacheFile); | 1635 | hr = PathConcatRelativeToFullyQualifiedBase(sczCacheDirectory, wzFilePath, &sczCacheFile); |
| 1630 | ExitOnFailure(hr, "Failed to construct cache file."); | 1636 | ExitOnFailure(hr, "Failed to construct cache file."); |
| 1631 | 1637 | ||
| 1632 | // Don't reset permissions here. The payload's package must reset its cache folder when it starts caching. | 1638 | // Don't reset permissions here. The payload's package must reset its cache folder when it starts caching. |
| @@ -1664,7 +1670,7 @@ static HRESULT CreateUnverifiedPath( | |||
| 1664 | pCache->fUnverifiedCacheFolderCreated = TRUE; | 1670 | pCache->fUnverifiedCacheFolderCreated = TRUE; |
| 1665 | } | 1671 | } |
| 1666 | 1672 | ||
| 1667 | hr = PathConcatRelativeToBase(sczUnverifiedCacheFolder, wzPayloadId, psczUnverifiedPayloadPath); | 1673 | hr = PathConcatRelativeToFullyQualifiedBase(sczUnverifiedCacheFolder, wzPayloadId, psczUnverifiedPayloadPath); |
| 1668 | ExitOnFailure(hr, "Failed to concat payload id to unverified folder path."); | 1674 | ExitOnFailure(hr, "Failed to concat payload id to unverified folder path."); |
| 1669 | 1675 | ||
| 1670 | LExit: | 1676 | LExit: |
| @@ -2085,13 +2091,13 @@ static HRESULT CopyEngineToWorkingFolder( | |||
| 2085 | hr = CacheEnsureBaseWorkingFolder(pCache, &sczWorkingFolder); | 2091 | hr = CacheEnsureBaseWorkingFolder(pCache, &sczWorkingFolder); |
| 2086 | ExitOnFailure(hr, "Failed to create working path to copy engine."); | 2092 | ExitOnFailure(hr, "Failed to create working path to copy engine."); |
| 2087 | 2093 | ||
| 2088 | hr = PathConcatRelativeToBase(sczWorkingFolder, wzWorkingFolderName, &sczTargetDirectory); | 2094 | hr = PathConcatRelativeToFullyQualifiedBase(sczWorkingFolder, wzWorkingFolderName, &sczTargetDirectory); |
| 2089 | ExitOnFailure(hr, "Failed to calculate the bundle working folder target name."); | 2095 | ExitOnFailure(hr, "Failed to calculate the bundle working folder target name."); |
| 2090 | 2096 | ||
| 2091 | hr = DirEnsureExists(sczTargetDirectory, NULL); | 2097 | hr = DirEnsureExists(sczTargetDirectory, NULL); |
| 2092 | ExitOnFailure(hr, "Failed create bundle working folder."); | 2098 | ExitOnFailure(hr, "Failed create bundle working folder."); |
| 2093 | 2099 | ||
| 2094 | hr = PathConcatRelativeToBase(sczTargetDirectory, wzExecutableName, &sczTargetPath); | 2100 | hr = PathConcatRelativeToFullyQualifiedBase(sczTargetDirectory, wzExecutableName, &sczTargetPath); |
| 2095 | ExitOnFailure(hr, "Failed to combine working path with engine file name."); | 2101 | ExitOnFailure(hr, "Failed to combine working path with engine file name."); |
| 2096 | 2102 | ||
| 2097 | // Copy the engine without any attached containers to the working path. | 2103 | // Copy the engine without any attached containers to the working path. |
