diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-05-02 16:07:18 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-05-11 19:11:19 -0500 |
| commit | 5cb01b477d85920662112d63b5a44b75c03762a9 (patch) | |
| tree | faa0e320981e7328debd861aa90980bce7411cf9 /src/burn/engine/cache.cpp | |
| parent | 71e689fe5179ca253d878480ba34e2e76a540eab (diff) | |
| download | wix-5cb01b477d85920662112d63b5a44b75c03762a9.tar.gz wix-5cb01b477d85920662112d63b5a44b75c03762a9.tar.bz2 wix-5cb01b477d85920662112d63b5a44b75c03762a9.zip | |
Allow launching approved exes from the original package cache.
Diffstat (limited to 'src/burn/engine/cache.cpp')
| -rw-r--r-- | src/burn/engine/cache.cpp | 91 |
1 files changed, 71 insertions, 20 deletions
diff --git a/src/burn/engine/cache.cpp b/src/burn/engine/cache.cpp index 59daf139..d1999a0d 100644 --- a/src/burn/engine/cache.cpp +++ b/src/burn/engine/cache.cpp | |||
| @@ -25,10 +25,11 @@ static HRESULT GetLastUsedSourceFolder( | |||
| 25 | __in BURN_VARIABLES* pVariables, | 25 | __in BURN_VARIABLES* pVariables, |
| 26 | __out_z LPWSTR* psczLastSource | 26 | __out_z LPWSTR* psczLastSource |
| 27 | ); | 27 | ); |
| 28 | static HRESULT SecurePerMachineCacheRoot(); | ||
| 28 | static HRESULT CreateCompletedPath( | 29 | static HRESULT CreateCompletedPath( |
| 29 | __in BOOL fPerMachine, | 30 | __in BOOL fPerMachine, |
| 30 | __in LPCWSTR wzCacheId, | 31 | __in LPCWSTR wzCacheId, |
| 31 | __out LPWSTR* psczCacheDirectory | 32 | __out_z LPWSTR* psczCacheDirectory |
| 32 | ); | 33 | ); |
| 33 | static HRESULT CreateUnverifiedPath( | 34 | static HRESULT CreateUnverifiedPath( |
| 34 | __in BOOL fPerMachine, | 35 | __in BOOL fPerMachine, |
| @@ -341,23 +342,31 @@ LExit: | |||
| 341 | return hr; | 342 | return hr; |
| 342 | } | 343 | } |
| 343 | 344 | ||
| 344 | extern "C" HRESULT CacheGetRootCompletedPath( | 345 | extern "C" HRESULT CacheGetPerMachineRootCompletedPath( |
| 345 | __in BOOL fPerMachine, | 346 | __out_z LPWSTR* psczCurrentRootCompletedPath, |
| 346 | __in BOOL fForceInitialize, | 347 | __out_z LPWSTR* psczDefaultRootCompletedPath |
| 347 | __deref_out_z LPWSTR* psczRootCompletedPath | ||
| 348 | ) | 348 | ) |
| 349 | { | 349 | { |
| 350 | HRESULT hr = S_OK; | 350 | HRESULT hr = S_OK; |
| 351 | 351 | ||
| 352 | if (fForceInitialize) | 352 | *psczCurrentRootCompletedPath = NULL; |
| 353 | { | 353 | *psczDefaultRootCompletedPath = NULL; |
| 354 | hr = CreateCompletedPath(fPerMachine, L"", psczRootCompletedPath); | 354 | |
| 355 | } | 355 | hr = SecurePerMachineCacheRoot(); |
| 356 | else | 356 | ExitOnFailure(hr, "Failed to secure per-machine cache root."); |
| 357 | |||
| 358 | hr = GetRootPath(TRUE, TRUE, psczCurrentRootCompletedPath); | ||
| 359 | ExitOnFailure(hr, "Failed to get per-machine cache root."); | ||
| 360 | |||
| 361 | if (S_FALSE == hr) | ||
| 357 | { | 362 | { |
| 358 | hr = GetRootPath(fPerMachine, TRUE, psczRootCompletedPath); | 363 | hr = GetRootPath(TRUE, FALSE, psczDefaultRootCompletedPath); |
| 364 | ExitOnFailure(hr, "Failed to get default per-machine cache root."); | ||
| 365 | |||
| 366 | hr = S_FALSE; | ||
| 359 | } | 367 | } |
| 360 | 368 | ||
| 369 | LExit: | ||
| 361 | return hr; | 370 | return hr; |
| 362 | } | 371 | } |
| 363 | 372 | ||
| @@ -1337,24 +1346,24 @@ static HRESULT GetLastUsedSourceFolder( | |||
| 1337 | return hr; | 1346 | return hr; |
| 1338 | } | 1347 | } |
| 1339 | 1348 | ||
| 1340 | static HRESULT CreateCompletedPath( | 1349 | static HRESULT SecurePerMachineCacheRoot() |
| 1341 | __in BOOL fPerMachine, | ||
| 1342 | __in LPCWSTR wzId, | ||
| 1343 | __out LPWSTR* psczCacheDirectory | ||
| 1344 | ) | ||
| 1345 | { | 1350 | { |
| 1346 | static BOOL fPerMachineCacheRootVerified = FALSE; | 1351 | static BOOL fPerMachineCacheRootVerified = FALSE; |
| 1352 | static BOOL fOriginalPerMachineCacheRootVerified = FALSE; | ||
| 1347 | 1353 | ||
| 1348 | HRESULT hr = S_OK; | 1354 | HRESULT hr = S_OK; |
| 1355 | BOOL fRedirected = FALSE; | ||
| 1349 | LPWSTR sczCacheDirectory = NULL; | 1356 | LPWSTR sczCacheDirectory = NULL; |
| 1350 | 1357 | ||
| 1351 | // If we are doing a permachine install but have not yet verified that the root cache folder | 1358 | if (!fPerMachineCacheRootVerified) |
| 1352 | // was created with the correct ACLs yet, do that now. | ||
| 1353 | if (fPerMachine && !fPerMachineCacheRootVerified) | ||
| 1354 | { | 1359 | { |
| 1355 | hr = GetRootPath(fPerMachine, TRUE, &sczCacheDirectory); | 1360 | // If we are doing a permachine install but have not yet verified that the root cache folder |
| 1361 | // was created with the correct ACLs yet, do that now. | ||
| 1362 | hr = GetRootPath(TRUE, TRUE, &sczCacheDirectory); | ||
| 1356 | ExitOnFailure(hr, "Failed to get cache directory."); | 1363 | ExitOnFailure(hr, "Failed to get cache directory."); |
| 1357 | 1364 | ||
| 1365 | fRedirected = S_FALSE == hr; | ||
| 1366 | |||
| 1358 | hr = DirEnsureExists(sczCacheDirectory, NULL); | 1367 | hr = DirEnsureExists(sczCacheDirectory, NULL); |
| 1359 | ExitOnFailure(hr, "Failed to create cache directory: %ls", sczCacheDirectory); | 1368 | ExitOnFailure(hr, "Failed to create cache directory: %ls", sczCacheDirectory); |
| 1360 | 1369 | ||
| @@ -1362,6 +1371,48 @@ static HRESULT CreateCompletedPath( | |||
| 1362 | ExitOnFailure(hr, "Failed to secure cache directory: %ls", sczCacheDirectory); | 1371 | ExitOnFailure(hr, "Failed to secure cache directory: %ls", sczCacheDirectory); |
| 1363 | 1372 | ||
| 1364 | fPerMachineCacheRootVerified = TRUE; | 1373 | fPerMachineCacheRootVerified = TRUE; |
| 1374 | |||
| 1375 | if (!fRedirected) | ||
| 1376 | { | ||
| 1377 | fOriginalPerMachineCacheRootVerified = TRUE; | ||
| 1378 | } | ||
| 1379 | } | ||
| 1380 | |||
| 1381 | if (!fOriginalPerMachineCacheRootVerified) | ||
| 1382 | { | ||
| 1383 | // If we are doing a permachine install but have not yet verified that the original root cache folder | ||
| 1384 | // was created with the correct ACLs yet, do that now. | ||
| 1385 | hr = GetRootPath(TRUE, FALSE, &sczCacheDirectory); | ||
| 1386 | ExitOnFailure(hr, "Failed to get original cache directory."); | ||
| 1387 | |||
| 1388 | hr = DirEnsureExists(sczCacheDirectory, NULL); | ||
| 1389 | ExitOnFailure(hr, "Failed to create original cache directory: %ls", sczCacheDirectory); | ||
| 1390 | |||
| 1391 | hr = SecurePath(sczCacheDirectory); | ||
| 1392 | ExitOnFailure(hr, "Failed to secure original cache directory: %ls", sczCacheDirectory); | ||
| 1393 | |||
| 1394 | fOriginalPerMachineCacheRootVerified = TRUE; | ||
| 1395 | } | ||
| 1396 | |||
| 1397 | LExit: | ||
| 1398 | ReleaseStr(sczCacheDirectory); | ||
| 1399 | |||
| 1400 | return hr; | ||
| 1401 | } | ||
| 1402 | |||
| 1403 | static HRESULT CreateCompletedPath( | ||
| 1404 | __in BOOL fPerMachine, | ||
| 1405 | __in LPCWSTR wzId, | ||
| 1406 | __out_z LPWSTR* psczCacheDirectory | ||
| 1407 | ) | ||
| 1408 | { | ||
| 1409 | HRESULT hr = S_OK; | ||
| 1410 | LPWSTR sczCacheDirectory = NULL; | ||
| 1411 | |||
| 1412 | if (fPerMachine) | ||
| 1413 | { | ||
| 1414 | hr = SecurePerMachineCacheRoot(); | ||
| 1415 | ExitOnFailure(hr, "Failed to secure per-machine cache root."); | ||
| 1365 | } | 1416 | } |
| 1366 | 1417 | ||
| 1367 | // Get the cache completed path, ensure it exists, and reset any permissions people | 1418 | // Get the cache completed path, ensure it exists, and reset any permissions people |
