Fix handling CrashRootPath from the config file 52/319752/1
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 31 Oct 2024 10:13:26 +0000 (19:13 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 31 Oct 2024 10:13:26 +0000 (19:13 +0900)
Change-Id: If82330f1dfc5ae1bbe521fc77b3f5b01425f97cf
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 a7a2c70c994b98cee5f95eee416f105e0cb38070..35bf25e298a9c092dcf405961a3004b526d205b2 100644 (file)
@@ -16,7 +16,7 @@
 
 Name:           crash-worker
 Summary:        Coredump handler and report generator for Tizen
-Version:        8.0.4
+Version:        8.0.5
 Release:        1
 Group:          Framework/system
 License:        MIT
index 93258e339ffeb1708842fd2673d01caa868e6d92..8daed4e92695cb37b6c6e1e8347461ae24ce8df3 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;