|
|
47a88a |
From 5f765f63193a0f13af2b7c31b466f0f207e0b4e0 Mon Sep 17 00:00:00 2001
|
|
|
47a88a |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
47a88a |
Date: Mon, 16 Mar 2015 08:58:58 +0100
|
|
|
47a88a |
Subject: [PATCH] dbus: add a new method GetProblemData
|
|
|
47a88a |
|
|
|
47a88a |
The method returns serialized problem_data_t for a given problem id.
|
|
|
47a88a |
|
|
|
47a88a |
The method is needed by cockpit-abrt which is supposed to have a page
|
|
|
47a88a |
showing comprehensive problem details.
|
|
|
47a88a |
|
|
|
47a88a |
Related: #1224984
|
|
|
47a88a |
|
|
|
47a88a |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
47a88a |
---
|
|
|
47a88a |
src/dbus/abrt-dbus.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
47a88a |
1 file changed, 70 insertions(+), 2 deletions(-)
|
|
|
47a88a |
|
|
|
47a88a |
diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c
|
|
|
47a88a |
index f2f742b..335c234 100644
|
|
|
47a88a |
--- a/src/dbus/abrt-dbus.c
|
|
|
47a88a |
+++ b/src/dbus/abrt-dbus.c
|
|
|
47a88a |
@@ -49,6 +49,10 @@ static const gchar introspection_xml[] =
|
|
|
47a88a |
" <arg type='s' name='problem_dir' direction='in'/>"
|
|
|
47a88a |
" <arg type='s' name='name' direction='in'/>"
|
|
|
47a88a |
" </method>"
|
|
|
47a88a |
+ " <method name='GetProblemData'>"
|
|
|
47a88a |
+ " <arg type='s' name='problem_dir' direction='in'/>"
|
|
|
47a88a |
+ " <arg type='a{s(its)}' name='problem_data' direction='out'/>"
|
|
|
47a88a |
+ " </method>"
|
|
|
47a88a |
" <method name='ChownProblemDir'>"
|
|
|
47a88a |
" <arg type='s' name='problem_dir' direction='in'/>"
|
|
|
47a88a |
" </method>"
|
|
|
47a88a |
@@ -599,6 +603,68 @@ static void handle_method_call(GDBusConnection *connection,
|
|
|
47a88a |
return;
|
|
|
47a88a |
}
|
|
|
47a88a |
|
|
|
47a88a |
+ if (g_strcmp0(method_name, "GetProblemData") == 0)
|
|
|
47a88a |
+ {
|
|
|
47a88a |
+ /* Parameter tuple is (s) */
|
|
|
47a88a |
+ const char *problem_id;
|
|
|
47a88a |
+
|
|
|
47a88a |
+ g_variant_get(parameters, "(&s)", &problem_id);
|
|
|
47a88a |
+
|
|
|
47a88a |
+ int ddstat = dump_dir_stat_for_uid(problem_id, caller_uid);
|
|
|
47a88a |
+ if ((ddstat & DD_STAT_ACCESSIBLE_BY_UID) == 0 &&
|
|
|
47a88a |
+ polkit_check_authorization_dname(caller, "org.freedesktop.problems.getall") != PolkitYes)
|
|
|
47a88a |
+ {
|
|
|
47a88a |
+ log_notice("Unauthorized access : '%s'", problem_id);
|
|
|
47a88a |
+ g_dbus_method_invocation_return_dbus_error(invocation,
|
|
|
47a88a |
+ "org.freedesktop.problems.AuthFailure",
|
|
|
47a88a |
+ _("Not Authorized"));
|
|
|
47a88a |
+ return;
|
|
|
47a88a |
+ }
|
|
|
47a88a |
+
|
|
|
47a88a |
+ struct dump_dir *dd = dd_opendir(problem_id, DD_OPEN_READONLY);
|
|
|
47a88a |
+ if (dd == NULL)
|
|
|
47a88a |
+ {
|
|
|
47a88a |
+ log_notice("Can't access the problem '%s' for reading", problem_id);
|
|
|
47a88a |
+ g_dbus_method_invocation_return_dbus_error(invocation,
|
|
|
47a88a |
+ "org.freedesktop.problems.Failure",
|
|
|
47a88a |
+ _("Can't access the problem for reading"));
|
|
|
47a88a |
+ return;
|
|
|
47a88a |
+ }
|
|
|
47a88a |
+
|
|
|
47a88a |
+ problem_data_t *pd = create_problem_data_from_dump_dir(dd);
|
|
|
47a88a |
+ dd_close(dd);
|
|
|
47a88a |
+
|
|
|
47a88a |
+ GVariantBuilder *response_builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
|
|
|
47a88a |
+
|
|
|
47a88a |
+ GHashTableIter pd_iter;
|
|
|
47a88a |
+ char *element_name;
|
|
|
47a88a |
+ struct problem_item *element_info;
|
|
|
47a88a |
+ g_hash_table_iter_init(&pd_iter, pd);
|
|
|
47a88a |
+ while (g_hash_table_iter_next(&pd_iter, (void**)&element_name, (void**)&element_info))
|
|
|
47a88a |
+ {
|
|
|
47a88a |
+ unsigned long size = 0;
|
|
|
47a88a |
+ if (problem_item_get_size(element_info, &size) != 0)
|
|
|
47a88a |
+ {
|
|
|
47a88a |
+ log_notice("Can't get stat of : '%s'", element_info->content);
|
|
|
47a88a |
+ continue;
|
|
|
47a88a |
+ }
|
|
|
47a88a |
+
|
|
|
47a88a |
+ g_variant_builder_add(response_builder, "{s(its)}",
|
|
|
47a88a |
+ element_name,
|
|
|
47a88a |
+ element_info->flags,
|
|
|
47a88a |
+ size,
|
|
|
47a88a |
+ element_info->content);
|
|
|
47a88a |
+ }
|
|
|
47a88a |
+
|
|
|
47a88a |
+ GVariant *response = g_variant_new("(a{s(its)})", response_builder);
|
|
|
47a88a |
+ g_variant_builder_unref(response_builder);
|
|
|
47a88a |
+
|
|
|
47a88a |
+ problem_data_free(pd);
|
|
|
47a88a |
+
|
|
|
47a88a |
+ g_dbus_method_invocation_return_value(invocation, response);
|
|
|
47a88a |
+ return;
|
|
|
47a88a |
+ }
|
|
|
47a88a |
+
|
|
|
47a88a |
if (g_strcmp0(method_name, "SetElement") == 0)
|
|
|
47a88a |
{
|
|
|
47a88a |
const char *problem_id;
|
|
|
47a88a |
@@ -923,8 +989,10 @@ int main(int argc, char *argv[])
|
|
|
47a88a |
* the introspection data structures - so we just build
|
|
|
47a88a |
* them from XML.
|
|
|
47a88a |
*/
|
|
|
47a88a |
- introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
|
|
|
47a88a |
- g_assert(introspection_data != NULL);
|
|
|
47a88a |
+ GError *err = NULL;
|
|
|
47a88a |
+ introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, &err;;
|
|
|
47a88a |
+ if (err != NULL)
|
|
|
47a88a |
+ error_msg_and_die("Invalid D-Bus interface: %s", err->message);
|
|
|
47a88a |
|
|
|
47a88a |
owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
|
|
|
47a88a |
ABRT_DBUS_NAME,
|
|
|
47a88a |
--
|
|
|
47a88a |
2.4.3
|
|
|
47a88a |
|