Fix handling CrashRootPath from the config file 19/319719/1 accepted/tizen/7.0/unified/20241031.071807
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 31 Oct 2024 00:17:29 +0000 (09:17 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 31 Oct 2024 00:18:13 +0000 (09:18 +0900)
Change-Id: I54c1477f8f9a015cbd9023043e36845bc38903b3
Signed-off-by: Mateusz Moscicki <m.moscicki2@partner.samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
packaging/crash-worker.spec
src/bugreport-service/diagnostics/diagnostics_dump.c
src/bugreport-service/systemdump.c

index 6422b28d22ae66bd60823c4de1293aeb0d27a2fd..4aa3aadb2c6a4a532bf883fdbc3c50ea6e1e7728 100644 (file)
@@ -16,7 +16,7 @@
 
 Name:           crash-worker
 Summary:        Coredump handler and report generator for Tizen
-Version:        7.0.1
+Version:        7.0.2
 Release:        1
 Group:          Framework/system
 License:        MIT
index bff0b006e5536b21da82f5086fb84fc79d1a3a2f..c1a25e72c94198c7717a2e53c7fd4d19d705b6ba 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "diagnostics/diagnostics.h"
 #include "diagnostics/diagnostics_dump.h"
+#include "shared/config.h"
 #include "shared/log.h"
 #include "shared/util.h"
 
@@ -139,9 +140,20 @@ static struct report_file* get_reports(size_t *count)
        struct report_file *list = NULL;
        *count = 0;
 
+       config_t config;
+       char *crash_root_path = NULL;
+       if (config_init(&config, CRASH_MANAGER_CONFIG_PATH))
+               crash_root_path = config.crash_root_path;
+       else
+               crash_root_path = CRASH_ROOT_PATH;
+
+       char crash_path[PATH_MAX];
+       char live_path[PATH_MAX];
+       snprintf(crash_path, sizeof(crash_path)-1, "%s%s", crash_root_path, CRASH_PATH_SUBDIR);
+       snprintf(live_path, sizeof(live_path)-1, "%s%s", crash_root_path, LIVE_PATH_SUBDIR);
        const char *dirs[] = {
-               CRASH_ROOT_PATH CRASH_PATH_SUBDIR,
-               CRASH_ROOT_PATH LIVE_PATH_SUBDIR
+               crash_path,
+               live_path
        };
 
        for (int i = 0; i < ARRAY_SIZE(dirs); i++) {
index df3e146a57e8544a4719eb72898d2ce84b33e268..0aca439a124572cc364ac2b372b3e877937b7f27 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "systemdump.h"
 #include "defs.h"
+#include "shared/config.h"
 #include "shared/spawn.h"
 #include "shared/util.h"
 #include "shared/log.h"
@@ -73,11 +74,22 @@ static bool prepare_paths(struct systemstate_info *sinfo)
        time_t time_info = time(NULL);
        localtime_r(&time_info, &loc_tm);
        strftime(date, sizeof(date), "%Y%m%d%H%M%S", &loc_tm);
+       config_t config;
+       const char *crash_root_path;
+       if (config_init(&config, CRASH_MANAGER_CONFIG_PATH))
+               crash_root_path = config.crash_root_path;
+       else
+               crash_root_path = CRASH_ROOT_PATH;
+
+       char *crash_temp_path;
+       if (asprintf(&crash_temp_path, "%s/temp", crash_root_path) == -1) {
+               goto out_of_memory;
+       }
 
-       if (!make_dir(CRASH_TEMP, DEFAULT_CRASH_DIR_PERM))
+       if (!make_dir(crash_temp_path, DEFAULT_CRASH_DIR_PERM))
                return false;
 
-       if (asprintf(&sinfo->temp_path, "%s/crash.XXXXXX", CRASH_TEMP) == -1)
+       if (asprintf(&sinfo->temp_path, "%s/crash.XXXXXX", crash_temp_path) == -1)
                goto out_of_memory;
 
        if (mkdtemp(sinfo->temp_path) == NULL || access(sinfo->temp_path, F_OK)) {
@@ -88,7 +100,7 @@ static bool prepare_paths(struct systemstate_info *sinfo)
        if (asprintf(&sinfo->report_name, "system_0_%s", date) == -1 ||
            asprintf(&sinfo->temp_report_dir, "%s/%s", sinfo->temp_path, sinfo->report_name) == -1 ||
            asprintf(&sinfo->log_path, "%s/%s.log", sinfo->temp_report_dir, sinfo->report_name) == -1 ||
-           asprintf(&sinfo->reports_dir, "%s%s", CRASH_ROOT_PATH, LIVE_PATH_SUBDIR) == -1 ||
+           asprintf(&sinfo->reports_dir, "%s%s", crash_root_path, LIVE_PATH_SUBDIR) == -1 ||
            asprintf(&sinfo->zip_path, "%s/report.zip", sinfo->temp_path) == -1 ||
            asprintf(&sinfo->report_path, "%s%s.%s", sinfo->reports_dir, sinfo->report_name, "zip") == -1)
                goto out_of_memory;