tdf#127711 - A runtime-switch for the MiniCrashDump

- in soffice.ini (sofficerc) the entry "CrashDumpEnable" default is "true"
    - when false then the Dump.ini and the dump-file are not written
    - when the switch --disable-crashdump is set, then the
      switch "CrashDumpEnable" set to "false"
    - when the entry "CrashDumpEnable" is missing, in this case is the
      default true, too
    - the checkbox under Options-General "Send crash reports to ..."
      is deactive and shows off (only view, not change the config)

 - when set the environment variable "CRASH_DUMP_ENABLE" to any char
   then the switch "CrashDumpEnable=false" are overrules with true
   and the Dump.ini and dump-file are write

Change-Id: I34e7795640eb95d111e18b0ad46ec67b2c126b19
Reviewed-on: https://gerrit.libreoffice.org/79273
Tested-by: Jenkins
Reviewed-by: Juergen Funk (CIB) <juergen.funk_ml@cib.de>
This commit is contained in:
Juergen Funk
2019-09-18 11:48:21 +02:00
committed by Juergen Funk (CIB)
parent be64610dba
commit 2215be5268
8 changed files with 67 additions and 12 deletions

View File

@@ -118,6 +118,7 @@ export EBOOK_LIBS=$(gb_SPACE)@EBOOK_LIBS@
export ENABLE_ANDROID_EDITING=@ENABLE_ANDROID_EDITING@
export ENABLE_AVAHI=@ENABLE_AVAHI@
export ENABLE_BREAKPAD=@ENABLE_BREAKPAD@
export DEFAULT_CRASHDUMP_VALUE=@DEFAULT_CRASHDUMP_VALUE@
export ENABLE_CAIRO_CANVAS=@ENABLE_CAIRO_CANVAS@
export ENABLE_CHART_TESTS=@ENABLE_CHART_TESTS@
export ENABLE_CIPHER_OPENSSL_BACKEND=@ENABLE_CIPHER_OPENSSL_BACKEND@

View File

@@ -1050,6 +1050,11 @@ libo_FUZZ_ARG_ENABLE(breakpad,
[Enables breakpad for crash reporting.])
)
libo_FUZZ_ARG_ENABLE(crashdump,
AS_HELP_STRING([--disable-crashdump],
[Disable dump.ini and dump-file, when --enable-breakpad])
)
AC_ARG_ENABLE(fetch-external,
AS_HELP_STRING([--disable-fetch-external],
[Disables fetching external tarballs from web sources.])
@@ -9515,6 +9520,7 @@ AC_SUBST(ICU_UCHAR_TYPE)
dnl ==================================================================
dnl Breakpad
dnl ==================================================================
DEFAULT_CRASHDUMP_VALUE="true"
AC_MSG_CHECKING([whether to enable breakpad])
if test "$enable_breakpad" != yes; then
AC_MSG_RESULT([no])
@@ -9525,6 +9531,14 @@ else
AC_DEFINE(HAVE_FEATURE_BREAKPAD, 1)
BUILD_TYPE="$BUILD_TYPE BREAKPAD"
AC_MSG_CHECKING([for disable crash dump])
if test "$enable_crashdump" = no; then
DEFAULT_CRASHDUMP_VALUE="false"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_MSG_CHECKING([for crashreport config])
if test "$with_symbol_config" = "no"; then
BREAKPAD_SYMBOL_CONFIG="invalid"
@@ -9537,6 +9551,7 @@ else
AC_SUBST(BREAKPAD_SYMBOL_CONFIG)
fi
AC_SUBST(ENABLE_BREAKPAD)
AC_SUBST(DEFAULT_CRASHDUMP_VALUE)
dnl ==================================================================
dnl libfuzzer

View File

@@ -59,6 +59,9 @@ $(eval $(call gb_Library_use_libraries,cui,\
ucbhelper \
utl \
vcl \
$(if $(ENABLE_BREAKPAD), \
crashreport \
) \
))
$(eval $(call gb_Library_use_externals,cui,\

View File

@@ -51,6 +51,7 @@
#include <officecfg/Setup.hxx>
#include <comphelper/configuration.hxx>
#include <tools/diagnose_ex.h>
#include <desktop/crashreport.hxx>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -392,8 +393,8 @@ void OfaMiscTabPage::Reset( const SfxItemSet* rSet )
m_xCollectUsageInfo->save_state();
#if HAVE_FEATURE_BREAKPAD
m_xCrashReport->set_active(officecfg::Office::Common::Misc::CrashReport::get());
m_xCrashReport->set_sensitive(!officecfg::Office::Common::Misc::CrashReport::isReadOnly());
m_xCrashReport->set_active(officecfg::Office::Common::Misc::CrashReport::get() && CrashReporter::IsDumpEnable());
m_xCrashReport->set_sensitive(!officecfg::Office::Common::Misc::CrashReport::isReadOnly() && CrashReporter::IsDumpEnable());
m_xCrashReport->save_state();
#else
m_xCrashReport->hide();

View File

@@ -62,15 +62,18 @@ void CrashReporter::addKeyValue(const OUString& rKey, const OUString& rValue, tA
{
osl::MutexGuard aGuard(maMutex);
if(!rKey.isEmpty())
maKeyValues.push_back(mpair(rKey, rValue));
if(AddKeyHandling != AddItem)
if (IsDumpEnable())
{
if(mbInit)
writeToFile(std::ios_base::app);
else if (AddKeyHandling == Create)
writeCommonInfo();
if (!rKey.isEmpty())
maKeyValues.push_back(mpair(rKey, rValue));
if (AddKeyHandling != AddItem)
{
if (mbInit)
writeToFile(std::ios_base::app);
else if (AddKeyHandling == Create)
writeCommonInfo();
}
}
}
@@ -84,8 +87,9 @@ void CrashReporter::writeCommonInfo()
const ucbhelper::InternetProxyServer proxy_server = proxy_decider.getProxy(protocol, url, port);
// save the Keys
// save the new Keys
vmaKeyValues atlast = maKeyValues;
// clear the keys, the following Keys should be at the begin
maKeyValues.clear();
// limit the amount of code that needs to be executed before the crash reporting
@@ -99,6 +103,7 @@ void CrashReporter::writeCommonInfo()
addKeyValue("Proxy", proxy_server.aName + ":" + OUString::number(proxy_server.nPort), AddItem);
}
// write the new keys at the end
maKeyValues.insert(maKeyValues.end(), atlast.begin(), atlast.end());
mbInit = true;
@@ -168,9 +173,27 @@ bool CrashReporter::readSendConfig(std::string& response)
void CrashReporter::storeExceptionHandler(google_breakpad::ExceptionHandler* pExceptionHandler)
{
mpExceptionHandler = pExceptionHandler;
if(IsDumpEnable())
mpExceptionHandler = pExceptionHandler;
}
bool CrashReporter::IsDumpEnable()
{
OUString sToken;
OString sEnvVar(std::getenv("CRASH_DUMP_ENABLE"));
bool bEnable = true; // default, always on
// read configuration item 'CrashDumpEnable' -> bool on/off
if (rtl::Bootstrap::get("CrashDumpEnable", sToken) && sEnvVar.isEmpty())
{
bEnable = sToken.toBoolean();
}
return bEnable;
}
std::string CrashReporter::getIniFileName()
{
OUString url = getCrashDirectory() + "dump.ini";

View File

@@ -52,6 +52,8 @@ public:
static bool readSendConfig(std::string& response);
static bool IsDumpEnable();
private:
static osl::Mutex maMutex;
static bool mbInit;

View File

@@ -119,6 +119,7 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_
( \
echo '[Bootstrap]' \
&& echo 'CrashDirectory=$${$$BRAND_BASE_DIR/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,bootstrap):UserInstallation}/crash' \
&& echo 'CrashDumpEnable=$(DEFAULT_CRASHDUMP_VALUE)' \
&& echo 'HideEula=1' \
&& echo 'Logo=1' \
&& echo 'NativeProgress=false' \

View File

@@ -439,6 +439,15 @@ ProfileItem gid_Brand_Profileitem_Soffice_CrashDirectory
Value = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" PROFILENAME(bootstrap) ":UserInstallation}/crash";
End
ProfileItem gid_Brand_Profileitem_Soffice_CrashDump
ProfileID = gid_Brand_Profile_Soffice_Ini;
ModuleID = gid_Module_Root_Brand;
Section = "Bootstrap";
Key = "CrashDumpEnable";
Value = "true";
End
ProfileItem gid_Brand_Profileitem_Soffice_SecureUserConfig
ProfileID = gid_Brand_Profile_Soffice_Ini;
ModuleID = gid_Module_Root_Brand;