Exemplo n.º 1
0
int delete_problem_dirs_over_dbus(const GList *problem_dir_paths)
{
    INITIALIZE_LIBABRT();

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return 1;

    GVariant *parameters = variant_from_string_list(problem_dir_paths);

    GError *error = NULL;
    g_dbus_proxy_call_sync(proxy,
                    "DeleteProblem",
                    parameters,
                    G_DBUS_CALL_FLAGS_NONE,
                    -1,
                    NULL,
                    &error);
//g_variant_unref(parameters); -- need this??? no?? why?

    if (error)
    {
        error_msg(_("Deleting problem directory failed: %s"), error->message);
        g_error_free(error);
        return 1;
    }
    return 0;
}
Exemplo n.º 2
0
int test_exist_over_dbus(const char *problem_id, const char *element_name)
{
    INITIALIZE_LIBABRT();

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return -1;

    GError *error = NULL;
    GVariant *result = g_dbus_proxy_call_sync(proxy,
                                            "TestElementExists",
                                            g_variant_new("(ss)", problem_id, element_name),
                                            G_DBUS_CALL_FLAGS_NONE,
                                            -1,
                                            NULL,
                                            &error);

    if (error)
    {
        error_msg(_("Can't test whether the element exists over abrt-dbus: %s"), error->message);
        g_error_free(error);
        return -1;
    }

    gboolean retval;
    g_variant_get(result, "(b)", &retval);
    g_variant_unref(result);

    return retval;
}
Exemplo n.º 3
0
int chown_dir_over_dbus(const char *problem_dir_path)
{
    INITIALIZE_LIBABRT();

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return 1;

    GError *error = NULL;
    g_dbus_proxy_call_sync(proxy,
                        "ChownProblemDir",
                        g_variant_new("(s)", problem_dir_path),
                        G_DBUS_CALL_FLAGS_NONE,
                        -1,
                        NULL,
                        &error);

    if (error)
    {
        error_msg(_("Can't chown '%s': %s"), problem_dir_path, error->message);
        g_error_free(error);
        return 1;
    }
    return 0;
}
Exemplo n.º 4
0
int moonshot_get_identity (const char     *nai,
                           const char     *password,
                           const char     *service,
                           char          **nai_out,
                           char          **password_out,
                           char          **server_certificate_hash_out,
                           char          **ca_certificate_out,
                           char          **subject_name_constraint_out,
                           char          **subject_alt_name_constraint_out,
                           MoonshotError **error)
{
    GError     *g_error = NULL;
    DBusGProxy *dbus_proxy;
    int         success;

    dbus_proxy = get_dbus_proxy (error);

    if (*error != NULL)
        return FALSE;

    g_return_val_if_fail (DBUS_IS_G_PROXY (dbus_proxy), FALSE);

    dbus_g_proxy_call_with_timeout (dbus_proxy,
                       "GetIdentity",
				    INFINITE_TIMEOUT,
				    &g_error,
                       G_TYPE_STRING, nai,
                       G_TYPE_STRING, password,
                       G_TYPE_STRING, service,
                       G_TYPE_INVALID,
                       G_TYPE_STRING, nai_out,
                       G_TYPE_STRING, password_out,
                       G_TYPE_STRING, server_certificate_hash_out,
                       G_TYPE_STRING, ca_certificate_out,
                       G_TYPE_STRING, subject_name_constraint_out,
                       G_TYPE_STRING, subject_alt_name_constraint_out,
                       G_TYPE_BOOLEAN, &success,
                       G_TYPE_INVALID);

    g_object_unref (dbus_proxy);

    if (g_error != NULL) {
        *error = moonshot_error_new (MOONSHOT_ERROR_IPC_ERROR,
                                     g_error->message);
        return FALSE;
    }

    if (success == FALSE) {
        *error = moonshot_error_new (MOONSHOT_ERROR_NO_IDENTITY_SELECTED,
                                     "No identity was returned by the Moonshot "
                                     "user interface.");
        return FALSE;
    }

    return TRUE;
}
Exemplo n.º 5
0
problem_data_t *get_problem_data_dbus(const char *problem_dir_path)
{
    INITIALIZE_LIBABRT();

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return NULL;

    GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
    g_variant_builder_add(builder, "s", FILENAME_TIME          );
    g_variant_builder_add(builder, "s", FILENAME_REASON        );
    g_variant_builder_add(builder, "s", FILENAME_NOT_REPORTABLE);
    g_variant_builder_add(builder, "s", FILENAME_COMPONENT     );
    g_variant_builder_add(builder, "s", FILENAME_EXECUTABLE    );
    g_variant_builder_add(builder, "s", FILENAME_REPORTED_TO   );
    GVariant *params = g_variant_new("(sas)", problem_dir_path, builder);
    g_variant_builder_unref(builder);

    GError *error = NULL;
    GVariant *result = g_dbus_proxy_call_sync(proxy,
                                            "GetInfo",
                                            params,
                                            G_DBUS_CALL_FLAGS_NONE,
                                            -1,
                                            NULL,
                                            &error);

    if (error)
    {
        error_msg(_("Can't get problem data from abrt-dbus: %s"), error->message);
        g_error_free(error);
        return NULL;
    }

    problem_data_t *pd = problem_data_new();
    char *key, *val;
    GVariantIter *iter;
    g_variant_get(result, "(a{ss})", &iter);
    while (g_variant_iter_loop(iter, "{ss}", &key, &val))
    {
        problem_data_add_text_noteditable(pd, key, val);
    }
    g_variant_unref(result);
    return pd;
}
Exemplo n.º 6
0
char *load_text_over_dbus(const char *problem_id, const char *element_name)
{
    INITIALIZE_LIBABRT();

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return ERR_PTR;

    GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
    g_variant_builder_add(builder, "s", element_name);
    GVariant *params = g_variant_new("(sas)", problem_id, builder);
    g_variant_builder_unref(builder);

    GError *error = NULL;
    GVariant *result = g_dbus_proxy_call_sync(proxy,
                                            "GetInfo",
                                            params,
                                            G_DBUS_CALL_FLAGS_NONE,
                                            -1,
                                            NULL,
                                            &error);

    if (error)
    {
        error_msg(_("Can't get problem data from abrt-dbus: %s"), error->message);
        g_error_free(error);
        return ERR_PTR;
    }

    GVariant *values = g_variant_get_child_value(result, 0);
    g_variant_unref(result);

    char *retval = NULL;
    if (g_variant_n_children(values) == 1)
    {
        GVariant *contents = g_variant_get_child_value(values, 0);
        gchar *key;
        g_variant_get(contents, "{&ss}", &key, &retval);
    }

    g_variant_unref(values);
    return retval;
}
Exemplo n.º 7
0
problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path)
{
    INITIALIZE_LIBABRT();

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return ERR_PTR;

    GError *error = NULL;
    GVariant *result = g_dbus_proxy_call_sync(proxy,
                                    "GetProblemData",
                                    g_variant_new("(s)", problem_dir_path),
                                    G_DBUS_CALL_FLAGS_NONE,
                                    -1,
                                    NULL,
                                    &error);

    if (error)
    {
        error_msg(_("Can't get problem data from abrt-dbus: %s"), error->message);
        g_error_free(error);
        return ERR_PTR;
    }

    GVariantIter *iter = NULL;
    g_variant_get(result, "(a{s(its)})", &iter);

    gchar *name = NULL;
    gint flags;
    gulong size;
    gchar *value = NULL;

    problem_data_t *pd = problem_data_new();
    while (g_variant_iter_loop(iter, "{&s(it&s)}", &name, &flags, &size, &value))
        problem_data_add_ext(pd, name, value, flags, size);

    problem_data_add(pd, CD_DUMPDIR, problem_dir_path,
            CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE + CD_FLAG_LIST);

    g_variant_unref(result);

    return pd;
}
Exemplo n.º 8
0
int fill_problem_data_over_dbus(const char *problem_id, const char **elements, problem_data_t *problem_data)
{
    INITIALIZE_LIBABRT();

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return -1;

    GVariantBuilder *args_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));

    for (const char **iter = elements; *iter; ++iter)
        g_variant_builder_add(args_builder, "s", *iter);

    GVariant *params = g_variant_new("(sas)", problem_id, args_builder);
    g_variant_builder_unref(args_builder);

    GError *error = NULL;
    GVariant *result = g_dbus_proxy_call_sync(proxy,
                                            "GetInfo",
                                            params,
                                            G_DBUS_CALL_FLAGS_NONE,
                                            -1,
                                            NULL,
                                            &error);

    if (error)
    {
        error_msg(_("D-Bus GetInfo method call failed: %s"), error->message);
        g_error_free(error);
        return -2;
    }


    char *key, *val;
    GVariantIter *iter;
    g_variant_get(result, "(a{ss})", &iter);
    while (g_variant_iter_loop(iter, "{ss}", &key, &val))
        problem_data_add_text_noteditable(problem_data, key, val);

    g_variant_unref(result);

    return 0;
}
Exemplo n.º 9
0
GList *get_problems_over_dbus(bool authorize)
{
    INITIALIZE_LIBABRT();

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return ERR_PTR;

    GError *error = NULL;
    GVariant *result = g_dbus_proxy_call_sync(proxy,
                                    authorize ? "GetAllProblems" : "GetProblems",
                                    g_variant_new("()"),
                                    G_DBUS_CALL_FLAGS_NONE,
                                    -1,
                                    NULL,
                                    &error);

    if (error)
    {
        error_msg(_("Can't get problem list from abrt-dbus: %s"), error->message);
        g_error_free(error);
        return ERR_PTR;
    }

    GList *list = NULL;
    if (result)
    {
        /* Fetch "as" from "(as)" */
        GVariant *array = g_variant_get_child_value(result, 0);
        list = string_list_from_variant(array);
        g_variant_unref(array);
        g_variant_unref(result);
    }

    return list;
}
Exemplo n.º 10
0
static gboolean
process_mail (int argc, char *argv[])
{
    GIOChannel *io = NULL;
    GIOStatus status;
    gchar *line = NULL;
    gsize length;
    int i;
    DBusGProxy *proxy = NULL;
    GString *body = NULL;
    gboolean next_password = FALSE;

    proxy = get_dbus_proxy();
    /*
    if (!proxy)
        return FALSE;
    */

    if (proxy && !org_MilterZipcrypt_Sendmail_from(proxy, from, NULL))
        goto fail;

    if (proxy) {
        for (i = 1; i < argc; i++) {
            if (!org_MilterZipcrypt_Sendmail_recipient(proxy, argv[i], NULL))
                goto fail;
        }
    }

    io = g_io_channel_unix_new(STDIN_FILENO);
    g_io_channel_set_line_term(io, "\r\n", 2);
    body = g_string_new(NULL);

    do {
        status = g_io_channel_read_line(io, &line, &length, NULL, NULL);
        if (line) {
            if (next_password) {
                gchar *password;
                password = line;
                if (password && proxy && !org_MilterZipcrypt_Sendmail_password(proxy, password, NULL))
                    goto fail;
                next_password = FALSE;
            }
            if (g_str_equal(line, ".\r\n"))
                break;
            if (g_str_has_prefix(line, "The password of "))
                next_password = TRUE;
            g_string_append(body, line);
        }
    } while (status == G_IO_STATUS_NORMAL || status == G_IO_STATUS_AGAIN);

    g_io_channel_unref(io);
    io = NULL;

    if (proxy && !org_MilterZipcrypt_Sendmail_body(proxy, body->str, NULL))
        goto fail;

    g_string_free(body, TRUE);
    body = NULL;

    return (status == G_IO_STATUS_NORMAL) ? TRUE : FALSE;

fail:
    g_object_unref(proxy);
    if (body)
        g_string_free(body, TRUE);
    if (io)
        g_io_channel_unref(io);

    return FALSE;
}
Exemplo n.º 11
0
int moonshot_install_id_card (const char     *display_name,
                              const char     *user_name,
                              const char     *password,
                              const char     *realm,
                              char           *rules_patterns[],
                              int             rules_patterns_length,
                              char           *rules_always_confirm[],
                              int             rules_always_confirm_length,
                              char           *services[],
                              int             services_length,
                              const char     *ca_cert,
                              const char     *subject,
                              const char     *subject_alt,
                              const char     *server_cert,
                              int            force_flat_file_store,
                              MoonshotError **error)
{
    GError      *g_error = NULL;
    DBusGProxy  *dbus_proxy;
    int          success = FALSE;
    int          i;
    const char **rules_patterns_strv,
               **rules_always_confirm_strv,
               **services_strv;

    dbus_proxy = get_dbus_proxy (error);

    if (*error != NULL)
        return FALSE;

    g_return_val_if_fail (DBUS_IS_G_PROXY (dbus_proxy), FALSE);
    g_return_val_if_fail (rules_patterns_length == rules_always_confirm_length, FALSE);

    /* Marshall array and struct parameters for DBus */
    rules_patterns_strv = g_malloc ((rules_patterns_length + 1) * sizeof (const char *));
    rules_always_confirm_strv = g_malloc ((rules_patterns_length + 1) * sizeof (const char *));
    services_strv = g_malloc ((services_length + 1) * sizeof (const char *));

    for (i = 0; i < rules_patterns_length; i ++) {
        rules_patterns_strv[i] = rules_patterns[i];
        rules_always_confirm_strv[i] = rules_always_confirm[i];
    }

    for (i = 0; i < services_length; i ++)
        services_strv[i] = services[i];

    rules_patterns_strv[rules_patterns_length] = NULL;
    rules_always_confirm_strv[rules_patterns_length] = NULL;
    services_strv[services_length] = NULL;

    dbus_g_proxy_call (dbus_proxy,
                       "InstallIdCard",
                       &g_error,
                       G_TYPE_STRING, display_name,
                       G_TYPE_STRING, user_name,
                       G_TYPE_STRING, password,
                       G_TYPE_STRING, realm,
                       G_TYPE_STRV, rules_patterns_strv,
                       G_TYPE_STRV, rules_always_confirm_strv,
                       G_TYPE_STRV, services_strv,
                       G_TYPE_STRING, ca_cert,
                       G_TYPE_STRING, subject,
                       G_TYPE_STRING, subject_alt,
                       G_TYPE_STRING, server_cert,
                       G_TYPE_INT, force_flat_file_store,
                       G_TYPE_INVALID,
                       G_TYPE_BOOLEAN, &success,
                       G_TYPE_INVALID);

    g_object_unref (dbus_proxy);
    g_free(rules_patterns_strv);
    g_free(rules_always_confirm_strv);
    g_free(services_strv);

    if (g_error != NULL) {
        *error = moonshot_error_new (MOONSHOT_ERROR_IPC_ERROR,
                                     g_error->message);
        return FALSE;
    }

    return success;
}