Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to Bypass Store Client App Policy When Called Through COM #3105

Merged
merged 9 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ -349,6 +349,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;
}
}

Expand Down