From: Mateusz Moscicki Date: Thu, 31 Oct 2024 00:17:29 +0000 (+0900) Subject: Fix handling CrashRootPath from the config file X-Git-Tag: accepted/tizen/7.0/unified/20241031.071807^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=822d7d37598c6f2ea9d2bde90085b37cda8aaebc;p=platform%2Fcore%2Fsystem%2Fcrash-worker.git Fix handling CrashRootPath from the config file Change-Id: I54c1477f8f9a015cbd9023043e36845bc38903b3 Signed-off-by: Mateusz Moscicki Signed-off-by: Chanwoo Choi --- diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 6422b28d..4aa3aadb 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -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 diff --git a/src/bugreport-service/diagnostics/diagnostics_dump.c b/src/bugreport-service/diagnostics/diagnostics_dump.c index bff0b006..c1a25e72 100644 --- a/src/bugreport-service/diagnostics/diagnostics_dump.c +++ b/src/bugreport-service/diagnostics/diagnostics_dump.c @@ -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++) { diff --git a/src/bugreport-service/systemdump.c b/src/bugreport-service/systemdump.c index df3e146a..0aca439a 100644 --- a/src/bugreport-service/systemdump.c +++ b/src/bugreport-service/systemdump.c @@ -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;