#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@"
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);
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;