diff options
author | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2021-02-05 11:47:31 +0100 |
---|---|---|
committer | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2021-02-05 12:55:04 +0100 |
commit | aac30ff4d266a208fe7c6919f1b48f7c17de6452 (patch) | |
tree | 302909e2c2e56324e30ba87eca68a4d208ce930f | |
parent | 146801388bd663800ae00c08e8a496f2ab11662d (diff) | |
download | crash-worker-aac30ff4d266a208fe7c6919f1b48f7c17de6452.tar.gz crash-worker-aac30ff4d266a208fe7c6919f1b48f7c17de6452.tar.bz2 crash-worker-aac30ff4d266a208fe7c6919f1b48f7c17de6452.zip |
Set permissions explicitly for directories and reports
Change-Id: If01ddf2a7f73a6b808f3cd8d39f20a77c74231d3
-rw-r--r-- | include/defs.h.in | 2 | ||||
-rw-r--r-- | src/crash-manager/crash-manager.c | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/include/defs.h.in b/include/defs.h.in index 8c0760a..906b649 100644 --- a/include/defs.h.in +++ b/include/defs.h.in @@ -3,6 +3,8 @@ #define KERNEL_DEFINED_TASK_COMM_LEN 16 // from include/linux/sched.h #define DEFAULT_UMASK 0077 +#define DEFAULT_REPORT_PERM 0644 +#define DEFAULT_CRASH_DIR_PERM 0775 #define CRASH_PATH "@CRASH_PATH@" #define CRASH_ROOT_PATH "@CRASH_ROOT_PATH@" diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index ea4c3b7..d3f4e98 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -262,14 +262,17 @@ static bool make_dump_dir(void) const char *dirname = dirs[i]; int r = mkdir(dirname, 0775); - if (r >= 0) - continue; - if (errno != EEXIST) { + if (r < 0 && errno != EEXIST) { _E("Unable to create directory %s: %m", dirname); return false; } + chmod(dirname, DEFAULT_CRASH_DIR_PERM); // Fixup permissions for directories created with bad umask + + if (r >= 0) + continue; + struct stat st = {0}; r = stat(dirname, &st); bool isdir = !!(st.st_mode & S_IFDIR); @@ -1177,9 +1180,10 @@ static bool move_dump_data(const char *from_path, const struct crash_info *cinfo if ((lock_fd = lock_dir(crash_dump_path, false)) < 0) return false; - if (!rename(from_path, cinfo->result_path)) + if (!rename(from_path, cinfo->result_path)) { + chmod(cinfo->result_path, DEFAULT_REPORT_PERM); clean_dump(); - else { + } else { _E("Failed to move %s to %s", from_path, cinfo->result_path); (void)check_disk_available(crash_dump_path, SPACE_REQUIRED_KB); is_ok = false; |