コード例 #1
0
ファイル: report.c プロジェクト: fengye0316/libreport
int report_problem_in_memory(problem_data_t *pd, int flags)
{
    int result = 0;
    struct dump_dir *dd = create_dump_dir_from_problem_data(pd, "/tmp"/* /var/tmp ?? */);
    if (!dd)
        return -1;
    char *dir_name = xstrdup(dd->dd_dirname);
    dd_close(dd);
    VERB2 log("Temp problem dir: '%s'", dir_name);

    if (!(flags & LIBREPORT_WAIT))
        flags |= LIBREPORT_DEL_DIR;
    result = report_problem_in_dir(dir_name, flags);

    /* If we waited for reporter to finish, we should clean up the tmp dir
     * (if we didn't, cleaning up will be done by reporting child process later).
     * We can also reload the problem data if requested.
     */
    if (flags & LIBREPORT_WAIT)
    {
        if (flags & LIBREPORT_RELOAD_DATA)
            g_hash_table_remove_all(pd);
        dd = dd_opendir(dir_name, 0);
        if (dd)
        {
            if (flags & LIBREPORT_RELOAD_DATA)
                problem_data_load_from_dump_dir(pd, dd, NULL);
            dd_delete(dd);
        }
    }

    free(dir_name);
    return result;
}
コード例 #2
0
ファイル: report.c プロジェクト: abrt/libreport
/* C: int report_problem_in_dir(const char *dirname, int flags); */
PyObject *p_report_problem_in_dir(PyObject *pself, PyObject *args)
{
    const char *dirname;
    int flags;
    if (!PyArg_ParseTuple(args, "si", &dirname, &flags))
    {
        return NULL;
    }
    int r = report_problem_in_dir(dirname, flags);
    return Py_BuildValue("i", r);
}
コード例 #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;
}