diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-16 10:48:38 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-19 23:12:55 -0500 |
| commit | 8c77de737aaea1b4857c724c730446bca8da2dd0 (patch) | |
| tree | 56159f2ea1f8407ad4b4b723ba0a75d8dcc09ec6 /src | |
| parent | d7b0329e16ba9cae4a33970e26591ae5f1d98f0d (diff) | |
| download | wix-8c77de737aaea1b4857c724c730446bca8da2dd0.tar.gz wix-8c77de737aaea1b4857c724c730446bca8da2dd0.tar.bz2 wix-8c77de737aaea1b4857c724c730446bca8da2dd0.zip | |
Elevate for CacheVerifyContainer/Payload.
Diffstat (limited to 'src')
| -rw-r--r-- | src/engine/apply.cpp | 15 | ||||
| -rw-r--r-- | src/engine/cache.cpp | 68 | ||||
| -rw-r--r-- | src/engine/elevation.cpp | 136 | ||||
| -rw-r--r-- | src/engine/elevation.h | 7 | ||||
| -rw-r--r-- | src/engine/engine.mc | 14 |
5 files changed, 209 insertions, 31 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp index f40b3841..0eb8a710 100644 --- a/src/engine/apply.cpp +++ b/src/engine/apply.cpp | |||
| @@ -538,6 +538,9 @@ extern "C" HRESULT ApplyCache( | |||
| 538 | 538 | ||
| 539 | if (!pPackage->fPerMachine && !cacheContext.wzLayoutDirectory) | 539 | if (!pPackage->fPerMachine && !cacheContext.wzLayoutDirectory) |
| 540 | { | 540 | { |
| 541 | hr = CacheGetCompletedPath(FALSE, pPackage->sczCacheId, &pPackage->sczCacheFolder); | ||
| 542 | ExitOnFailure(hr, "Failed to get cached path for package with cache id: %ls", pPackage->sczCacheId); | ||
| 543 | |||
| 541 | cacheContext.hPipe = INVALID_HANDLE_VALUE; | 544 | cacheContext.hPipe = INVALID_HANDLE_VALUE; |
| 542 | } | 545 | } |
| 543 | 546 | ||
| @@ -800,12 +803,6 @@ static HRESULT ApplyCachePackage( | |||
| 800 | HRESULT hr = S_OK; | 803 | HRESULT hr = S_OK; |
| 801 | BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION cachePackageCompleteAction = BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE; | 804 | BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION cachePackageCompleteAction = BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE; |
| 802 | 805 | ||
| 803 | if (!pPackage->sczCacheFolder && !pContext->wzLayoutDirectory) | ||
| 804 | { | ||
| 805 | hr = CacheGetCompletedPath(pPackage->fPerMachine, pPackage->sczCacheId, &pPackage->sczCacheFolder); | ||
| 806 | ExitOnFailure(hr, "Failed to get cached path for package with cache id: %ls", pPackage->sczCacheId); | ||
| 807 | } | ||
| 808 | |||
| 809 | for (;;) | 806 | for (;;) |
| 810 | { | 807 | { |
| 811 | hr = UserExperienceOnCachePackageBegin(pContext->pUX, pPackage->sczId, pPackage->payloads.cPayloads, pPackage->payloads.qwTotalSize); | 808 | hr = UserExperienceOnCachePackageBegin(pContext->pUX, pPackage->sczId, pPackage->payloads.cPayloads, pPackage->payloads.qwTotalSize); |
| @@ -1038,7 +1035,11 @@ static HRESULT ApplyCacheVerifyContainerOrPayload( | |||
| 1038 | hr = UserExperienceOnCacheContainerOrPayloadVerifyBegin(pContext->pUX, wzPackageOrContainerId, wzPayloadId); | 1035 | hr = UserExperienceOnCacheContainerOrPayloadVerifyBegin(pContext->pUX, wzPackageOrContainerId, wzPayloadId); |
| 1039 | ExitOnRootFailure(hr, "BA aborted cache container or payload verify begin."); | 1036 | ExitOnRootFailure(hr, "BA aborted cache container or payload verify begin."); |
| 1040 | 1037 | ||
| 1041 | if (pContainer) | 1038 | if (INVALID_HANDLE_VALUE != pContext->hPipe) |
| 1039 | { | ||
| 1040 | hr = ElevationCacheVerifyContainerOrPayload(pContext->hPipe, pContainer, pPackage, pPayload, pContext->wzLayoutDirectory); | ||
| 1041 | } | ||
| 1042 | else if (pContainer) | ||
| 1042 | { | 1043 | { |
| 1043 | hr = CacheVerifyContainer(pContainer, pContext->wzLayoutDirectory); | 1044 | hr = CacheVerifyContainer(pContainer, pContext->wzLayoutDirectory); |
| 1044 | } | 1045 | } |
diff --git a/src/engine/cache.cpp b/src/engine/cache.cpp index 2299d26d..9aa94d1d 100644 --- a/src/engine/cache.cpp +++ b/src/engine/cache.cpp | |||
| @@ -59,11 +59,13 @@ static HRESULT TransferWorkingPathToUnverifiedPath( | |||
| 59 | ); | 59 | ); |
| 60 | static HRESULT VerifyFileAgainstContainer( | 60 | static HRESULT VerifyFileAgainstContainer( |
| 61 | __in BURN_CONTAINER* pContainer, | 61 | __in BURN_CONTAINER* pContainer, |
| 62 | __in_z LPCWSTR wzVerifyPath | 62 | __in_z LPCWSTR wzVerifyPath, |
| 63 | __in BOOL fAlreadyCached | ||
| 63 | ); | 64 | ); |
| 64 | static HRESULT VerifyFileAgainstPayload( | 65 | static HRESULT VerifyFileAgainstPayload( |
| 65 | __in BURN_PAYLOAD* pPayload, | 66 | __in BURN_PAYLOAD* pPayload, |
| 66 | __in_z LPCWSTR wzVerifyPath | 67 | __in_z LPCWSTR wzVerifyPath, |
| 68 | __in BOOL fAlreadyCached | ||
| 67 | ); | 69 | ); |
| 68 | static HRESULT ResetPathPermissions( | 70 | static HRESULT ResetPathPermissions( |
| 69 | __in BOOL fPerMachine, | 71 | __in BOOL fPerMachine, |
| @@ -896,19 +898,11 @@ extern "C" HRESULT CacheCompletePayload( | |||
| 896 | ExitOnFailure(hr, "Failed to concat complete cached path."); | 898 | ExitOnFailure(hr, "Failed to concat complete cached path."); |
| 897 | 899 | ||
| 898 | // If the cached file matches what we expected, we're good. | 900 | // If the cached file matches what we expected, we're good. |
| 899 | hr = VerifyFileAgainstPayload(pPayload, sczCachedPath); | 901 | hr = VerifyFileAgainstPayload(pPayload, sczCachedPath, TRUE); |
| 900 | if (SUCCEEDED(hr)) | 902 | if (SUCCEEDED(hr)) |
| 901 | { | 903 | { |
| 902 | ::DecryptFileW(sczCachedPath, 0); // Let's try to make sure it's not encrypted. | ||
| 903 | LogId(REPORT_STANDARD, MSG_VERIFIED_EXISTING_PAYLOAD, pPayload->sczKey, sczCachedPath); | ||
| 904 | ExitFunction(); | 904 | ExitFunction(); |
| 905 | } | 905 | } |
| 906 | else if (E_PATHNOTFOUND != hr && E_FILENOTFOUND != hr) | ||
| 907 | { | ||
| 908 | LogErrorId(hr, MSG_FAILED_VERIFY_PAYLOAD, pPayload->sczKey, sczCachedPath, NULL); | ||
| 909 | |||
| 910 | FileEnsureDelete(sczCachedPath); // if the file existed but did not verify correctly, make it go away. | ||
| 911 | } | ||
| 912 | 906 | ||
| 913 | hr = CreateUnverifiedPath(fPerMachine, pPayload->sczKey, &sczUnverifiedPayloadPath); | 907 | hr = CreateUnverifiedPath(fPerMachine, pPayload->sczKey, &sczUnverifiedPayloadPath); |
| 914 | ExitOnFailure(hr, "Failed to create unverified path."); | 908 | ExitOnFailure(hr, "Failed to create unverified path."); |
| @@ -928,14 +922,8 @@ extern "C" HRESULT CacheCompletePayload( | |||
| 928 | hr = ResetPathPermissions(fPerMachine, sczUnverifiedPayloadPath); | 922 | hr = ResetPathPermissions(fPerMachine, sczUnverifiedPayloadPath); |
| 929 | ExitOnFailure(hr, "Failed to reset permissions on unverified cached payload: %ls", pPayload->sczKey); | 923 | ExitOnFailure(hr, "Failed to reset permissions on unverified cached payload: %ls", pPayload->sczKey); |
| 930 | 924 | ||
| 931 | hr = VerifyFileAgainstPayload(pPayload, sczUnverifiedPayloadPath); | 925 | hr = VerifyFileAgainstPayload(pPayload, sczUnverifiedPayloadPath, FALSE); |
| 932 | if (FAILED(hr)) | 926 | LogExitOnFailure(hr, MSG_FAILED_VERIFY_PAYLOAD, "Failed to verify payload: %ls at path: %ls", pPayload->sczKey, sczUnverifiedPayloadPath, NULL); |
| 933 | { | ||
| 934 | LogErrorId(hr, MSG_FAILED_VERIFY_PAYLOAD, pPayload->sczKey, sczUnverifiedPayloadPath, NULL); | ||
| 935 | |||
| 936 | FileEnsureDelete(sczUnverifiedPayloadPath); // if the file did not verify correctly, make it go away. | ||
| 937 | ExitFunction(); | ||
| 938 | } | ||
| 939 | 927 | ||
| 940 | LogId(REPORT_STANDARD, MSG_VERIFIED_ACQUIRED_PAYLOAD, pPayload->sczKey, sczUnverifiedPayloadPath, fMove ? "moving" : "copying", sczCachedPath); | 928 | LogId(REPORT_STANDARD, MSG_VERIFIED_ACQUIRED_PAYLOAD, pPayload->sczKey, sczUnverifiedPayloadPath, fMove ? "moving" : "copying", sczCachedPath); |
| 941 | 929 | ||
| @@ -963,7 +951,7 @@ extern "C" HRESULT CacheVerifyContainer( | |||
| 963 | hr = PathConcat(wzCachedDirectory, pContainer->sczFilePath, &sczCachedPath); | 951 | hr = PathConcat(wzCachedDirectory, pContainer->sczFilePath, &sczCachedPath); |
| 964 | ExitOnFailure(hr, "Failed to concat complete cached path."); | 952 | ExitOnFailure(hr, "Failed to concat complete cached path."); |
| 965 | 953 | ||
| 966 | hr = VerifyFileAgainstContainer(pContainer, sczCachedPath); | 954 | hr = VerifyFileAgainstContainer(pContainer, sczCachedPath, TRUE); |
| 967 | 955 | ||
| 968 | LExit: | 956 | LExit: |
| 969 | ReleaseStr(sczCachedPath); | 957 | ReleaseStr(sczCachedPath); |
| @@ -982,7 +970,7 @@ extern "C" HRESULT CacheVerifyPayload( | |||
| 982 | hr = PathConcat(wzCachedDirectory, pPayload->sczFilePath, &sczCachedPath); | 970 | hr = PathConcat(wzCachedDirectory, pPayload->sczFilePath, &sczCachedPath); |
| 983 | ExitOnFailure(hr, "Failed to concat complete cached path."); | 971 | ExitOnFailure(hr, "Failed to concat complete cached path."); |
| 984 | 972 | ||
| 985 | hr = VerifyFileAgainstPayload(pPayload, sczCachedPath); | 973 | hr = VerifyFileAgainstPayload(pPayload, sczCachedPath, TRUE); |
| 986 | 974 | ||
| 987 | LExit: | 975 | LExit: |
| 988 | ReleaseStr(sczCachedPath); | 976 | ReleaseStr(sczCachedPath); |
| @@ -1460,7 +1448,8 @@ LExit: | |||
| 1460 | 1448 | ||
| 1461 | static HRESULT VerifyFileAgainstContainer( | 1449 | static HRESULT VerifyFileAgainstContainer( |
| 1462 | __in BURN_CONTAINER* pContainer, | 1450 | __in BURN_CONTAINER* pContainer, |
| 1463 | __in_z LPCWSTR wzVerifyPath | 1451 | __in_z LPCWSTR wzVerifyPath, |
| 1452 | __in BOOL fAlreadyCached | ||
| 1464 | ) | 1453 | ) |
| 1465 | { | 1454 | { |
| 1466 | HRESULT hr = S_OK; | 1455 | HRESULT hr = S_OK; |
| @@ -1484,15 +1473,32 @@ static HRESULT VerifyFileAgainstContainer( | |||
| 1484 | ExitOnFailure(hr, "Failed to verify hash of container: %ls", pContainer->sczId); | 1473 | ExitOnFailure(hr, "Failed to verify hash of container: %ls", pContainer->sczId); |
| 1485 | } | 1474 | } |
| 1486 | 1475 | ||
| 1476 | if (fAlreadyCached) | ||
| 1477 | { | ||
| 1478 | LogId(REPORT_STANDARD, MSG_VERIFIED_EXISTING_CONTAINER, pContainer->sczId, wzVerifyPath); | ||
| 1479 | ::DecryptFileW(wzVerifyPath, 0); // Let's try to make sure it's not encrypted. | ||
| 1480 | } | ||
| 1481 | |||
| 1487 | LExit: | 1482 | LExit: |
| 1488 | ReleaseFileHandle(hFile); | 1483 | ReleaseFileHandle(hFile); |
| 1489 | 1484 | ||
| 1485 | if (FAILED(hr) && E_PATHNOTFOUND != hr && E_FILENOTFOUND != hr) | ||
| 1486 | { | ||
| 1487 | if (fAlreadyCached) | ||
| 1488 | { | ||
| 1489 | LogErrorId(hr, MSG_FAILED_VERIFY_CONTAINER, pContainer->sczId, wzVerifyPath, NULL); | ||
| 1490 | } | ||
| 1491 | |||
| 1492 | FileEnsureDelete(wzVerifyPath); // if the file existed but did not verify correctly, make it go away. | ||
| 1493 | } | ||
| 1494 | |||
| 1490 | return hr; | 1495 | return hr; |
| 1491 | } | 1496 | } |
| 1492 | 1497 | ||
| 1493 | static HRESULT VerifyFileAgainstPayload( | 1498 | static HRESULT VerifyFileAgainstPayload( |
| 1494 | __in BURN_PAYLOAD* pPayload, | 1499 | __in BURN_PAYLOAD* pPayload, |
| 1495 | __in_z LPCWSTR wzVerifyPath | 1500 | __in_z LPCWSTR wzVerifyPath, |
| 1501 | __in BOOL fAlreadyCached | ||
| 1496 | ) | 1502 | ) |
| 1497 | { | 1503 | { |
| 1498 | HRESULT hr = S_OK; | 1504 | HRESULT hr = S_OK; |
| @@ -1516,9 +1522,25 @@ static HRESULT VerifyFileAgainstPayload( | |||
| 1516 | ExitOnFailure(hr, "Failed to verify hash of payload: %ls", pPayload->sczKey); | 1522 | ExitOnFailure(hr, "Failed to verify hash of payload: %ls", pPayload->sczKey); |
| 1517 | } | 1523 | } |
| 1518 | 1524 | ||
| 1525 | if (fAlreadyCached) | ||
| 1526 | { | ||
| 1527 | LogId(REPORT_STANDARD, MSG_VERIFIED_EXISTING_PAYLOAD, pPayload->sczKey, wzVerifyPath); | ||
| 1528 | ::DecryptFileW(wzVerifyPath, 0); // Let's try to make sure it's not encrypted. | ||
| 1529 | } | ||
| 1530 | |||
| 1519 | LExit: | 1531 | LExit: |
| 1520 | ReleaseFileHandle(hFile); | 1532 | ReleaseFileHandle(hFile); |
| 1521 | 1533 | ||
| 1534 | if (FAILED(hr) && E_PATHNOTFOUND != hr && E_FILENOTFOUND != hr) | ||
| 1535 | { | ||
| 1536 | if (fAlreadyCached) | ||
| 1537 | { | ||
| 1538 | LogErrorId(hr, MSG_FAILED_VERIFY_PAYLOAD, pPayload->sczKey, wzVerifyPath, NULL); | ||
| 1539 | } | ||
| 1540 | |||
| 1541 | FileEnsureDelete(wzVerifyPath); // if the file existed but did not verify correctly, make it go away. | ||
| 1542 | } | ||
| 1543 | |||
| 1522 | return hr; | 1544 | return hr; |
| 1523 | } | 1545 | } |
| 1524 | 1546 | ||
diff --git a/src/engine/elevation.cpp b/src/engine/elevation.cpp index d37907cf..2dd61a81 100644 --- a/src/engine/elevation.cpp +++ b/src/engine/elevation.cpp | |||
| @@ -16,6 +16,7 @@ typedef enum _BURN_ELEVATION_MESSAGE_TYPE | |||
| 16 | BURN_ELEVATION_MESSAGE_TYPE_SAVE_STATE, | 16 | BURN_ELEVATION_MESSAGE_TYPE_SAVE_STATE, |
| 17 | BURN_ELEVATION_MESSAGE_TYPE_LAYOUT_BUNDLE, | 17 | BURN_ELEVATION_MESSAGE_TYPE_LAYOUT_BUNDLE, |
| 18 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_OR_LAYOUT_CONTAINER_OR_PAYLOAD, | 18 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_OR_LAYOUT_CONTAINER_OR_PAYLOAD, |
| 19 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD, | ||
| 19 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP, | 20 | BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP, |
| 20 | BURN_ELEVATION_MESSAGE_TYPE_PROCESS_DEPENDENT_REGISTRATION, | 21 | BURN_ELEVATION_MESSAGE_TYPE_PROCESS_DEPENDENT_REGISTRATION, |
| 21 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, | 22 | BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_EXE_PACKAGE, |
| @@ -176,6 +177,13 @@ static HRESULT OnCacheOrLayoutContainerOrPayload( | |||
| 176 | __in BYTE* pbData, | 177 | __in BYTE* pbData, |
| 177 | __in DWORD cbData | 178 | __in DWORD cbData |
| 178 | ); | 179 | ); |
| 180 | static HRESULT OnCacheVerifyContainerOrPayload( | ||
| 181 | __in BURN_CONTAINERS* pContainers, | ||
| 182 | __in BURN_PACKAGES* pPackages, | ||
| 183 | __in BURN_PAYLOADS* pPayloads, | ||
| 184 | __in BYTE* pbData, | ||
| 185 | __in DWORD cbData | ||
| 186 | ); | ||
| 179 | static void OnCacheCleanup( | 187 | static void OnCacheCleanup( |
| 180 | __in_z LPCWSTR wzBundleId | 188 | __in_z LPCWSTR wzBundleId |
| 181 | ); | 189 | ); |
| @@ -657,6 +665,44 @@ LExit: | |||
| 657 | return hr; | 665 | return hr; |
| 658 | } | 666 | } |
| 659 | 667 | ||
| 668 | extern "C" HRESULT ElevationCacheVerifyContainerOrPayload( | ||
| 669 | __in HANDLE hPipe, | ||
| 670 | __in_opt BURN_CONTAINER* pContainer, | ||
| 671 | __in_opt BURN_PACKAGE* pPackage, | ||
| 672 | __in_opt BURN_PAYLOAD* pPayload, | ||
| 673 | __in_z_opt LPCWSTR wzLayoutDirectory | ||
| 674 | ) | ||
| 675 | { | ||
| 676 | HRESULT hr = S_OK; | ||
| 677 | BYTE* pbData = NULL; | ||
| 678 | SIZE_T cbData = 0; | ||
| 679 | DWORD dwResult = 0; | ||
| 680 | |||
| 681 | // serialize message data | ||
| 682 | hr = BuffWriteString(&pbData, &cbData, pContainer ? pContainer->sczId : NULL); | ||
| 683 | ExitOnFailure(hr, "Failed to write container id to message buffer."); | ||
| 684 | |||
| 685 | hr = BuffWriteString(&pbData, &cbData, pPackage ? pPackage->sczId : NULL); | ||
| 686 | ExitOnFailure(hr, "Failed to write package id to message buffer."); | ||
| 687 | |||
| 688 | hr = BuffWriteString(&pbData, &cbData, pPayload ? pPayload->sczKey : NULL); | ||
| 689 | ExitOnFailure(hr, "Failed to write payload id to message buffer."); | ||
| 690 | |||
| 691 | hr = BuffWriteString(&pbData, &cbData, wzLayoutDirectory); | ||
| 692 | ExitOnFailure(hr, "Failed to write layout directory to message buffer."); | ||
| 693 | |||
| 694 | // send message | ||
| 695 | hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD, pbData, cbData, NULL, NULL, &dwResult); | ||
| 696 | ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD message to per-machine process."); | ||
| 697 | |||
| 698 | hr = (HRESULT)dwResult; | ||
| 699 | |||
| 700 | LExit: | ||
| 701 | ReleaseBuffer(pbData); | ||
| 702 | |||
| 703 | return hr; | ||
| 704 | } | ||
| 705 | |||
| 660 | /******************************************************************* | 706 | /******************************************************************* |
| 661 | ElevationCacheCleanup - | 707 | ElevationCacheCleanup - |
| 662 | 708 | ||
| @@ -1724,6 +1770,10 @@ static HRESULT ProcessElevatedChildCacheMessage( | |||
| 1724 | hrResult = OnCacheOrLayoutContainerOrPayload(pContext->pContainers, pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); | 1770 | hrResult = OnCacheOrLayoutContainerOrPayload(pContext->pContainers, pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); |
| 1725 | break; | 1771 | break; |
| 1726 | 1772 | ||
| 1773 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_VERIFY_CONTAINER_OR_PAYLOAD: | ||
| 1774 | hrResult = OnCacheVerifyContainerOrPayload(pContext->pContainers, pContext->pPackages, pContext->pPayloads, (BYTE*)pMsg->pvData, pMsg->cbData); | ||
| 1775 | break; | ||
| 1776 | |||
| 1727 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP: | 1777 | case BURN_ELEVATION_MESSAGE_TYPE_CACHE_CLEANUP: |
| 1728 | OnCacheCleanup(pContext->pRegistration->sczId); | 1778 | OnCacheCleanup(pContext->pRegistration->sczId); |
| 1729 | hrResult = S_OK; | 1779 | hrResult = S_OK; |
| @@ -2062,7 +2112,7 @@ static HRESULT OnCacheOrLayoutContainerOrPayload( | |||
| 2062 | 2112 | ||
| 2063 | // Deserialize message data. | 2113 | // Deserialize message data. |
| 2064 | hr = BuffReadString(pbData, cbData, &iData, &scz); | 2114 | hr = BuffReadString(pbData, cbData, &iData, &scz); |
| 2065 | ExitOnFailure(hr, "Failed to read package id."); | 2115 | ExitOnFailure(hr, "Failed to read container id."); |
| 2066 | 2116 | ||
| 2067 | if (scz && *scz) | 2117 | if (scz && *scz) |
| 2068 | { | 2118 | { |
| @@ -2135,6 +2185,90 @@ LExit: | |||
| 2135 | return hr; | 2185 | return hr; |
| 2136 | } | 2186 | } |
| 2137 | 2187 | ||
| 2188 | static HRESULT OnCacheVerifyContainerOrPayload( | ||
| 2189 | __in BURN_CONTAINERS* pContainers, | ||
| 2190 | __in BURN_PACKAGES* pPackages, | ||
| 2191 | __in BURN_PAYLOADS* pPayloads, | ||
| 2192 | __in BYTE* pbData, | ||
| 2193 | __in DWORD cbData | ||
| 2194 | ) | ||
| 2195 | { | ||
| 2196 | HRESULT hr = S_OK; | ||
| 2197 | SIZE_T iData = 0; | ||
| 2198 | LPWSTR scz = NULL; | ||
| 2199 | BURN_CONTAINER* pContainer = NULL; | ||
| 2200 | BURN_PACKAGE* pPackage = NULL; | ||
| 2201 | BURN_PAYLOAD* pPayload = NULL; | ||
| 2202 | LPWSTR sczCacheDirectory = NULL; | ||
| 2203 | |||
| 2204 | // Deserialize message data. | ||
| 2205 | hr = BuffReadString(pbData, cbData, &iData, &scz); | ||
| 2206 | ExitOnFailure(hr, "Failed to read container id."); | ||
| 2207 | |||
| 2208 | if (scz && *scz) | ||
| 2209 | { | ||
| 2210 | hr = ContainerFindById(pContainers, scz, &pContainer); | ||
| 2211 | ExitOnFailure(hr, "Failed to find container: %ls", scz); | ||
| 2212 | } | ||
| 2213 | |||
| 2214 | hr = BuffReadString(pbData, cbData, &iData, &scz); | ||
| 2215 | ExitOnFailure(hr, "Failed to read package id."); | ||
| 2216 | |||
| 2217 | if (scz && *scz) | ||
| 2218 | { | ||
| 2219 | hr = PackageFindById(pPackages, scz, &pPackage); | ||
| 2220 | ExitOnFailure(hr, "Failed to find package: %ls", scz); | ||
| 2221 | } | ||
| 2222 | |||
| 2223 | hr = BuffReadString(pbData, cbData, &iData, &scz); | ||
| 2224 | ExitOnFailure(hr, "Failed to read payload id."); | ||
| 2225 | |||
| 2226 | if (scz && *scz) | ||
| 2227 | { | ||
| 2228 | hr = PayloadFindById(pPayloads, scz, &pPayload); | ||
| 2229 | ExitOnFailure(hr, "Failed to find payload: %ls", scz); | ||
| 2230 | } | ||
| 2231 | |||
| 2232 | hr = BuffReadString(pbData, cbData, &iData, &sczCacheDirectory); | ||
| 2233 | ExitOnFailure(hr, "Failed to read layout directory."); | ||
| 2234 | |||
| 2235 | if (!sczCacheDirectory || !*sczCacheDirectory) | ||
| 2236 | { | ||
| 2237 | if (!pPackage) | ||
| 2238 | { | ||
| 2239 | hr = E_INVALIDARG; | ||
| 2240 | ExitOnRootFailure(hr, "Invalid data passed to cache verify payload."); | ||
| 2241 | } | ||
| 2242 | |||
| 2243 | hr = CacheGetCompletedPath(TRUE, pPackage->sczCacheId, &sczCacheDirectory); | ||
| 2244 | ExitOnFailure(hr, "Failed to get cached path for package with cache id: %ls", pPackage->sczCacheId); | ||
| 2245 | } | ||
| 2246 | |||
| 2247 | if (pContainer) | ||
| 2248 | { | ||
| 2249 | Assert(!pPackage); | ||
| 2250 | Assert(!pPayload); | ||
| 2251 | |||
| 2252 | hr = CacheVerifyContainer(pContainer, sczCacheDirectory); | ||
| 2253 | } | ||
| 2254 | else if (pPayload) | ||
| 2255 | { | ||
| 2256 | hr = CacheVerifyPayload(pPayload, sczCacheDirectory); | ||
| 2257 | } | ||
| 2258 | else | ||
| 2259 | { | ||
| 2260 | hr = E_INVALIDARG; | ||
| 2261 | ExitOnRootFailure(hr, "Invalid data passed to cache or layout payload."); | ||
| 2262 | } | ||
| 2263 | // Nothing should be logged on failure. | ||
| 2264 | |||
| 2265 | LExit: | ||
| 2266 | ReleaseStr(sczCacheDirectory); | ||
| 2267 | ReleaseStr(scz); | ||
| 2268 | |||
| 2269 | return hr; | ||
| 2270 | } | ||
| 2271 | |||
| 2138 | static void OnCacheCleanup( | 2272 | static void OnCacheCleanup( |
| 2139 | __in_z LPCWSTR wzBundleId | 2273 | __in_z LPCWSTR wzBundleId |
| 2140 | ) | 2274 | ) |
diff --git a/src/engine/elevation.h b/src/engine/elevation.h index 9ce8cef9..da67e3f3 100644 --- a/src/engine/elevation.h +++ b/src/engine/elevation.h | |||
| @@ -64,6 +64,13 @@ HRESULT ElevationCacheOrLayoutContainerOrPayload( | |||
| 64 | __in_z LPCWSTR wzUnverifiedPath, | 64 | __in_z LPCWSTR wzUnverifiedPath, |
| 65 | __in BOOL fMove | 65 | __in BOOL fMove |
| 66 | ); | 66 | ); |
| 67 | HRESULT ElevationCacheVerifyContainerOrPayload( | ||
| 68 | __in HANDLE hPipe, | ||
| 69 | __in_opt BURN_CONTAINER* pContainer, | ||
| 70 | __in_opt BURN_PACKAGE* pPackage, | ||
| 71 | __in_opt BURN_PAYLOAD* pPayload, | ||
| 72 | __in_z_opt LPCWSTR wzLayoutDirectory | ||
| 73 | ); | ||
| 67 | HRESULT ElevationCacheCleanup( | 74 | HRESULT ElevationCacheCleanup( |
| 68 | __in HANDLE hPipe | 75 | __in HANDLE hPipe |
| 69 | ); | 76 | ); |
diff --git a/src/engine/engine.mc b/src/engine/engine.mc index 0e19d3bb..6e0695bc 100644 --- a/src/engine/engine.mc +++ b/src/engine/engine.mc | |||
| @@ -478,6 +478,13 @@ Language=English | |||
| 478 | Acquired payload: %1!ls! to working path: %2!ls! from: %4!ls!. | 478 | Acquired payload: %1!ls! to working path: %2!ls! from: %4!ls!. |
| 479 | . | 479 | . |
| 480 | 480 | ||
| 481 | MessageId=303 | ||
| 482 | Severity=Success | ||
| 483 | SymbolicName=MSG_VERIFIED_EXISTING_CONTAINER | ||
| 484 | Language=English | ||
| 485 | Verified existing container: %1!ls! at path: %2!ls!. | ||
| 486 | . | ||
| 487 | |||
| 481 | MessageId=304 | 488 | MessageId=304 |
| 482 | Severity=Success | 489 | Severity=Success |
| 483 | SymbolicName=MSG_VERIFIED_EXISTING_PAYLOAD | 490 | SymbolicName=MSG_VERIFIED_EXISTING_PAYLOAD |
| @@ -724,6 +731,13 @@ Language=English | |||
| 724 | Acquiring package: %1!ls!, payload: %2!ls!, %3!hs! from: %4!ls! | 731 | Acquiring package: %1!ls!, payload: %2!ls!, %3!hs! from: %4!ls! |
| 725 | . | 732 | . |
| 726 | 733 | ||
| 734 | MessageId=339 | ||
| 735 | Severity=Error | ||
| 736 | SymbolicName=MSG_FAILED_VERIFY_CONTAINER | ||
| 737 | Language=English | ||
| 738 | Failed to verify container: %2!ls! at path: %3!ls!, error: %1!ls!. Deleting file. | ||
| 739 | . | ||
| 740 | |||
| 727 | MessageId=347 | 741 | MessageId=347 |
| 728 | Severity=Warning | 742 | Severity=Warning |
| 729 | SymbolicName=MSG_APPLY_RETRYING_CONTAINER | 743 | SymbolicName=MSG_APPLY_RETRYING_CONTAINER |
