Skip to content

Commit

Permalink
Support to Bypass Store Client App Policy When Called Through COM (#3105
Browse files Browse the repository at this point in the history
)
  • Loading branch information
PaulJYim authored Mar 31, 2023
1 parent 741244e commit 9f8fb4c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/specs/#888 - Com Api.md
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,8 @@ namespace Microsoft.Management.Deployment
String LogOutputPath;
/// Continues the install even if the hash in the catalog does not match the linked installer.
Boolean AllowHashMismatch;
/// Allows Store installs when Store Client is disabled.
Boolean BypassIsStoreClientBlockedPolicyCheck;
/// A string that will be passed to the installer.
/// IMPLEMENTATION NOTE: maps to "--override" in the winget cmd line
String ReplacementInstallerArguments;
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/ExecutionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace AppInstaller::CLI::Execution
TreatSourceFailuresAsWarning = 0x8,
ShowSearchResultsOnPartialFailure = 0x10,
DisableInteractivity = 0x40,
BypassIsStoreClientBlockedPolicyCheck = 0x80,
};

DEFINE_ENUM_FLAG_OPERATORS(ContextFlag);
Expand Down
5 changes: 3 additions & 2 deletions src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ namespace AppInstaller::CLI::Workflow
constexpr std::wstring_view s_StoreClientPublisher = L"CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"sv;

// Policy check
AppInstallManager installManager;
if (installManager.IsStoreBlockedByPolicyAsync(s_StoreClientName, s_StoreClientPublisher).get())
AppInstallManager installManager;

if (!WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::BypassIsStoreClientBlockedPolicyCheck) && installManager.IsStoreBlockedByPolicyAsync(s_StoreClientName, s_StoreClientPublisher).get())
{
context.Reporter.Error() << Resource::String::MSStoreStoreClientBlocked << std::endl;
AICLI_LOG(CLI, Error, << "Store client is blocked by policy. MSStore execution failed.");
Expand Down
8 changes: 8 additions & 0 deletions src/Microsoft.Management.Deployment/InstallOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ namespace winrt::Microsoft::Management::Deployment::implementation
{
m_allowHashMismatch = value;
}
bool InstallOptions::BypassIsStoreClientBlockedPolicyCheck()
{
return m_bypassIsStoreClientBlockedPolicyCheck;
}
void InstallOptions::BypassIsStoreClientBlockedPolicyCheck(bool value)
{
m_bypassIsStoreClientBlockedPolicyCheck = value;
}
hstring InstallOptions::ReplacementInstallerArguments()
{
return hstring(m_replacementInstallerArguments);
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.Management.Deployment/InstallOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation
void LogOutputPath(hstring const& value);
bool AllowHashMismatch();
void AllowHashMismatch(bool value);
bool BypassIsStoreClientBlockedPolicyCheck();
void BypassIsStoreClientBlockedPolicyCheck(bool value);
hstring ReplacementInstallerArguments();
void ReplacementInstallerArguments(hstring const& value);
hstring AdditionalInstallerArguments();
Expand All @@ -47,6 +49,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation
winrt::Microsoft::Management::Deployment::PackageInstallMode m_packageInstallMode = winrt::Microsoft::Management::Deployment::PackageInstallMode::Default;
std::wstring m_logOutputPath = L"";
bool m_allowHashMismatch = false;
bool m_bypassIsStoreClientBlockedPolicyCheck = false;
std::wstring m_replacementInstallerArguments = L"";
std::wstring m_additionalInstallerArguments = L"";
std::wstring m_correlationData = L"";
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.Management.Deployment/PackageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ namespace winrt::Microsoft::Management::Deployment::implementation
{
context->Args.AddArg(Execution::Args::Type::HashOverride);
}

if (options.BypassIsStoreClientBlockedPolicyCheck())
{
context->SetFlags(Execution::ContextFlag::BypassIsStoreClientBlockedPolicyCheck);
}

if (options.Force())
{
context->Args.AddArg(Execution::Args::Type::Force);
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.Management.Deployment/PackageManager.idl
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@ namespace Microsoft.Management.Deployment

/// Accept the package agreements required for installation.
Boolean AcceptPackageAgreements;

/// Bypasses the Disabled Store Policy
Boolean BypassIsStoreClientBlockedPolicyCheck;

This comment has been minimized.

Copy link
@ChrisGuzak

ChrisGuzak May 1, 2023

Member

this looks like a breaking change. seems it needs to be under an API contract with a new number.

}
}

Expand Down

0 comments on commit 9f8fb4c

Please sign in to comment.