Allow disabling so_info generation via config file 03/228203/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 19 Mar 2020 14:06:45 +0000 (15:06 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 19 Mar 2020 15:15:49 +0000 (16:15 +0100)
Change-Id: I89d3b687225a7a85498344c9dd84c17ba4f3e33b

packaging/crash-worker.spec
src/crash-manager/crash-manager.c
src/crash-manager/crash-manager.conf
src/shared/config.c
src/shared/config.h
tests/system/CMakeLists.txt
tests/system/without_so_info_file/without_so_info_file.sh.template [new file with mode: 0644]

index 7c75698..f40ad8c 100644 (file)
@@ -268,6 +268,7 @@ mkdir -p %{buildroot}%{crash_temp}
 %{_libdir}/crash-worker/system-tests/utils/libcrash-servicetest
 %{_libdir}/crash-worker/system-tests/utils/minicore-utils.sh
 %{_libdir}/crash-worker/system-tests/wait_for_opt_usr/wait_for_opt_usr.sh
+%{_libdir}/crash-worker/system-tests/without_so_info_file/without_so_info_file.sh
 %{_libdir}/crash-worker/system-tests/without_core/without_core.sh
 
 %if %{with livedumper}
index 7e88660..0f4cdae 100644 (file)
@@ -1066,7 +1066,10 @@ static bool run(struct crash_info *cinfo)
        char *temp_report;
        if (config.report_type >= REP_TYPE_FULL) {
                /* Save shared objects info (file names, bulid IDs, rpm package names) */
-               save_so_info(cinfo);
+               if (config.dump_so_info)
+                       save_so_info(cinfo);
+               else
+                       _I("Not saving .so_info (disabled in configuration)");
 
                /* Wait misc. pids */
                wait_for_pid(dump_state_pid, NULL);
index dfa2d1b..09f3926 100644 (file)
@@ -15,6 +15,15 @@ AllowZip=yes
 # This option applies to ReportType=FULL only!
 # DumpCore=1
 
+# DumpSharedObjectInfo - 1 to enable (default), 0 to disable
+# This option controls creation of .so_info file
+#
+# Note! When set to 0 report will not include information about packages that were
+# mapped into process memory. This information is normally needed to re-create
+# sysroot for the use with debugger.
+#
+# DumpSharedObjectInfo=1
+
 # Use Legacy ProcessCrashed DBus signal
 #   When '0' (default), crash worker emits new-style signal with extensive data:
 #     1. cmd name,
index a35d191..60f168e 100644 (file)
@@ -151,6 +151,7 @@ static bool config_load_from_dict(config_t *c, const dictionary *ini)
        UPDATE(c->max_retention_sec, int, "MaxRetentionSec");
        UPDATE(c->max_crash_dump, int, "MaxCrashDump");
        UPDATE(c->dump_core, boolean, "DumpCore");
+       UPDATE(c->dump_so_info, boolean, "DumpSharedObjectInfo");
        UPDATE(c->allow_zip, boolean, "AllowZip");
        UPDATE(c->legacy_notification, boolean, "UseLegacyNotification");
 
@@ -247,6 +248,7 @@ static bool config_apply_defaults(config_t *c)
        c->max_retention_sec = MAX_RETENTION_SEC;
        c->max_crash_dump = MAX_CRASH_DUMP;
        c->dump_core = DUMP_CORE;
+       c->dump_so_info = DUMP_SO_INFO;
        c->allow_zip = ALLOW_ZIP;
        c->legacy_notification = LEGACY_NOTIFICATION;
 
@@ -265,6 +267,7 @@ static void config_dump(config_t *c)
           "config: max_retention_sec = %d\n"
           "config: max_crash_dump = %d\n"
           "config: dump_core = %d\n"
+          "config: dump_so_info = %d\n"
           "config: allow_zip = %d\n"
           "config: legacy_notification = %d\n",
           c->crash_root_path,
@@ -275,6 +278,7 @@ static void config_dump(config_t *c)
           c->max_retention_sec,
           c->max_crash_dump,
           c->dump_core,
+          c->dump_so_info,
           c->allow_zip,
           c->legacy_notification);
 }
index f32d7f0..00b71b7 100644 (file)
@@ -26,6 +26,7 @@
 #define MAX_RETENTION_SEC    0
 #define MAX_CRASH_DUMP       0
 #define DUMP_CORE            1
+#define DUMP_SO_INFO         1
 #define ALLOW_ZIP            1
 #define LEGACY_NOTIFICATION  0
 
@@ -42,6 +43,7 @@ enum ReportType {
 typedef struct config {
        bool allow_zip;
        bool dump_core;
+       bool dump_so_info;
        bool legacy_notification;
        enum ReportType report_type;
        int system_max_use;
index eace3ef..4039b25 100644 (file)
@@ -28,6 +28,7 @@ configure_test("so_info_file")
 configure_test("report_basic")
 configure_test("report_type_info")
 configure_test("without_core")
+configure_test("without_so_info_file")
 configure_test("crash_root_path")
 configure_test("dump_systemstate_extras")
 configure_test("livedumper")
diff --git a/tests/system/without_so_info_file/without_so_info_file.sh.template b/tests/system/without_so_info_file/without_so_info_file.sh.template
new file mode 100644 (file)
index 0000000..038e773
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Checks ability to disable .so_info
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+CONF_DIR=/etc/crash-manager.conf.d
+CONF_FILE=${CONF_DIR}/crash-worker-without-so-info.conf
+
+mount -o rw,remount /
+
+mkdir -p $CONF_DIR
+rm -f $CONF_FILE || :
+cat <<EOF >$CONF_FILE
+[CrashManager]
+DumpSharedObjectInfo=0
+EOF
+
+clean_crash_dump
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+wait_for_app crash-manager
+
+rm -f ${CONF_FILE} || :
+
+test -f ${CRASH_DUMP_PATH}/kenny*zip || fail "crash report not created"
+unzip -l ${CRASH_DUMP_PATH}/kenny*zip | egrep 'kenny*/kenny*.so_info$' && fail ".so_info file found despite being disabled in config"
+
+exit_ok