diff options
Diffstat (limited to 'src/burn/engine/exeengine.cpp')
| -rw-r--r-- | src/burn/engine/exeengine.cpp | 91 |
1 files changed, 79 insertions, 12 deletions
diff --git a/src/burn/engine/exeengine.cpp b/src/burn/engine/exeengine.cpp index a1049006..9754002f 100644 --- a/src/burn/engine/exeengine.cpp +++ b/src/burn/engine/exeengine.cpp | |||
| @@ -40,6 +40,10 @@ extern "C" HRESULT ExeEngineParsePackageFromXml( | |||
| 40 | hr = XmlGetYesNoAttribute(pixnExePackage, L"Uninstallable", &pPackage->Exe.fUninstallable); | 40 | hr = XmlGetYesNoAttribute(pixnExePackage, L"Uninstallable", &pPackage->Exe.fUninstallable); |
| 41 | ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Uninstallable."); | 41 | ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Uninstallable."); |
| 42 | 42 | ||
| 43 | // @Bundle | ||
| 44 | hr = XmlGetYesNoAttribute(pixnExePackage, L"Bundle", &pPackage->Exe.fBundle); | ||
| 45 | ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Bundle."); | ||
| 46 | |||
| 43 | // @Protocol | 47 | // @Protocol |
| 44 | hr = XmlGetAttributeEx(pixnExePackage, L"Protocol", &scz); | 48 | hr = XmlGetAttributeEx(pixnExePackage, L"Protocol", &scz); |
| 45 | ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Protocol."); | 49 | ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Protocol."); |
| @@ -87,6 +91,7 @@ extern "C" void ExeEnginePackageUninitialize( | |||
| 87 | ReleaseStr(pPackage->Exe.sczInstallArguments); | 91 | ReleaseStr(pPackage->Exe.sczInstallArguments); |
| 88 | ReleaseStr(pPackage->Exe.sczRepairArguments); | 92 | ReleaseStr(pPackage->Exe.sczRepairArguments); |
| 89 | ReleaseStr(pPackage->Exe.sczUninstallArguments); | 93 | ReleaseStr(pPackage->Exe.sczUninstallArguments); |
| 94 | ReleaseStr(pPackage->Exe.sczIgnoreDependencies); | ||
| 90 | ReleaseMem(pPackage->Exe.rgExitCodes); | 95 | ReleaseMem(pPackage->Exe.rgExitCodes); |
| 91 | 96 | ||
| 92 | // free command-line arguments | 97 | // free command-line arguments |
| @@ -286,6 +291,24 @@ extern "C" HRESULT ExeEnginePlanAddPackage( | |||
| 286 | pAction->exePackage.pPackage = pPackage; | 291 | pAction->exePackage.pPackage = pPackage; |
| 287 | pAction->exePackage.action = pPackage->rollback; | 292 | pAction->exePackage.action = pPackage->rollback; |
| 288 | 293 | ||
| 294 | if (pPackage->Exe.sczIgnoreDependencies) | ||
| 295 | { | ||
| 296 | hr = StrAllocString(&pAction->exePackage.sczIgnoreDependencies, pPackage->Exe.sczIgnoreDependencies, 0); | ||
| 297 | ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore."); | ||
| 298 | } | ||
| 299 | |||
| 300 | if (pPackage->Exe.wzAncestors) | ||
| 301 | { | ||
| 302 | hr = StrAllocString(&pAction->exePackage.sczAncestors, pPackage->Exe.wzAncestors, 0); | ||
| 303 | ExitOnFailure(hr, "Failed to allocate the list of ancestors."); | ||
| 304 | } | ||
| 305 | |||
| 306 | if (pPackage->Exe.wzEngineWorkingDirectory) | ||
| 307 | { | ||
| 308 | hr = StrAllocString(&pAction->exePackage.sczEngineWorkingDirectory, pPackage->Exe.wzEngineWorkingDirectory, 0); | ||
| 309 | ExitOnFailure(hr, "Failed to allocate the custom working directory."); | ||
| 310 | } | ||
| 311 | |||
| 289 | LoggingSetPackageVariable(pPackage, NULL, TRUE, pLog, pVariables, NULL); // ignore errors. | 312 | LoggingSetPackageVariable(pPackage, NULL, TRUE, pLog, pVariables, NULL); // ignore errors. |
| 290 | 313 | ||
| 291 | hr = PlanExecuteCheckpoint(pPlan); | 314 | hr = PlanExecuteCheckpoint(pPlan); |
| @@ -302,6 +325,24 @@ extern "C" HRESULT ExeEnginePlanAddPackage( | |||
| 302 | pAction->exePackage.pPackage = pPackage; | 325 | pAction->exePackage.pPackage = pPackage; |
| 303 | pAction->exePackage.action = pPackage->execute; | 326 | pAction->exePackage.action = pPackage->execute; |
| 304 | 327 | ||
| 328 | if (pPackage->Exe.sczIgnoreDependencies) | ||
| 329 | { | ||
| 330 | hr = StrAllocString(&pAction->exePackage.sczIgnoreDependencies, pPackage->Exe.sczIgnoreDependencies, 0); | ||
| 331 | ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore."); | ||
| 332 | } | ||
| 333 | |||
| 334 | if (pPackage->Exe.wzAncestors) | ||
| 335 | { | ||
| 336 | hr = StrAllocString(&pAction->exePackage.sczAncestors, pPackage->Exe.wzAncestors, 0); | ||
| 337 | ExitOnFailure(hr, "Failed to allocate the list of ancestors."); | ||
| 338 | } | ||
| 339 | |||
| 340 | if (pPackage->Exe.wzEngineWorkingDirectory) | ||
| 341 | { | ||
| 342 | hr = StrAllocString(&pAction->exePackage.sczEngineWorkingDirectory, pPackage->Exe.wzEngineWorkingDirectory, 0); | ||
| 343 | ExitOnFailure(hr, "Failed to allocate the custom working directory."); | ||
| 344 | } | ||
| 345 | |||
| 305 | LoggingSetPackageVariable(pPackage, NULL, FALSE, pLog, pVariables, NULL); // ignore errors. | 346 | LoggingSetPackageVariable(pPackage, NULL, FALSE, pLog, pVariables, NULL); // ignore errors. |
| 306 | } | 347 | } |
| 307 | 348 | ||
| @@ -406,27 +447,53 @@ extern "C" HRESULT ExeEngineExecutePackage( | |||
| 406 | } | 447 | } |
| 407 | 448 | ||
| 408 | // build command | 449 | // build command |
| 409 | if (*sczArguments) | 450 | AppAppendCommandLineArgument(&sczCommand, sczExecutablePath); |
| 451 | ExitOnFailure(hr, "Failed to create executable command."); | ||
| 452 | |||
| 453 | if (pPackage->Exe.fBundle) | ||
| 454 | { | ||
| 455 | hr = StrAllocConcat(&sczCommand, L" -norestart", 0); | ||
| 456 | ExitOnFailure(hr, "Failed to append quiet argument."); | ||
| 457 | |||
| 458 | // Add the list of dependencies to ignore, if any, to the burn command line. | ||
| 459 | if (pExecuteAction->exePackage.sczIgnoreDependencies) | ||
| 460 | { | ||
| 461 | hr = StrAllocConcatFormatted(&sczCommand, L" -%ls=%ls", BURN_COMMANDLINE_SWITCH_IGNOREDEPENDENCIES, pExecuteAction->exePackage.sczIgnoreDependencies); | ||
| 462 | ExitOnFailure(hr, "Failed to append the list of dependencies to ignore to the command line."); | ||
| 463 | } | ||
| 464 | |||
| 465 | // Add the list of ancestors, if any, to the burn command line. | ||
| 466 | if (pExecuteAction->exePackage.sczAncestors) | ||
| 467 | { | ||
| 468 | hr = StrAllocConcatFormatted(&sczCommand, L" -%ls=%ls", sczCommand, BURN_COMMANDLINE_SWITCH_ANCESTORS, pExecuteAction->exePackage.sczAncestors); | ||
| 469 | ExitOnFailure(hr, "Failed to append the list of ancestors to the command line."); | ||
| 470 | } | ||
| 471 | |||
| 472 | if (pExecuteAction->exePackage.sczEngineWorkingDirectory) | ||
| 473 | { | ||
| 474 | hr = CoreAppendEngineWorkingDirectoryToCommandLine(pExecuteAction->exePackage.sczEngineWorkingDirectory, &sczCommand, NULL); | ||
| 475 | ExitOnFailure(hr, "Failed to append the custom working directory to the exepackage command line."); | ||
| 476 | } | ||
| 477 | |||
| 478 | hr = CoreAppendFileHandleSelfToCommandLine(sczExecutablePath, &hExecutableFile, &sczCommand, NULL); | ||
| 479 | ExitOnFailure(hr, "Failed to append %ls", BURN_COMMANDLINE_SWITCH_FILEHANDLE_SELF); | ||
| 480 | } | ||
| 481 | |||
| 482 | // Always add user supplied arguments last. | ||
| 483 | if (sczArguments && *sczArguments) | ||
| 410 | { | 484 | { |
| 411 | hr = VariableFormatString(pVariables, sczArguments, &sczArgumentsFormatted, NULL); | 485 | hr = VariableFormatString(pVariables, sczArguments, &sczArgumentsFormatted, NULL); |
| 412 | ExitOnFailure(hr, "Failed to format argument string."); | 486 | ExitOnFailure(hr, "Failed to format argument string."); |
| 413 | 487 | ||
| 414 | hr = StrAllocFormattedSecure(&sczCommand, L"\"%ls\" %ls", sczExecutablePath, sczArgumentsFormatted); | ||
| 415 | ExitOnFailure(hr, "Failed to create executable command."); | ||
| 416 | |||
| 417 | hr = VariableFormatStringObfuscated(pVariables, sczArguments, &sczArgumentsObfuscated, NULL); | 488 | hr = VariableFormatStringObfuscated(pVariables, sczArguments, &sczArgumentsObfuscated, NULL); |
| 418 | ExitOnFailure(hr, "Failed to format obfuscated argument string."); | 489 | ExitOnFailure(hr, "Failed to format obfuscated argument string."); |
| 419 | 490 | ||
| 420 | hr = StrAllocFormatted(&sczCommandObfuscated, L"\"%ls\" %ls", sczExecutablePath, sczArgumentsObfuscated); | 491 | hr = StrAllocFormatted(&sczCommandObfuscated, L"%ls %ls", sczCommand, sczArgumentsObfuscated); |
| 421 | } | 492 | ExitOnFailure(hr, "Failed to copy obfuscated formatted arguments."); |
| 422 | else | ||
| 423 | { | ||
| 424 | hr = StrAllocFormatted(&sczCommand, L"\"%ls\"", sczExecutablePath); | ||
| 425 | ExitOnFailure(hr, "Failed to create executable command."); | ||
| 426 | 493 | ||
| 427 | hr = StrAllocFormatted(&sczCommandObfuscated, L"\"%ls\"", sczExecutablePath); | 494 | hr = StrAllocConcatFormattedSecure(&sczCommand, L" %ls", sczArgumentsFormatted); |
| 495 | ExitOnFailure(hr, "Failed to copy formatted arguments."); | ||
| 428 | } | 496 | } |
| 429 | ExitOnFailure(hr, "Failed to create obfuscated executable command."); | ||
| 430 | 497 | ||
| 431 | // Log before we add the secret pipe name and client token for embedded processes. | 498 | // Log before we add the secret pipe name and client token for embedded processes. |
| 432 | LogId(REPORT_STANDARD, MSG_APPLYING_PACKAGE, LoggingRollbackOrExecute(fRollback), pPackage->sczId, LoggingActionStateToString(pExecuteAction->exePackage.action), sczExecutablePath, sczCommandObfuscated); | 499 | LogId(REPORT_STANDARD, MSG_APPLYING_PACKAGE, LoggingRollbackOrExecute(fRollback), pPackage->sczId, LoggingActionStateToString(pExecuteAction->exePackage.action), sczExecutablePath, sczCommandObfuscated); |
