static bool problem_info_ensure_writable(problem_info_t *pi) { if (pi->is_writable) return true; /* chown the directory in any case, because kernel oopses are not foreign */ /* but their dump directories are not writable without chowning them or */ /* stealing them. The stealing is deprecated as it breaks the local */ /* duplicate search and root cannot see them */ const int res = chown_dir_over_dbus(problem_info_get_dir(pi)); if (pi->foreign && res != 0) { error_msg(_("Can't take ownership of '%s'"), problem_info_get_dir(pi)); return false; } pi->foreign = false; struct dump_dir *dd = open_directory_for_writing(problem_info_get_dir(pi), /* don't ask */ NULL); if (!dd) { error_msg(_("Can't open directory for writing '%s'"), problem_info_get_dir(pi)); return false; } problem_info_set_dir(pi, dd->dd_dirname); pi->is_writable = true; dd_close(dd); return true; }
int _cmd_report(const char **dirs_strv, int flags) { int ret = 0; while (*dirs_strv) { const char *dir_name = *dirs_strv++; char *const real_problem_id = hash2dirname_if_necessary(dir_name); if (real_problem_id == NULL) { error_msg(_("Can't find problem '%s'"), dir_name); ++ret; continue; } const int not_reportable = test_exist_over_dbus(real_problem_id, FILENAME_NOT_REPORTABLE); if (not_reportable != 0) { if (!(flags & CMD_REPORT_UNSAFE)) { if (g_verbose > 0) { char *reason = load_text_over_dbus(real_problem_id, FILENAME_NOT_REPORTABLE); if (reason != NULL) log("%s\n", reason); free(reason); } error_msg(_("Problem '%s' cannot be reported"), real_problem_id); free(real_problem_id); ++ret; continue; } log_info(_("Problem '%s' is labeled as 'not-reportable'?"), real_problem_id); } const int res = chown_dir_over_dbus(real_problem_id); if (res != 0) { error_msg(_("Can't take ownership of '%s'"), real_problem_id); free(real_problem_id); ++ret; continue; } int lr_flags = LIBREPORT_WAIT | LIBREPORT_RUN_CLI; if (flags & CMD_REPORT_UNSAFE) lr_flags |= LIBREPORT_IGNORE_NOT_REPORTABLE; int status = report_problem_in_dir(real_problem_id, lr_flags); /* the problem was successfully reported and option is -d */ if((flags & CMD_REPORT_REMOVE) && (status == 0 || status == EXIT_STOP_EVENT_RUN)) { log(_("Deleting '%s'"), real_problem_id); delete_dump_dir_possibly_using_abrtd(real_problem_id); } free(real_problem_id); if (status) exit(status); } return ret; }