summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-12-08 23:35:37 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-08-30 23:32:15 +0200
commita5cd307a84d4d390462c7ee53d436efc2459c92d (patch)
tree01771cd9615db7281db21438e9412c0ba6978fe2
parent9de835ae66a9b26bd57f580bc670831cf2a313f3 (diff)
tdf#121987: Don't fail installation if failed to enable WU service
Since commit 1882827320ed760de82211cf690b686f8d34ff74, an attempt to install UCRT will be performed regardless there is an evidence that it's present on the system, to workaround some cases where the existing UCRT is broken (tdf#115405, tdf#119910). But that made other errors to emerge: on systems where users disable WU service using some exotic ways, installer is unable to enable the service, and fails. [1][2] Examples of such hard-disables are using `sc delete` [3] and associating WU service with a guest account. Many such cases are reported for Windows 10, where installation of the UCRT is not required. So the solution (imperfect, but possibly the best possible here) is to allow installer to continue in case of failure enabling the service. This will automatically eliminate all problems related to Win10; and also for cases where users are advanced enough (the majority of such hard-disable cases should be those), it might be enough to add a relevant FAQ entry. [1] https://ask.libreoffice.org/en/question/172227/cannot-install-631/ [2] https://ask.libreoffice.org/en/question/175571/installation-failed-unknown-error-win10x64/ [3] https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/sc-delete Change-Id: Ie85016eb6f0667f39412a3089fe1b1855cb1fc73 Reviewed-on: https://gerrit.libreoffice.org/64825 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 53058090beede6a399e2f408f62c28a2921ff8ab) Reviewed-on: https://gerrit.libreoffice.org/64829 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--setup_native/source/win32/customactions/inst_msu/inst_msu.cxx66
1 files changed, 47 insertions, 19 deletions
diff --git a/setup_native/source/win32/customactions/inst_msu/inst_msu.cxx b/setup_native/source/win32/customactions/inst_msu/inst_msu.cxx
index b03d3cf3791c..fe948a97d595 100644
--- a/setup_native/source/win32/customactions/inst_msu/inst_msu.cxx
+++ b/setup_native/source/win32/customactions/inst_msu/inst_msu.cxx
@@ -166,6 +166,16 @@ bool IsWow64Process()
#endif
}
+// An exception class to differentiate a non-fatal exception
+class nonfatal_exception : public std::exception
+{
+public:
+ nonfatal_exception(const std::exception& e)
+ : std::exception(e)
+ {
+ }
+};
+
// Checks if Windows Update service is disabled, and if it is, enables it temporarily.
class WUServiceEnabler
{
@@ -195,27 +205,37 @@ public:
private:
static CloseServiceHandleGuard EnableWUService(MSIHANDLE hInstall)
{
- auto hSCM = Guard(OpenSCManagerW(nullptr, nullptr, SC_MANAGER_ALL_ACCESS));
- if (!hSCM)
- ThrowLastError("OpenSCManagerW");
- WriteLog(hInstall, "Opened service control manager");
-
- auto hService = Guard(OpenServiceW(hSCM.get(), L"wuauserv",
- SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG
- | SERVICE_QUERY_STATUS | SERVICE_STOP));
- if (!hService)
- ThrowLastError("OpenServiceW");
- WriteLog(hInstall, "Obtained WU service handle");
-
- if (ServiceStatus(hInstall, hService.get()) == SERVICE_RUNNING
- || !EnsureServiceEnabled(hInstall, hService.get(), true))
+ try
{
- // No need to restore anything back, since we didn't change config
- hService.reset();
- WriteLog(hInstall, "Service configuration is unchanged");
- }
+ auto hSCM = Guard(OpenSCManagerW(nullptr, nullptr, SC_MANAGER_ALL_ACCESS));
+ if (!hSCM)
+ ThrowLastError("OpenSCManagerW");
+ WriteLog(hInstall, "Opened service control manager");
+
+ auto hService = Guard(OpenServiceW(hSCM.get(), L"wuauserv",
+ SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG
+ | SERVICE_QUERY_STATUS | SERVICE_STOP));
+ if (!hService)
+ ThrowLastError("OpenServiceW");
+ WriteLog(hInstall, "Obtained WU service handle");
+
+ if (ServiceStatus(hInstall, hService.get()) == SERVICE_RUNNING
+ || !EnsureServiceEnabled(hInstall, hService.get(), true))
+ {
+ // No need to restore anything back, since we didn't change config
+ hService.reset();
+ WriteLog(hInstall, "Service configuration is unchanged");
+ }
- return hService;
+ return hService;
+ }
+ catch (const std::exception& e)
+ {
+ // Allow errors opening service to be logged, but not interrupt installation.
+ // They are likely to happen in situations where people hard-disable WU service,
+ // and for these cases, let people deal with install logs instead of failing.
+ throw nonfatal_exception(e);
+ }
}
// Returns if the service configuration was actually changed
@@ -476,6 +496,14 @@ extern "C" UINT __stdcall InstallMSU(MSIHANDLE hInstall)
ThrowWin32Error("Execution of wusa.exe", nExitCode);
}
}
+ catch (nonfatal_exception& e)
+ {
+ // An error that should not interrupt installation
+ WriteLog(hInstall, e.what());
+ WriteLog(hInstall, "Installation of MSU package failed, but installation of product will "
+ "continue. You may need to install the required update manually");
+ return ERROR_SUCCESS;
+ }
catch (std::exception& e)
{
WriteLog(hInstall, e.what());