summaryrefslogtreecommitdiff
path: root/setup_native
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-12-08 23:35:37 +0300
committerCaolán McNamara <caolanm@redhat.com>2018-12-09 22:15:55 +0100
commit79defcb4a9d559c16f59af561f7767f8fbfed98d (patch)
treef6d97c489ec0a5f68d7ed6f41fd7c438368842b7 /setup_native
parent03f724a1ba9155a100f51954871f22f858859299 (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/64828 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'setup_native')
-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 c8d649a6f4d9..96fb88f4b889 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" __declspec(dllexport) 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());