예제 #1
0
파일: status.c 프로젝트: abrt/abrt
static unsigned int count_problem_dirs(unsigned long since)
{
    unsigned count = 0;

    GList *problems = get_problems_over_dbus(g_cli_authenticate);
    if (problems == ERR_PTR)
        return count;

    for (GList *iter = problems; iter != NULL; iter = g_list_next(iter))
    {
        const char *problem_id = (const char *)iter->data;
        if (test_exist_over_dbus(problem_id, FILENAME_REPORTED_TO))
        {
            log_debug("Not counting problem %s: already reported", problem_id);
            continue;
        }

        char *time_str = load_text_over_dbus(problem_id, FILENAME_LAST_OCCURRENCE);
        if (time_str == ERR_PTR || time_str == NULL)
        {
            log_debug("Not counting problem %s: failed to get time element", problem_id);
            continue;
        }

        long val = atol(time_str);
        free(time_str);
        if (val < since)
        {
            log_debug("Not counting problem %s: older tham limit (%ld < %ld)", problem_id, val, since);
            continue;
        }

        count++;
    }

    return count;
}
예제 #2
0
int dbus_problem_is_complete(const char *problem_id)
{
    return test_exist_over_dbus(problem_id, FILENAME_COUNT);
}
예제 #3
0
파일: report.c 프로젝트: xsulca00/abrt
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;
}