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 | |
parent | 71e689fe5179ca253d878480ba34e2e76a540eab (diff) | |
download | wix-5cb01b477d85920662112d63b5a44b75c03762a9.tar.gz wix-5cb01b477d85920662112d63b5a44b75c03762a9.tar.bz2 wix-5cb01b477d85920662112d63b5a44b75c03762a9.zip |
Allow launching approved exes from the original package cache.
-rw-r--r-- | src/burn/engine/approvedexe.cpp | 16 | ||||
-rw-r--r-- | src/burn/engine/cache.cpp | 91 | ||||
-rw-r--r-- | src/burn/engine/cache.h | 7 |
3 files changed, 88 insertions, 26 deletions
diff --git a/src/burn/engine/approvedexe.cpp b/src/burn/engine/approvedexe.cpp index 55518519..e3d51a47 100644 --- a/src/burn/engine/approvedexe.cpp +++ b/src/burn/engine/approvedexe.cpp | |||
@@ -217,6 +217,7 @@ extern "C" HRESULT ApprovedExesVerifySecureLocation( | |||
217 | { | 217 | { |
218 | HRESULT hr = S_OK; | 218 | HRESULT hr = S_OK; |
219 | LPWSTR scz = NULL; | 219 | LPWSTR scz = NULL; |
220 | LPWSTR sczSecondary = NULL; | ||
220 | 221 | ||
221 | const LPCWSTR vrgSecureFolderVariables[] = { | 222 | const LPCWSTR vrgSecureFolderVariables[] = { |
222 | L"ProgramFiles64Folder", | 223 | L"ProgramFiles64Folder", |
@@ -243,10 +244,20 @@ extern "C" HRESULT ApprovedExesVerifySecureLocation( | |||
243 | } | 244 | } |
244 | 245 | ||
245 | // The problem with using a Variable for the root package cache folder is that it might not have been secured yet. | 246 | // The problem with using a Variable for the root package cache folder is that it might not have been secured yet. |
246 | // Getting it through CacheGetRootCompletedPath makes sure it has been secured. | 247 | // Getting it through CacheGetPerMachineRootCompletedPath makes sure it has been secured. |
247 | hr = CacheGetRootCompletedPath(TRUE, TRUE, &scz); | 248 | hr = CacheGetPerMachineRootCompletedPath(&scz, &sczSecondary); |
248 | ExitOnFailure(hr, "Failed to get the root package cache folder."); | 249 | ExitOnFailure(hr, "Failed to get the root package cache folder."); |
249 | 250 | ||
251 | // If the package cache is redirected, hr is S_FALSE. | ||
252 | if (S_FALSE == hr) | ||
253 | { | ||
254 | hr = PathDirectoryContainsPath(sczSecondary, pLaunchApprovedExe->sczExecutablePath); | ||
255 | if (S_OK == hr) | ||
256 | { | ||
257 | ExitFunction(); | ||
258 | } | ||
259 | } | ||
260 | |||
250 | hr = PathDirectoryContainsPath(scz, pLaunchApprovedExe->sczExecutablePath); | 261 | hr = PathDirectoryContainsPath(scz, pLaunchApprovedExe->sczExecutablePath); |
251 | if (S_OK == hr) | 262 | if (S_OK == hr) |
252 | { | 263 | { |
@@ -257,6 +268,7 @@ extern "C" HRESULT ApprovedExesVerifySecureLocation( | |||
257 | 268 | ||
258 | LExit: | 269 | LExit: |
259 | ReleaseStr(scz); | 270 | ReleaseStr(scz); |
271 | ReleaseStr(sczSecondary); | ||
260 | 272 | ||
261 | return hr; | 273 | return hr; |
262 | } | 274 | } |
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 |
diff --git a/src/burn/engine/cache.h b/src/burn/engine/cache.h index 0152d33b..a300e99d 100644 --- a/src/burn/engine/cache.h +++ b/src/burn/engine/cache.h | |||
@@ -80,10 +80,9 @@ HRESULT CacheCalculateContainerWorkingPath( | |||
80 | __in BURN_CONTAINER* pContainer, | 80 | __in BURN_CONTAINER* pContainer, |
81 | __deref_out_z LPWSTR* psczWorkingPath | 81 | __deref_out_z LPWSTR* psczWorkingPath |
82 | ); | 82 | ); |
83 | HRESULT CacheGetRootCompletedPath( | 83 | HRESULT CacheGetPerMachineRootCompletedPath( |
84 | __in BOOL fPerMachine, | 84 | __out_z LPWSTR* psczCurrentRootCompletedPath, |
85 | __in BOOL fForceInitialize, | 85 | __out_z LPWSTR* psczDefaultRootCompletedPath |
86 | __deref_out_z LPWSTR* psczRootCompletedPath | ||
87 | ); | 86 | ); |
88 | HRESULT CacheGetCompletedPath( | 87 | HRESULT CacheGetCompletedPath( |
89 | __in BOOL fPerMachine, | 88 | __in BOOL fPerMachine, |