From 6b34e49391094bd1a0d5b2d6dfad42b26d0dabc8 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Thu, 19 Dec 2024 11:20:56 +0100 Subject: Optionally disable crashreporter UI Change-Id: I0eea6267bbd3082e185dc0be3ff0371aabc0c101 --- desktop/source/app/app.cxx | 3 ++- desktop/source/app/crashreport.cxx | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index d30bd0e582f3..0cd3b2b40f48 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -2031,7 +2031,8 @@ void Desktop::OpenClients() #endif #if HAVE_FEATURE_BREAKPAD - if (officecfg::Office::Common::Misc::CrashReport::get() && CrashReporter::crashReportInfoExists()) + if (CrashReporter::IsDumpEnable() && + officecfg::Office::Common::Misc::CrashReport::get() && CrashReporter::crashReportInfoExists()) handleCrashReport(); #endif diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx index 18db12d07b38..b8d3a9400b29 100644 --- a/desktop/source/app/crashreport.cxx +++ b/desktop/source/app/crashreport.cxx @@ -131,9 +131,21 @@ void CrashReporter::writeCommonInfo() ucbhelper::InternetProxyDecider proxy_decider(::comphelper::getProcessComponentContext()); static constexpr OUString protocol = u"https"_ustr; - static constexpr OUString url = u"crashreport.libreoffice.org"_ustr; const sal_Int32 port = 443; + // read configuration item 'CrashDumpUrl' + OUString url; + rtl::Bootstrap::get("CrashDumpUrl", url); + if (url.isEmpty()) + { + // no url in config, bail out, but still set proper crash + // directory for local dump generation (in case + // CrashDumpEnable is on + updateMinidumpLocation(); + mbInit = false; + return; + } + const OUString proxy_server = proxy_decider.getProxy(protocol, url, port); // save the new Keys @@ -269,6 +281,12 @@ void CrashReporter::removeExceptionHandler() bool CrashReporter::IsDumpEnable() { + static bool bConfigRead = false; + static bool bEnable = true; // default, always on + + if (bConfigRead) + return bEnable; + auto const env = std::getenv("CRASH_DUMP_ENABLE"); if (env != nullptr && env[0] != '\0') { return true; @@ -277,9 +295,11 @@ bool CrashReporter::IsDumpEnable() OUString sToken; if (rtl::Bootstrap::get("CrashDumpEnable", sToken)) { - return sToken.toBoolean(); + bEnable = sToken.toBoolean(); } - return true; // default, always on + + bConfigRead = true; + return bEnable; } -- cgit