aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-08-03 15:42:40 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-08-04 10:03:57 -0500
commitc50e82c27b7f33b9024a04ec7ad7d4301bc7f7ca (patch)
tree1340ef3bf598ec362bf4dcf135e65343db3e7d14
parent94b8260fc5c1abc199f8d6145f3db4e2de490463 (diff)
downloadwix-c50e82c27b7f33b9024a04ec7ad7d4301bc7f7ca.tar.gz
wix-c50e82c27b7f33b9024a04ec7ad7d4301bc7f7ca.tar.bz2
wix-c50e82c27b7f33b9024a04ec7ad7d4301bc7f7ca.zip
Create separate log file for clean room.
-rw-r--r--src/burn/engine/engine.cpp17
-rw-r--r--src/burn/engine/engine.mc7
-rw-r--r--src/burn/engine/logging.cpp19
3 files changed, 39 insertions, 4 deletions
diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp
index 99471e0d..8b4a296b 100644
--- a/src/burn/engine/engine.cpp
+++ b/src/burn/engine/engine.cpp
@@ -95,6 +95,7 @@ extern "C" HRESULT EngineRun(
95 SYSTEM_INFO si = { }; 95 SYSTEM_INFO si = { };
96 RTL_OSVERSIONINFOEXW ovix = { }; 96 RTL_OSVERSIONINFOEXW ovix = { };
97 LPWSTR sczExePath = NULL; 97 LPWSTR sczExePath = NULL;
98 BOOL fRunUntrusted = FALSE;
98 BOOL fRunNormal = FALSE; 99 BOOL fRunNormal = FALSE;
99 BOOL fRestart = FALSE; 100 BOOL fRestart = FALSE;
100 101
@@ -194,6 +195,8 @@ extern "C" HRESULT EngineRun(
194 switch (engineState.internalCommand.mode) 195 switch (engineState.internalCommand.mode)
195 { 196 {
196 case BURN_MODE_UNTRUSTED: 197 case BURN_MODE_UNTRUSTED:
198 fRunUntrusted = TRUE;
199
197 hr = RunUntrusted(&engineState); 200 hr = RunUntrusted(&engineState);
198 ExitOnFailure(hr, "Failed to run untrusted mode."); 201 ExitOnFailure(hr, "Failed to run untrusted mode.");
199 break; 202 break;
@@ -296,6 +299,10 @@ LExit:
296 LogId(REPORT_STANDARD, MSG_RESTARTING); 299 LogId(REPORT_STANDARD, MSG_RESTARTING);
297 } 300 }
298 } 301 }
302 else if (fRunUntrusted)
303 {
304 LogId(REPORT_STANDARD, MSG_EXITING_CLEAN_ROOM, FAILED(hr) ? (int)hr : *pdwExitCode);
305 }
299 306
300 if (fLogInitialized) 307 if (fLogInitialized)
301 { 308 {
@@ -425,6 +432,10 @@ static HRESULT RunUntrusted(
425 HANDLE hFileSelf = NULL; 432 HANDLE hFileSelf = NULL;
426 HANDLE hProcess = NULL; 433 HANDLE hProcess = NULL;
427 434
435 // Initialize logging.
436 hr = LoggingOpen(&pEngineState->log, &pEngineState->internalCommand, &pEngineState->command, &pEngineState->variables, pEngineState->registration.sczDisplayName);
437 ExitOnFailure(hr, "Failed to open clean room log.");
438
428 hr = PathForCurrentProcess(&sczCurrentProcessPath, NULL); 439 hr = PathForCurrentProcess(&sczCurrentProcessPath, NULL);
429 ExitOnFailure(hr, "Failed to get path for current process."); 440 ExitOnFailure(hr, "Failed to get path for current process.");
430 441
@@ -480,6 +491,12 @@ static HRESULT RunUntrusted(
480 ExitOnFailure(hr, "Failed to wait for clean room process: %ls", wzCleanRoomBundlePath); 491 ExitOnFailure(hr, "Failed to wait for clean room process: %ls", wzCleanRoomBundlePath);
481 492
482LExit: 493LExit:
494 // If the splash screen is still around, close it.
495 if (::IsWindow(pEngineState->command.hwndSplashScreen))
496 {
497 ::PostMessageW(pEngineState->command.hwndSplashScreen, WM_CLOSE, 0, 0);
498 }
499
483 ReleaseHandle(pi.hThread); 500 ReleaseHandle(pi.hThread);
484 ReleaseFileHandle(hFileSelf); 501 ReleaseFileHandle(hFileSelf);
485 ReleaseFileHandle(hFileAttached); 502 ReleaseFileHandle(hFileAttached);
diff --git a/src/burn/engine/engine.mc b/src/burn/engine/engine.mc
index a587415d..f1ecebcd 100644
--- a/src/burn/engine/engine.mc
+++ b/src/burn/engine/engine.mc
@@ -142,6 +142,13 @@ Language=English
142Unknown burn internal command-line switch modifier encountered, switch: '%1!ls!', modifier: '%2!c!'. 142Unknown burn internal command-line switch modifier encountered, switch: '%1!ls!', modifier: '%2!c!'.
143. 143.
144 144
145MessageId=17
146Severity=Success
147SymbolicName=MSG_EXITING_CLEAN_ROOM
148Language=English
149Exit code: 0x%1!x!
150.
151
145MessageId=51 152MessageId=51
146Severity=Error 153Severity=Error
147SymbolicName=MSG_FAILED_PARSE_CONDITION 154SymbolicName=MSG_FAILED_PARSE_CONDITION
diff --git a/src/burn/engine/logging.cpp b/src/burn/engine/logging.cpp
index 6b19cc8a..9aaf60ed 100644
--- a/src/burn/engine/logging.cpp
+++ b/src/burn/engine/logging.cpp
@@ -39,11 +39,12 @@ extern "C" HRESULT LoggingOpen(
39 HRESULT hr = S_OK; 39 HRESULT hr = S_OK;
40 LPWSTR sczLoggingBaseFolder = NULL; 40 LPWSTR sczLoggingBaseFolder = NULL;
41 LPWSTR sczPrefixFormatted = NULL; 41 LPWSTR sczPrefixFormatted = NULL;
42 LPCWSTR wzPostfix = BURN_MODE_UNTRUSTED == pInternalCommand->mode ? L".cleanroom" : NULL;
42 43
43 hr = InitializeLogging(pLog, pInternalCommand); 44 hr = InitializeLogging(pLog, pInternalCommand);
44 ExitOnFailure(hr, "Failed to initialize logging."); 45 ExitOnFailure(hr, "Failed to initialize logging.");
45 46
46 if (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_VERBOSE || pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_EXTRADEBUG) 47 if ((pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_VERBOSE) || (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_EXTRADEBUG))
47 { 48 {
48 if (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_EXTRADEBUG) 49 if (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_EXTRADEBUG)
49 { 50 {
@@ -54,9 +55,17 @@ extern "C" HRESULT LoggingOpen(
54 LogSetLevel(REPORT_VERBOSE, FALSE); 55 LogSetLevel(REPORT_VERBOSE, FALSE);
55 } 56 }
56 57
58 // In these modes, make sure a log will be created even if the bundle wasn't configured to create one.
57 if ((!pLog->sczPath || !*pLog->sczPath) && (!pLog->sczPrefix || !*pLog->sczPrefix)) 59 if ((!pLog->sczPath || !*pLog->sczPath) && (!pLog->sczPrefix || !*pLog->sczPrefix))
58 { 60 {
59 PathCreateTimeBasedTempFile(NULL, L"Setup", NULL, L"log", &pLog->sczPath, NULL); 61 hr = StrAllocString(&pLog->sczPrefix, L"Setup", 0);
62 ExitOnFailure(hr, "Failed to copy default log prefix.");
63
64 if (!pLog->sczExtension || !*pLog->sczExtension)
65 {
66 hr = StrAllocString(&pLog->sczExtension, L"log", 0);
67 ExitOnFailure(hr, "Failed to copy default log extension.");
68 }
60 } 69 }
61 } 70 }
62 71
@@ -134,7 +143,7 @@ extern "C" HRESULT LoggingOpen(
134 ExitOnFailure(hr, "Failed to get non-session specific TEMP folder."); 143 ExitOnFailure(hr, "Failed to get non-session specific TEMP folder.");
135 } 144 }
136 145
137 hr = LogOpen(sczLoggingBaseFolder, wzPrefix, NULL, pLog->sczExtension, FALSE, FALSE, &pLog->sczPath); 146 hr = LogOpen(sczLoggingBaseFolder, wzPrefix, wzPostfix, pLog->sczExtension, FALSE, FALSE, &pLog->sczPath);
138 if (FAILED(hr)) 147 if (FAILED(hr))
139 { 148 {
140 LogDisable(); 149 LogDisable();
@@ -760,7 +769,9 @@ static HRESULT InitializeLogging(
760 769
761 pLog->dwAttributes |= pInternalCommand->dwLoggingAttributes; 770 pLog->dwAttributes |= pInternalCommand->dwLoggingAttributes;
762 771
763 if (pInternalCommand->sczLogFile) 772 // The untrusted process needs a separate log file.
773 // TODO: Burn crashes if they do try to use the same log file.
774 if (pInternalCommand->sczLogFile && BURN_MODE_UNTRUSTED != pInternalCommand->mode)
764 { 775 {
765 hr = StrAllocString(&pLog->sczPath, pInternalCommand->sczLogFile, 0); 776 hr = StrAllocString(&pLog->sczPath, pInternalCommand->sczLogFile, 0);
766 ExitOnFailure(hr, "Failed to copy log file path from command line."); 777 ExitOnFailure(hr, "Failed to copy log file path from command line.");