summaryrefslogtreecommitdiffstats
path: root/libreport/src
diff options
context:
space:
mode:
Diffstat (limited to 'libreport/src')
-rw-r--r--libreport/src/Makefile.am1
-rw-r--r--libreport/src/gtk-helpers/Makefile.am34
-rw-r--r--libreport/src/gtk-helpers/abrt-keyring.c166
-rw-r--r--libreport/src/gtk-helpers/autowrapped_label.c107
-rw-r--r--libreport/src/gtk-helpers/event_config_dialog.c454
-rw-r--r--libreport/src/gtk-helpers/libreport-gtk.h31
-rw-r--r--libreport/src/gtk-helpers/libreport-gtk.pc.in11
-rw-r--r--libreport/src/gui-wizard-gtk/Makefile.am61
-rw-r--r--libreport/src/gui-wizard-gtk/main.c152
-rw-r--r--libreport/src/gui-wizard-gtk/wizard.c1782
-rw-r--r--libreport/src/gui-wizard-gtk/wizard.glade801
-rw-r--r--libreport/src/gui-wizard-gtk/wizard.h33
-rw-r--r--libreport/src/include/Makefile.am17
-rw-r--r--libreport/src/include/abrt_dbus.h360
-rw-r--r--libreport/src/include/dump_dir.h80
-rw-r--r--libreport/src/include/event_config.h108
-rw-r--r--libreport/src/include/hash_sha1.h59
-rw-r--r--libreport/src/include/libreport.h307
-rw-r--r--libreport/src/include/libreport_problem_data.h99
-rw-r--r--libreport/src/include/libreport_types.h45
-rw-r--r--libreport/src/include/logging.h91
-rw-r--r--libreport/src/include/parse_options.h80
-rw-r--r--libreport/src/include/problem_data.h105
-rw-r--r--libreport/src/include/read_write.h55
-rw-r--r--libreport/src/include/report.h42
-rw-r--r--libreport/src/include/run_event.h82
-rw-r--r--libreport/src/include/strbuf.h112
-rw-r--r--libreport/src/include/xfuncs.h144
-rw-r--r--libreport/src/lib/Makefile.am94
-rw-r--r--libreport/src/lib/abrt_dbus.c623
-rw-r--r--libreport/src/lib/abrt_types.c37
-rw-r--r--libreport/src/lib/append_to_malloced_string.c27
-rw-r--r--libreport/src/lib/binhex.c76
-rw-r--r--libreport/src/lib/concat_path_file.c37
-rw-r--r--libreport/src/lib/copy_file_recursive.c149
-rw-r--r--libreport/src/lib/copyfd.c172
-rw-r--r--libreport/src/lib/create_dump_dir.c85
-rw-r--r--libreport/src/lib/daemon_is_ok.c51
-rw-r--r--libreport/src/lib/dirsize.c110
-rw-r--r--libreport/src/lib/dump_dir.c839
-rw-r--r--libreport/src/lib/encbase64.c93
-rw-r--r--libreport/src/lib/event_config.c366
-rw-r--r--libreport/src/lib/event_xml_parser.c469
-rw-r--r--libreport/src/lib/get_cmdline.c150
-rw-r--r--libreport/src/lib/glib_support.c27
-rw-r--r--libreport/src/lib/hash_sha1.c226
-rw-r--r--libreport/src/lib/is_in_string_list.c30
-rw-r--r--libreport/src/lib/iso_date_string.c31
-rw-r--r--libreport/src/lib/kernel-tainted.c143
-rw-r--r--libreport/src/lib/load_plugin_settings.c97
-rw-r--r--libreport/src/lib/logging.c148
-rw-r--r--libreport/src/lib/make_descr.c262
-rw-r--r--libreport/src/lib/overlapping_strcpy.c38
-rw-r--r--libreport/src/lib/parse_options.c251
-rw-r--r--libreport/src/lib/parse_release.c81
-rw-r--r--libreport/src/lib/problem_data.c424
-rw-r--r--libreport/src/lib/read_write.c120
-rw-r--r--libreport/src/lib/report.c129
-rw-r--r--libreport/src/lib/report_event.conf47
-rw-r--r--libreport/src/lib/run_event.c551
-rw-r--r--libreport/src/lib/skip_whitespace.c34
-rw-r--r--libreport/src/lib/spawn.c173
-rw-r--r--libreport/src/lib/stdio_helpers.c84
-rw-r--r--libreport/src/lib/steal_directory.c58
-rw-r--r--libreport/src/lib/strbuf.c170
-rw-r--r--libreport/src/lib/xatonum.c65
-rw-r--r--libreport/src/lib/xfuncs.c410
-rw-r--r--libreport/src/report-python/Makefile.am43
-rw-r--r--libreport/src/report-python/README44
-rw-r--r--libreport/src/report-python/__init__.py161
-rw-r--r--libreport/src/report-python/accountmanager.py21
-rw-r--r--libreport/src/report-python/common.h53
-rw-r--r--libreport/src/report-python/dump_dir.c264
-rw-r--r--libreport/src/report-python/io/GTKIO.py25
-rw-r--r--libreport/src/report-python/io/NewtIO.py21
-rw-r--r--libreport/src/report-python/io/TextIO.py20
-rw-r--r--libreport/src/report-python/io/__init__.py15
-rw-r--r--libreport/src/report-python/libreport-meh-test.py31
-rw-r--r--libreport/src/report-python/problem_data.c147
-rw-r--r--libreport/src/report-python/py_report_test.py7
-rw-r--r--libreport/src/report-python/pyreport.c22
-rw-r--r--libreport/src/report-python/report.c59
-rw-r--r--libreport/src/report-python/reportmodule.c95
-rw-r--r--libreport/src/report-python/run_event.c220
-rwxr-xr-xlibreport/src/report-python/test_dd_create25
-rwxr-xr-xlibreport/src/report-python/test_full27
-rwxr-xr-xlibreport/src/report-python/test_full217
-rw-r--r--libreport/src/report-python/test_problem_data21
-rw-r--r--libreport/src/report-python/test_problem_data210
-rwxr-xr-xlibreport/src/report-python/test_run_event_state13
-rwxr-xr-xlibreport/src/report-python/test_run_event_state127
-rwxr-xr-xlibreport/src/report-python/test_setroubleshoot_example18
-rwxr-xr-xlibreport/src/report-python/test_setroubleshoot_example227
93 files changed, 0 insertions, 13829 deletions
diff --git a/libreport/src/Makefile.am b/libreport/src/Makefile.am
deleted file mode 100644
index 9314b9ab..00000000
--- a/libreport/src/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = include lib report-python gtk-helpers gui-wizard-gtk
diff --git a/libreport/src/gtk-helpers/Makefile.am b/libreport/src/gtk-helpers/Makefile.am
deleted file mode 100644
index 38f9c1d0..00000000
--- a/libreport/src/gtk-helpers/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-# libreportgtk - the stuff shared among gtk clients (abrt-gui, wizard)
-libreport_gtk_includedir = \
- $(includedir)/libreport
-
-libreport_gtk_include_HEADERS = \
- libreport-gtk.h
-
-lib_LTLIBRARIES = \
- libreport-gtk.la
-
-libreport_gtk_la_SOURCES = \
- event_config_dialog.c \
- abrt-keyring.c \
- autowrapped_label.c
-
-libreport_gtk_la_CPPFLAGS = \
- -Wall -Wwrite-strings -Werror \
- -I$(srcdir)/../include \
- -I$(srcdir)/../lib \
- $(GTK_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GNOME_KEYRING_CFLAGS) \
- -D_GNU_SOURCE
-libreport_gtk_la_LDFLAGS = \
- -version-info 0:1:0
-libreport_gtk_la_LIBADD = \
- $(GTK_LIBS) \
- $(GLIB_LIBS) \
- $(GNOME_KEYRING_LIBS)
-
-EXTRA_DIST = libreport-gtk.pc.in
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libreport-gtk.pc
diff --git a/libreport/src/gtk-helpers/abrt-keyring.c b/libreport/src/gtk-helpers/abrt-keyring.c
deleted file mode 100644
index a6097a27..00000000
--- a/libreport/src/gtk-helpers/abrt-keyring.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <gnome-keyring.h>
-#include "libreport.h"
-
-static char *keyring_name;
-static bool got_keyring = 0;
-
-static guint32 search_item_id(const char *event_name)
-{
- GnomeKeyringAttributeList *attrs = gnome_keyring_attribute_list_new();
- GList *found = NULL;
- gnome_keyring_attribute_list_append_string(attrs, "libreportEventConfig", event_name);
- GnomeKeyringResult result = gnome_keyring_find_items_sync(
- GNOME_KEYRING_ITEM_GENERIC_SECRET,
- attrs,
- &found);
- gnome_keyring_attribute_list_free(attrs);
-
- //let's hope 0 is not valid item_id
- guint32 item_id = 0;
- if (result != GNOME_KEYRING_RESULT_OK)
- goto ret;
- if (found)
- item_id = ((GnomeKeyringFound *)found->data)->item_id;
- ret:
- if (found)
- gnome_keyring_found_list_free(found);
- VERB2 log("keyring has %sconfiguration for event '%s'", (item_id != 0) ? "" : "no ", event_name);
- return item_id;
-}
-
-void abrt_keyring_save_settings(const char *event_name)
-{
- GList *l;
- GnomeKeyringAttributeList *attrs = gnome_keyring_attribute_list_new();
- event_config_t *ec = get_event_config(event_name);
- /* add string id which we use to search for items */
- gnome_keyring_attribute_list_append_string(attrs, "libreportEventConfig", event_name);
- for (l = g_list_first(ec->options); l != NULL; l = g_list_next(l))
- {
- event_option_t *op = (event_option_t *)l->data;
- gnome_keyring_attribute_list_append_string(attrs, op->eo_name, op->eo_value);
- }
-
- GnomeKeyringResult result;
- guint32 item_id = search_item_id(event_name);
- if (item_id)
- {
- /* found existing item, so just update the values */
- result = gnome_keyring_item_set_attributes_sync(keyring_name, item_id, attrs);
- VERB2 log("updated item with id: %i", item_id);
- }
- else
- {
- /* did't find existing item, so create a new one */
- result = gnome_keyring_item_create_sync(keyring_name,
- GNOME_KEYRING_ITEM_GENERIC_SECRET, /* type */
- event_name, /* display name */
- attrs, /* attributes */
- NULL, /* secret - no special handling for password it's stored in attrs */
- 1, /* update if exist */
- &item_id);
- VERB2 log("created new item with id: %i", item_id);
- }
- gnome_keyring_attribute_list_free(attrs);
-
- if (result != GNOME_KEYRING_RESULT_OK)
- {
- error_msg("Error saving event '%s' configuration to keyring", event_name);
- return;
- }
- VERB2 log("saved event '%s' configuration to keyring", event_name);
-}
-
-static void abrt_keyring_load_settings(const char *event_name, event_config_t *ec)
-{
- guint item_id = search_item_id(event_name);
- if (!item_id)
- return;
- GnomeKeyringAttributeList *attrs = NULL;
- GnomeKeyringResult result = gnome_keyring_item_get_attributes_sync(
- keyring_name,
- item_id,
- &attrs);
- if (result == GNOME_KEYRING_RESULT_OK && attrs)
- {
- VERB3 log("num attrs %i", attrs->len);
- guint index;
- for (index = 0; index < attrs->len; index++)
- {
- char *name = g_array_index(attrs, GnomeKeyringAttribute, index).name;
- VERB2 log("keyring has name '%s'", name);
- event_option_t *option = get_event_option_from_list(name, ec->options);
- if (option)
- {
- free(option->eo_value);
- option->eo_value = xstrdup(g_array_index(attrs, GnomeKeyringAttribute, index).value.string);
- VERB2 log("added or replaced in event config:'%s=%s'", name, option->eo_value);
- }
- }
- }
- if (attrs)
- gnome_keyring_attribute_list_free(attrs);
-}
-
-static void init_keyring()
-{
- /* Called again? */
- if (got_keyring)
- return;
-
- if (!gnome_keyring_is_available())
- {
- error_msg("Cannot connect to Gnome keyring daemon");
- return;
- }
-
- GnomeKeyringResult result = gnome_keyring_get_default_keyring_sync(&keyring_name);
- if (result != GNOME_KEYRING_RESULT_OK)
- {
- error_msg("Can't get default keyring (result:%d)", result);
- return;
- }
-
- got_keyring = 1;
- /*
- * Note: The default keyring name can be NULL. It is a valid name.
- */
- VERB2 log("keyring:'%s'", keyring_name);
-}
-
-static void load_event_config(gpointer key, gpointer value, gpointer user_data)
-{
- char* event_name = (char*)key;
- event_config_t *ec = (event_config_t *)value;
- VERB2 log("loading event '%s' configuration from keyring", event_name);
- abrt_keyring_load_settings(event_name, ec);
-}
-
-/*
- * Tries to load settings for all events in g_event_config_list
-*/
-void load_event_config_data_from_keyring()
-{
- init_keyring();
- if (!got_keyring)
- return;
- g_hash_table_foreach(g_event_config_list, &load_event_config, NULL);
-}
diff --git a/libreport/src/gtk-helpers/autowrapped_label.c b/libreport/src/gtk-helpers/autowrapped_label.c
deleted file mode 100644
index 981cb709..00000000
--- a/libreport/src/gtk-helpers/autowrapped_label.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <gtk/gtk.h>
-#include "libreport.h"
-
-/*
- * GTK doesn't re-wrap GtkLabels which have line wrapping set to true.
- * The line wrapped label in VBox looks like this:
- * |----------------------------------------|
- * |----------------------------------------|
- * | word word word word |
- * | word word word word |
- * | word word |
- * |----------------------------------------|
- * |----------------------------------------|
- * So every project copy-pastes this code to make labels widen
- * and shrink horizontally on resize.
- */
-
-static void rewrap_label_to_parent_size(GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer data)
-{
- GtkLabel *label = GTK_LABEL(widget);
- PangoLayout *layout = gtk_label_get_layout(label);
-
- int lw_old, lh_old;
- pango_layout_get_pixel_size(layout, &lw_old, &lh_old);
-
- /* Already right size? */
- if (lw_old == allocation->width)
- return;
-
- /* Rewrap text to new width */
- pango_layout_set_width(layout, allocation->width * PANGO_SCALE);
-
- /* Did text height change as a result? */
- int lh;
- pango_layout_get_pixel_size(layout, NULL, &lh);
- if (lh != lh_old) /* yes, resize label height */
- gtk_widget_set_size_request(widget, -1, lh);
-}
-
-void make_label_autowrap_on_resize(GtkLabel *label)
-{
- // So far, only tested to work on labels which were set up as:
- //gtk_label_set_justify(label, GTK_JUSTIFY_LEFT);
- //gtk_misc_set_alignment(GTK_MISC(label), /*x,yalign:*/ 0.0, 0.0);
- // yalign != 0 definitely breaks things!
- // also, <property name="ypad">NONZERO</property> would be bad
-
- /* Makes no sense on non-wrapped labels, so we can as well
- * set wrapping to "on" unconditionally, istead of making it a requirement
- */
- gtk_label_set_line_wrap(label, TRUE);
- g_signal_connect(G_OBJECT(label), "size-allocate", G_CALLBACK(rewrap_label_to_parent_size), NULL);
-
- // So far, only tested to work on labels which were set up as:
- //gtk_box_pack_start(box, label, /*expand*/ false, /*fill*/ false, /*padding*/ 0);
-}
-
-static void fixer(GtkWidget *widget, gpointer data_unused)
-{
- if (GTK_IS_CONTAINER(widget))
- {
- gtk_container_foreach((GtkContainer*)widget, fixer, NULL);
- return;
- }
- if (GTK_IS_LABEL(widget))
- {
- GtkLabel *label = (GtkLabel*)widget;
- //const char *txt = gtk_label_get_label(label);
- GtkMisc *misc = (GtkMisc*)widget;
- gfloat yalign; //= 1;
- gint ypad; //= 1;
- if (gtk_label_get_line_wrap(label)
- && (gtk_misc_get_alignment(misc, NULL, &yalign), yalign == 0)
- && (gtk_misc_get_padding(misc, NULL, &ypad), ypad == 0)
- ) {
- //log("label '%s' set to wrap", txt);
- make_label_autowrap_on_resize(label);
- return;
- }
- //log("label '%s' not set to wrap %g %d", txt, yalign, ypad);
- }
-}
-
-void fix_all_wrapped_labels(GtkWidget *widget)
-{
- fixer(widget, NULL);
-}
diff --git a/libreport/src/gtk-helpers/event_config_dialog.c b/libreport/src/gtk-helpers/event_config_dialog.c
deleted file mode 100644
index e98b50b7..00000000
--- a/libreport/src/gtk-helpers/event_config_dialog.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <gtk/gtk.h>
-#include "libreport-gtk.h"
-
-static GtkWindow *g_event_list_window;
-static GList *option_widget_list;
-GtkWindow *g_parent_window;
-
-enum
-{
- COLUMN_EVENT_UINAME,
- COLUMN_EVENT_NAME,
- NUM_COLUMNS
-};
-
-typedef struct
-{
- event_option_t *option;
- GtkWidget *widget;
-} option_widget_t;
-
-static void show_event_config_dialog(const char *event_name);
-
-static GtkWidget *gtk_label_new_justify_left(const gchar *label_str)
-{
- GtkWidget *label = gtk_label_new(label_str);
- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment(GTK_MISC(label), /*xalign:*/ 0, /*yalign:*/ 0.5);
- /* Make some space between label and input field to the right of it: */
- gtk_misc_set_padding(GTK_MISC(label), /*xpad:*/ 5, /*ypad:*/ 0);
- return label;
-}
-
-static void add_option_widget(GtkWidget *widget, event_option_t *option)
-{
- option_widget_t *ow = (option_widget_t *)xmalloc(sizeof(option_widget_t));
- ow->widget = widget;
- ow->option = option;
- option_widget_list = g_list_prepend(option_widget_list, ow);
-}
-
-static void on_show_pass_cb(GtkToggleButton *tb, gpointer user_data)
-{
- GtkEntry *entry = (GtkEntry *)user_data;
- gtk_entry_set_visibility(entry, gtk_toggle_button_get_active(tb));
-}
-
-static unsigned grow_table_by_1(GtkTable *table)
-{
- guint rows, columns;
- //needs gtk 2.22: gtk_table_get_size(table, &rows, &columns);
- g_object_get(table, "n-rows", &rows, NULL);
- g_object_get(table, "n-columns", &columns, NULL);
- gtk_table_resize(table, rows + 1, columns);
- return rows;
-}
-
-static void add_option_to_table(gpointer data, gpointer user_data)
-{
- event_option_t *option = data;
- GtkTable *option_table = user_data;
-
- GtkWidget *label;
- GtkWidget *option_input;
- unsigned last_row;
-
- char *option_label;
- if (option->eo_label != NULL)
- option_label = xstrdup(option->eo_label);
- else
- {
- option_label = xstrdup(option->eo_name ? option->eo_name : "");
- /* Replace '_' with ' ' */
- char *p = option_label - 1;
- while (*++p)
- if (*p == '_')
- *p = ' ';
- }
-
- switch (option->eo_type)
- {
- case OPTION_TYPE_TEXT:
- case OPTION_TYPE_NUMBER:
- case OPTION_TYPE_PASSWORD:
- last_row = grow_table_by_1(option_table);
- label = gtk_label_new_justify_left(option_label);
- gtk_table_attach(option_table, label,
- /*left,right_attach:*/ 0, 1,
- /*top,bottom_attach:*/ last_row, last_row+1,
- /*x,yoptions:*/ GTK_FILL, GTK_FILL,
- /*x,ypadding:*/ 0, 0);
- option_input = gtk_entry_new();
- if (option->eo_value != NULL)
- gtk_entry_set_text(GTK_ENTRY(option_input), option->eo_value);
- gtk_table_attach(option_table, option_input,
- /*left,right_attach:*/ 1, 2,
- /*top,bottom_attach:*/ last_row, last_row+1,
- /*x,yoptions:*/ GTK_FILL | GTK_EXPAND, GTK_FILL,
- /*x,ypadding:*/ 0, 0);
- add_option_widget(option_input, option);
- if (option->eo_type == OPTION_TYPE_PASSWORD)
- {
- gtk_entry_set_visibility(GTK_ENTRY(option_input), 0);
- last_row = grow_table_by_1(option_table);
- GtkWidget *pass_cb = gtk_check_button_new_with_label(_("Show password"));
- gtk_table_attach(option_table, pass_cb,
- /*left,right_attach:*/ 1, 2,
- /*top,bottom_attach:*/ last_row, last_row+1,
- /*x,yoptions:*/ GTK_FILL, GTK_FILL,
- /*x,ypadding:*/ 0, 0);
- g_signal_connect(pass_cb, "toggled", G_CALLBACK(on_show_pass_cb), option_input);
- }
- break;
-
- case OPTION_TYPE_HINT_HTML:
- label = gtk_label_new(option_label);
- gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(label), /*x,yalign:*/ 0.0, 0.0);
- make_label_autowrap_on_resize(GTK_LABEL(label));
-
- last_row = grow_table_by_1(option_table);
- gtk_table_attach(option_table, label,
- /*left,right_attach:*/ 0, 2,
- /*top,bottom_attach:*/ last_row, last_row+1,
- /*x,yoptions:*/ GTK_FILL, GTK_FILL,
- /*x,ypadding:*/ 0, 0);
- break;
-
- case OPTION_TYPE_BOOL:
- last_row = grow_table_by_1(option_table);
- option_input = gtk_check_button_new_with_label(option_label);
- gtk_table_attach(option_table, option_input,
- /*left,right_attach:*/ 0, 2,
- /*top,bottom_attach:*/ last_row, last_row+1,
- /*x,yoptions:*/ GTK_FILL, GTK_FILL,
- /*x,ypadding:*/ 0, 0);
- if (option->eo_value != NULL)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(option_input),
- string_to_bool(option->eo_value));
- add_option_widget(option_input, option);
- break;
-
- default:
- //option_input = gtk_label_new_justify_left("WTF?");
- log("unsupported option type");
- free(option_label);
- return;
- }
-
- if (option->eo_note_html)
- {
- label = gtk_label_new(option->eo_note_html);
- gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(label), /*x,yalign:*/ 0.0, 0.0);
- make_label_autowrap_on_resize(GTK_LABEL(label));
-
- last_row = grow_table_by_1(option_table);
- gtk_table_attach(option_table, label,
- /*left,right_attach:*/ 1, 2,
- /*top,bottom_attach:*/ last_row, last_row+1,
- /*x,yoptions:*/ GTK_FILL, GTK_FILL,
- /*x,ypadding:*/ 0, 0);
- }
-
- free(option_label);
-}
-
-static void on_close_event_list_cb(GtkWidget *button, gpointer user_data)
-{
- GtkWidget *window = (GtkWidget *)user_data;
- gtk_widget_destroy(window);
-}
-
-static char *get_event_name_from_row(GtkTreeView *treeview)
-{
- GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
- char *event_name = NULL;
- if (selection)
- {
- GtkTreeIter iter;
- GtkTreeModel *store = gtk_tree_view_get_model(treeview);
- if (gtk_tree_selection_get_selected(selection, &store, &iter) == TRUE)
- {
- GValue value = { 0 };
- gtk_tree_model_get_value(store, &iter, COLUMN_EVENT_NAME, &value);
- event_name = (char *)g_value_get_string(&value);
- }
- }
- return event_name;
-}
-
-static void on_configure_event_cb(GtkWidget *button, gpointer user_data)
-{
- GtkTreeView *events_tv = (GtkTreeView *)user_data;
- char *event_name = get_event_name_from_row(events_tv);
- if (event_name != NULL)
- show_event_config_dialog(event_name);
- //else
- // error_msg(_("Please select a plugin from the list to edit its options."));
-}
-
-static void on_event_row_activated_cb(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
-{
- char *event_name = get_event_name_from_row(treeview);
- event_config_t *ec = get_event_config(event_name);
- if (ec->options != NULL) //We need to have some options to show
- show_event_config_dialog(event_name);
-}
-
-static void on_event_row_changed_cb(GtkTreeView *treeview, gpointer user_data)
-{
- event_config_t *ec = get_event_config(get_event_name_from_row(treeview));
- gtk_widget_set_sensitive(GTK_WIDGET(user_data), ec->options != NULL);
-}
-
-static void add_event_to_liststore(gpointer key, gpointer value, gpointer user_data)
-{
- GtkListStore *events_list_store = (GtkListStore *)user_data;
- event_config_t *ec = (event_config_t *)value;
-
- char *event_label;
- if (ec->screen_name != NULL && ec->description != NULL)
- event_label = xasprintf("<b>%s</b>\n%s", ec->screen_name, ec->description);
- else
- //if event has no xml description
- event_label = xasprintf("<b>%s</b>\nNo description available", key);
-
- GtkTreeIter iter;
- gtk_list_store_append(events_list_store, &iter);
- gtk_list_store_set(events_list_store, &iter,
- COLUMN_EVENT_UINAME, event_label,
- COLUMN_EVENT_NAME, key,
- -1);
- free(event_label);
-}
-
-static void save_value_from_widget(gpointer data, gpointer user_data)
-{
- option_widget_t *ow = (option_widget_t *)data;
-
- const char *val = NULL;
- switch (ow->option->eo_type)
- {
- case OPTION_TYPE_TEXT:
- case OPTION_TYPE_NUMBER:
- case OPTION_TYPE_PASSWORD:
- val = (char *)gtk_entry_get_text(GTK_ENTRY(ow->widget));
- break;
- case OPTION_TYPE_BOOL:
- val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ow->widget)) ? "yes" : "no";
- break;
- default:
- log("unsupported option type");
- }
- if (val)
- {
- free(ow->option->eo_value);
- ow->option->eo_value = xstrdup(val);
- VERB1 log("saved: %s:%s", ow->option->eo_name, ow->option->eo_value);
- }
-}
-
-static void dehydrate_config_dialog()
-{
- if (option_widget_list != NULL)
- g_list_foreach(option_widget_list, &save_value_from_widget, NULL);
-}
-
-static void show_event_config_dialog(const char *event_name)
-{
- if (option_widget_list != NULL)
- {
- g_list_free(option_widget_list);
- option_widget_list = NULL;
- }
-
- event_config_t *event = get_event_config(event_name);
-
- GtkWidget *dialog = gtk_dialog_new_with_buttons(
- /*title:*/ event->screen_name ? event->screen_name : event_name,
- g_event_list_window,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
- GTK_RESPONSE_APPLY,
- NULL);
- if (g_event_list_window != NULL)
- {
- gtk_window_set_icon_name(GTK_WINDOW(dialog),
- gtk_window_get_icon_name(g_event_list_window));
- }
-
- GtkWidget *option_table = gtk_table_new(/*rows*/ 0, /*cols*/ 2, /*homogeneous*/ FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(option_table), 2);
- g_list_foreach(event->options, &add_option_to_table, option_table);
-
- GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
- gtk_box_pack_start(GTK_BOX(content), option_table, false, false, 20);
- gtk_widget_show_all(option_table);
-
- int result = gtk_dialog_run(GTK_DIALOG(dialog));
- if (result == GTK_RESPONSE_APPLY)
- {
- dehydrate_config_dialog();
- abrt_keyring_save_settings(event_name);
- }
- //else if (result == GTK_RESPONSE_CANCEL)
- // log("log");
- gtk_widget_destroy(dialog);
-}
-
-void show_events_list_dialog(GtkWindow *parent)
-{
- /*remove this line if we want to reload the config
- *everytime we show the config dialog
- */
- if (g_event_config_list == NULL)
- {
- load_event_config_data();
- load_event_config_data_from_keyring();
- }
-
- GtkWidget *event_list_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- g_event_list_window = (GtkWindow*)event_list_window;
- gtk_window_set_title(g_event_list_window, _("Event Configuration"));
- gtk_window_set_default_size(g_event_list_window, 450, 400);
- gtk_window_set_position(g_event_list_window, parent ? GTK_WIN_POS_CENTER_ON_PARENT : GTK_WIN_POS_CENTER);
- if (parent != NULL)
- {
- gtk_window_set_transient_for(g_event_list_window, parent);
- // modal = parent window can't steal focus
- gtk_window_set_modal(g_event_list_window, true);
- gtk_window_set_icon_name(g_event_list_window,
- gtk_window_get_icon_name(parent));
- }
-
- GtkWidget *main_vbox = gtk_vbox_new(0, 0);
- GtkWidget *events_scroll = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(events_scroll),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- /* event list treeview */
- GtkWidget *events_tv = gtk_tree_view_new();
- /* column with event name and description */
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- /* add column to tree view */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Event"),
- renderer,
- "markup",
- COLUMN_EVENT_UINAME,
- NULL);
- gtk_tree_view_column_set_resizable(column, TRUE);
- g_object_set(G_OBJECT(renderer), "wrap-mode", PANGO_WRAP_WORD, NULL);
- g_object_set(G_OBJECT(renderer), "wrap-width", 440, NULL);
- gtk_tree_view_column_set_sort_column_id(column, COLUMN_EVENT_NAME);
- gtk_tree_view_append_column(GTK_TREE_VIEW(events_tv), column);
- /* "Please draw rows in alternating colors": */
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(events_tv), TRUE);
- // TODO: gtk_tree_view_set_headers_visible(FALSE)? We have only one column anyway...
-
- /* Create data store for the list and attach it
- * COLUMN_EVENT_UINAME -> name+description
- * COLUMN_EVENT_NAME -> event name so we can retrieve it from the row
- */
- GtkListStore *events_list_store = gtk_list_store_new(NUM_COLUMNS,
- G_TYPE_STRING, /* Event name + description */
- G_TYPE_STRING /* event name */
- );
- gtk_tree_view_set_model(GTK_TREE_VIEW(events_tv), GTK_TREE_MODEL(events_list_store));
-
- g_hash_table_foreach(g_event_config_list,
- &add_event_to_liststore,
- events_list_store);
-//TODO: can unref events_list_store? treeview holds one ref.
-
- /* Double click/Enter handler */
- g_signal_connect(events_tv, "row-activated", G_CALLBACK(on_event_row_activated_cb), NULL);
-
- gtk_container_add(GTK_CONTAINER(events_scroll), events_tv);
-
- GtkWidget *configure_event_btn = gtk_button_new_with_mnemonic(_("Configure E_vent"));
- gtk_widget_set_sensitive(configure_event_btn, false);
- g_signal_connect(configure_event_btn, "clicked", G_CALLBACK(on_configure_event_cb), events_tv);
- g_signal_connect(events_tv, "cursor-changed", G_CALLBACK(on_event_row_changed_cb), configure_event_btn);
-
- GtkWidget *close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
- g_signal_connect(close_btn, "clicked", G_CALLBACK(on_close_event_list_cb), g_event_list_window);
-
- GtkWidget *btnbox = gtk_hbutton_box_new();
- gtk_box_pack_end(GTK_BOX(btnbox), close_btn, false, false, 0);
- gtk_box_pack_end(GTK_BOX(btnbox), configure_event_btn, false, false, 0);
-
- gtk_box_pack_start(GTK_BOX(main_vbox), events_scroll, true, true, 10);
- gtk_box_pack_start(GTK_BOX(main_vbox), btnbox, false, false, 0);
-
- gtk_container_add(GTK_CONTAINER(event_list_window), main_vbox);
-
- gtk_widget_show_all(event_list_window);
-}
-
-static void show_event_opt_error_dialog(const char *event_name)
-{
- event_config_t *ec = get_event_config(event_name);
- char *message = xasprintf(_("Wrong settings detected for %s, "
- "reporting will probably fail if you continue "
- "with the current configuration."),
- ec->screen_name);
- char *markup_message = xasprintf(_("Wrong settings detected for <b>%s</b>, "
- "reporting will probably fail if you continue "
- "with the current configuration."),
- ec->screen_name);
- GtkWidget *wrong_settings = gtk_message_dialog_new(g_parent_window,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- message);
- gtk_window_set_transient_for(GTK_WINDOW(wrong_settings), g_parent_window);
- free(message);
- gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(wrong_settings),
- markup_message);
- free(markup_message);
- gtk_dialog_run(GTK_DIALOG(wrong_settings));
- gtk_widget_destroy(wrong_settings);
-}
-
-//TODO: move this code to its only callsite?
-// (in which case, move show_event_opt_error_dialog and g_parent_window too)
-void g_validate_event(const char* event_name)
-{
- GHashTable *errors = validate_event(event_name);
- if (errors != NULL)
- show_event_opt_error_dialog(event_name);
-}
diff --git a/libreport/src/gtk-helpers/libreport-gtk.h b/libreport/src/gtk-helpers/libreport-gtk.h
deleted file mode 100644
index 417f6053..00000000
--- a/libreport/src/gtk-helpers/libreport-gtk.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "libreport.h"
-#include "report.h"
-
-void make_label_autowrap_on_resize(GtkLabel *label);
-void fix_all_wrapped_labels(GtkWidget *widget);
-
-void show_events_list_dialog(GtkWindow *parent);
-
-void abrt_keyring_save_settings(const char *event_name);
-void load_event_config_data_from_keyring();
-void g_validate_event(const char* event_name);
-extern GtkWindow *g_parent_window;
diff --git a/libreport/src/gtk-helpers/libreport-gtk.pc.in b/libreport/src/gtk-helpers/libreport-gtk.pc.in
deleted file mode 100644
index 2d842977..00000000
--- a/libreport/src/gtk-helpers/libreport-gtk.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libreport-gtk
-Description: libreport bindings for GTK apps
-Version: @VERSION@
-Requires: libreport
-Libs: -L${libdir} -lreport-gtk
-Cflags: -fPIC -I${includedir}/libreport
diff --git a/libreport/src/gui-wizard-gtk/Makefile.am b/libreport/src/gui-wizard-gtk/Makefile.am
deleted file mode 100644
index de8497ba..00000000
--- a/libreport/src/gui-wizard-gtk/Makefile.am
+++ /dev/null
@@ -1,61 +0,0 @@
-# bug-reporting-wizard binary
-bin_PROGRAMS = bug-reporting-wizard
-
-bug_reporting_wizard_SOURCES = \
- wizard.h wizard.c \
- main.c \
- wizard_glade.c
-
-# Required for gtk_builder_connect_signals() to work correctly:
-# -g
-# -Wl,--export-dynamic
-bug_reporting_wizard_CFLAGS = \
- -I$(srcdir)/../include \
- -I$(srcdir)/../lib \
- -I$(srcdir)/../gtk-helpers \
- -DBIN_DIR=\"$(bindir)\" \
- -DVAR_RUN=\"$(VAR_RUN)\" \
- -DCONF_DIR=\"$(CONF_DIR)\" \
- -DDATA_DIR=\"$(datadir)\" \
- -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
- -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
- -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
- -DICON_DIR=\"${datadir}/abrt/icons/hicolor/48x48/status\" \
- $(GLIB_CFLAGS) \
- $(GTK_CFLAGS) \
- $(DBUS_CFLAGS) \
- -D_GNU_SOURCE \
- -Wall -Wwrite-strings -Werror
-
-# Required for gtk_builder_connect_signals() to work correctly:
-# -lgmodule-2.0
-# -lgthread-2.0
-bug_reporting_wizard_LDADD = \
- ../lib/libreport.la \
- ../lib/libabrt_dbus.la \
- ../gtk-helpers/libreport-gtk.la \
- $(GLIB_LIBS) \
- $(GTK_LIBS) \
- $(DBUS_LIBS)
-
-# we don't want to install it, just make it part of tarball
-# created by make dist
-GLADE_FILES = wizard.glade
-#pkgdata_DATA = $(GLADE_FILES)
-EXTRA_DIST = $(GLADE_FILES)
-
-
-# For internal glade file storage in the binary:
-wizard.c: wizard_glade.c
-
-wizard_glade.c: wizard.glade
- { \
- echo '#define WIZARD_GLADE_CONTENTS "\'; \
- cat $(srcdir)/wizard.glade | sed -e 's/"/\\"/g' -e 's/?/\\?/g' -e 's/$$/\\/g'; \
- echo '"'; \
- } >wizard_glade.c
-
-
-DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
-
-@INTLTOOL_DESKTOP_RULE@
diff --git a/libreport/src/gui-wizard-gtk/main.c b/libreport/src/gui-wizard-gtk/main.c
deleted file mode 100644
index 2dc88cbb..00000000
--- a/libreport/src/gui-wizard-gtk/main.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <gtk/gtk.h>
-#include "parse_options.h"
-#include "wizard.h"
-#if HAVE_LOCALE_H
-# include <locale.h>
-#endif
-
-char *g_glade_file = NULL;
-char *g_dump_dir_name = NULL;
-char *g_analyze_events = NULL;
-char *g_report_events = NULL;
-int g_report_only = false;
-problem_data_t *g_cd;
-
-
-void reload_problem_data_from_dump_dir(void)
-{
- free(g_analyze_events);
- free(g_report_events);
-
- struct dump_dir *dd = dd_opendir(g_dump_dir_name, DD_OPEN_READONLY);
- if (!dd)
- xfunc_die(); /* dd_opendir already logged error msg */
-
- problem_data_t *new_cd = create_problem_data_from_dump_dir(dd);
- add_to_problem_data_ext(new_cd, CD_DUMPDIR, g_dump_dir_name, (CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE));
-
- g_analyze_events = list_possible_events(dd, NULL, "analyze");
- g_report_events = list_possible_events(dd, NULL, "report");
- dd_close(dd);
-
- if (1)
- {
- /* Copy "selected for reporting" flags */
- GHashTableIter iter;
- char *name;
- struct problem_item *new_item;
- g_hash_table_iter_init(&iter, new_cd);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&new_item))
- {
- struct problem_item *old_item = g_cd ? get_problem_data_item_or_NULL(g_cd, name) : NULL;
- if (old_item)
- {
- new_item->selected_by_user = old_item->selected_by_user;
- }
- else
- {
- new_item->selected_by_user = 0;
- }
- //log("%s: was ->selected_by_user=%d", __func__, new_item->selected_by_user);
- }
- free_problem_data(g_cd);
- }
- g_cd = new_cd;
-
- /* Load /etc/abrt/events/foo.{conf,xml} stuff */
- load_event_config_data();
- load_event_config_data_from_keyring();
-//TODO: Load ~/.abrt/events/foo.conf?
-}
-
-int main(int argc, char **argv)
-{
- const char *prgname = "abrt";
- abrt_init(argv);
-
- /* I18n */
- setlocale(LC_ALL, "");
-#if ENABLE_NLS
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-#endif
-
- gtk_init(&argc, &argv);
-
- /* Can't keep these strings/structs static: _() doesn't support that */
- const char *program_usage_string = _(
- "\b [-vp] [-g GUI_FILE] [-o|--report-only] [-n|--prgname] DIR\n"
- "\n"
- "GUI tool to analyze and report problem saved in specified DIR"
- );
- enum {
- OPT_v = 1 << 0,
- OPT_g = 1 << 1,
- OPT_p = 1 << 2,
- OPT_o = 1 << 3, // report only
- OPT_n = 1 << 4, // prgname
- };
- /* Keep enum above and order of options below in sync! */
- struct options program_options[] = {
- OPT__VERBOSE(&g_verbose),
- OPT_STRING('g', NULL, &g_glade_file, "FILE" , _("Alternate GUI file")),
- OPT_BOOL( 'p', NULL, NULL , _("Add program names to log")),
- /* for use from 3rd party apps to show just a reporter selector */
- OPT_BOOL( 'o', "report-only", &g_report_only , _("Use wizard to report pre-filled problem data")),
- /* override the default prgname, so it's the same as the application
- which is calling us
- */
- OPT_STRING( 'n', "prgname", &prgname, "NAME" , _("Override the default prgname")),
- OPT_END()
- };
- unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
- argv += optind;
- if (!argv[0] || argv[1]) /* zero or >1 arguments */
- show_usage_and_die(program_usage_string, program_options);
-
- /* without this the name is set to argv[0] which confuses
- * desktops which uses the name to find the corresponding .desktop file
- * trac#180
- */
- g_set_prgname(prgname);
-
- export_abrt_envvars(opts & OPT_p);
-
- g_dump_dir_name = xstrdup(argv[0]);
-
- /* load /etc/abrt/events/foo.{conf,xml} stuff
- and ~/.abrt/events/foo.conf */
- load_event_config_data();
- load_event_config_data_from_keyring();
-
- create_assistant();
-
- g_custom_logger = &show_error_as_msgbox;
-
- reload_problem_data_from_dump_dir();
-
- update_gui_state_from_problem_data();
-
- /* Enter main loop */
- gtk_main();
-
- return 0;
-}
diff --git a/libreport/src/gui-wizard-gtk/wizard.c b/libreport/src/gui-wizard-gtk/wizard.c
deleted file mode 100644
index d7164d6d..00000000
--- a/libreport/src/gui-wizard-gtk/wizard.c
+++ /dev/null
@@ -1,1782 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <gtk/gtk.h>
-#include "abrt_dbus.h"
-#include "libreport-gtk.h"
-#include "wizard.h"
-
-#define DEFAULT_WIDTH 800
-#define DEFAULT_HEIGHT 500
-
-#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 22
-# define gtk_assistant_commit(...) ((void)0)
-#endif
-
-typedef struct event_gui_data_t
-{
- char *event_name;
- GtkToggleButton *toggle_button;
-} event_gui_data_t;
-
-
-static GtkAssistant *g_assistant;
-
-static char *g_analyze_event_selected;
-static char *g_reporter_events_selected;
-static unsigned g_black_event_count = 0;
-
-static GtkBox *g_box_analyzers;
-/* List of event_gui_data's */
-static GList *g_list_analyzers;
-static GtkLabel *g_lbl_analyze_log;
-static GtkTextView *g_tv_analyze_log;
-
-static GtkBox *g_box_reporters;
-/* List of event_gui_data's */
-static GList *g_list_reporters;
-static GtkLabel *g_lbl_report_log;
-static GtkTextView *g_tv_report_log;
-
-static GtkContainer *g_container_details1;
-static GtkContainer *g_container_details2;
-
-static GtkLabel *g_lbl_cd_reason;
-static GtkTextView *g_tv_backtrace;
-static GtkTextView *g_tv_comment;
-static GtkEventBox *g_eb_comment;
-static GtkWidget *g_widget_warnings_area;
-static GtkBox *g_box_warning_labels;
-static GtkToggleButton *g_tb_approve_bt;
-static GtkButton *g_btn_refresh;
-
-static GtkLabel *g_lbl_reporters;
-static GtkLabel *g_lbl_size;
-
-static GtkTreeView *g_tv_details;
-static GtkCellRenderer *g_tv_details_renderer_value;
-static GtkTreeViewColumn *g_tv_details_col_checkbox;
-//static GtkCellRenderer *g_tv_details_renderer_checkbox;
-static GtkListStore *g_ls_details;
-enum
-{
- /* Note: need to update types in
- * gtk_list_store_new(DETAIL_NUM_COLUMNS, TYPE1, TYPE2...)
- * if you change these:
- */
- DETAIL_COLUMN_CHECKBOX,
- DETAIL_COLUMN_NAME,
- DETAIL_COLUMN_VALUE,
- DETAIL_NUM_COLUMNS,
-};
-
-/* Search in bt */
-static guint g_timeout = 0;
-static GtkEntry *g_search_entry_bt;
-
-static GtkBuilder *builder;
-static PangoFontDescription *monospace_font;
-
-
-/* THE PAGE FLOW
- * page_5: user comments
- * page_1: analyze action selection
- * page_2: analyze progress
- * page_3: reporter selection
- * page_4: backtrace editor
- * page_6: summary
- * page_7: reporting progress
- */
-enum {
- PAGENO_SUMMARY,
- PAGENO_EDIT_COMMENT,
- PAGENO_ANALYZE_SELECTOR,
- PAGENO_ANALYZE_PROGRESS,
- PAGENO_REPORTER_SELECTOR,
- PAGENO_EDIT_BACKTRACE,
- PAGENO_REVIEW_DATA,
- PAGENO_REPORT_PROGRESS,
- PAGENO_REPORT_DONE,
- PAGENO_NOT_SHOWN,
- NUM_PAGES
-};
-
-/* Use of arrays (instead of, say, #defines to C strings)
- * allows cheaper page_obj_t->name == PAGE_FOO comparisons
- * instead of strcmp.
- */
-static const gchar PAGE_SUMMARY[] = "page_0";
-static const gchar PAGE_EDIT_COMMENT[] = "page_1";
-static const gchar PAGE_ANALYZE_SELECTOR[] = "page_2";
-static const gchar PAGE_ANALYZE_PROGRESS[] = "page_3";
-static const gchar PAGE_REPORTER_SELECTOR[] = "page_4_report";
-static const gchar PAGE_EDIT_BACKTRACE[] = "page_5";
-static const gchar PAGE_REVIEW_DATA[] = "page_6_report";
-static const gchar PAGE_REPORT_PROGRESS[] = "page_7_report";
-static const gchar PAGE_REPORT_DONE[] = "page_8_report";
-static const gchar PAGE_NOT_SHOWN[] = "page_9_report";
-
-static const gchar *const page_names[] =
-{
- PAGE_SUMMARY,
- PAGE_EDIT_COMMENT,
- PAGE_ANALYZE_SELECTOR,
- PAGE_ANALYZE_PROGRESS,
- PAGE_REPORTER_SELECTOR,
- PAGE_EDIT_BACKTRACE,
- PAGE_REVIEW_DATA,
- PAGE_REPORT_PROGRESS,
- PAGE_REPORT_DONE,
- PAGE_NOT_SHOWN,
- NULL
-};
-
-typedef struct
-{
- const gchar *name;
- const gchar *title;
- GtkAssistantPageType type;
- GtkWidget *page_widget;
-} page_obj_t;
-
-static page_obj_t pages[] =
-{
- /* Page types:
- * CONTENT: normal page (has all btns: [Cancel] [Last] [Back] [Fwd])
- * INTRO: only [Fwd] button is shown
- * (we use these where we want to suppress [Back]-navigation)
- * CONFIRM: has [Apply] instead of [Fwd] and emits "apply" signal
- * PROGRESS: skipped on [Back] navigation
- * SUMMARY: has only [Close] button
- *
- * Note that we suppress [Cancel] everywhere once and for all
- * using gtk_assistant_commit at init time.
- */
- /* glade element name , on-screen text , type */
- { PAGE_SUMMARY , "Problem description" , GTK_ASSISTANT_PAGE_CONTENT },
- { PAGE_EDIT_COMMENT,"Provide additional information", GTK_ASSISTANT_PAGE_CONTENT },
- { PAGE_ANALYZE_SELECTOR , "Select analyzer" , GTK_ASSISTANT_PAGE_CONFIRM },
- { PAGE_ANALYZE_PROGRESS , "Analyzing" , GTK_ASSISTANT_PAGE_INTRO },
- /* Some reporters don't need backtrace, we can skip bt page for them.
- * Therefore we want to know reporters _before_ we go to bt page
- */
- { PAGE_REPORTER_SELECTOR , "Select reporter" , GTK_ASSISTANT_PAGE_CONTENT },
- { PAGE_EDIT_BACKTRACE , "Review the backtrace" , GTK_ASSISTANT_PAGE_CONTENT },
- { PAGE_REVIEW_DATA , "Confirm data to report", GTK_ASSISTANT_PAGE_CONFIRM },
- /* Was GTK_ASSISTANT_PAGE_PROGRESS, but we want to allow returning to it */
- { PAGE_REPORT_PROGRESS , "Reporting" , GTK_ASSISTANT_PAGE_INTRO },
- { PAGE_REPORT_DONE , "Reporting done" , GTK_ASSISTANT_PAGE_CONTENT },
- /* We prevent user from reaching this page, as SUMMARY can't be navigated away
- * (must be always closed) and we don't want that
- */
- { PAGE_NOT_SHOWN , "" , GTK_ASSISTANT_PAGE_SUMMARY },
- { NULL }
-};
-
-static page_obj_t *added_pages[NUM_PAGES];
-
-
-/* Utility functions */
-
-static void remove_child_widget(GtkWidget *widget, gpointer unused)
-{
- /* Destroy will safely remove it and free the memory
- * if there are no refs left
- */
- gtk_widget_destroy(widget);
-}
-
-static void save_dialog_response(GtkDialog *dialog, gint response_id, gpointer user_data)
-{
- *(gint*)user_data = response_id;
-}
-
-struct dump_dir *steal_if_needed(struct dump_dir *dd)
-{
- if (!dd)
- xfunc_die(); /* error msg was already logged */
-
- if (dd->locked)
- return dd;
-
- dd_close(dd);
-
- char *HOME = getenv("HOME");
- if (!HOME || !HOME[0])
- {
- struct passwd *pw = getpwuid(getuid());
- HOME = pw ? pw->pw_dir : NULL;
- }
- if (HOME && HOME[0])
- HOME = concat_path_file(HOME, ".abrt/spool");
- else
- HOME = xstrdup("/tmp");
-
- GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(g_assistant),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_OK_CANCEL,
- _("Need writable directory, but '%s' is not writable."
- " Move it to '%s' and operate on the moved copy?"),
- g_dump_dir_name, HOME
- );
- gint response = GTK_RESPONSE_CANCEL;
- g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(save_dialog_response), &response);
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
-
- if (response != GTK_RESPONSE_OK)
- return NULL;
-
- dd = steal_directory(HOME, g_dump_dir_name);
- if (!dd)
- return NULL; /* Stealing failed. Error msg was already logged */
-
- /* Delete old dir and switch to new one.
- * Don't want to keep new dd open across deletion,
- * therefore it's a bit more complicated.
- */
- char *old_name = g_dump_dir_name;
- g_dump_dir_name = xstrdup(dd->dd_dirname);
- dd_close(dd);
-
- gtk_window_set_title(GTK_WINDOW(g_assistant), g_dump_dir_name);
- delete_dump_dir_possibly_using_abrtd(old_name); //TODO: if (deletion_failed) error_msg("BAD")?
- free(old_name);
-
- dd = dd_opendir(g_dump_dir_name, 0);
- if (!dd)
- xfunc_die(); /* error msg was already logged */
-
- return dd;
-}
-
-void show_error_as_msgbox(const char *msg)
-{
- GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(g_assistant),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- "%s", msg
- );
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
-}
-
-static void load_text_to_text_view(GtkTextView *tv, const char *name)
-{
- const char *str = g_cd ? get_problem_item_content_or_NULL(g_cd, name) : NULL;
- gtk_text_buffer_set_text(gtk_text_view_get_buffer(tv), (str ? str : ""), -1);
-}
-
-static gchar *get_malloced_string_from_text_view(GtkTextView *tv)
-{
- GtkTextBuffer *buffer = gtk_text_view_get_buffer(tv);
- GtkTextIter start;
- GtkTextIter end;
- gtk_text_buffer_get_start_iter(buffer, &start);
- gtk_text_buffer_get_end_iter(buffer, &end);
- return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
-}
-
-static void save_text_if_changed(const char *name, const char *new_value)
-{
- const char *old_value = g_cd ? get_problem_item_content_or_NULL(g_cd, name) : "";
- if (!old_value)
- old_value = "";
- if (strcmp(new_value, old_value) != 0)
- {
- struct dump_dir *dd = dd_opendir(g_dump_dir_name, DD_OPEN_READONLY);
- dd = steal_if_needed(dd);
- if (dd && dd->locked)
- {
- dd_save_text(dd, name, new_value);
- }
-//FIXME: else: what to do with still-unsaved data in the widget??
- dd_close(dd);
- reload_problem_data_from_dump_dir();
- update_gui_state_from_problem_data();
- }
-}
-
-static void save_text_from_text_view(GtkTextView *tv, const char *name)
-{
- gchar *new_str = get_malloced_string_from_text_view(tv);
- save_text_if_changed(name, new_str);
- free(new_str);
-}
-
-static void append_to_textview(GtkTextView *tv, const char *str)
-{
- GtkTextBuffer *tb = gtk_text_view_get_buffer(tv);
-
- /* Ensure we insert text at the end */
- GtkTextIter text_iter;
- gtk_text_buffer_get_iter_at_offset(tb, &text_iter, -1);
- gtk_text_buffer_place_cursor(tb, &text_iter);
-
- gtk_text_buffer_insert_at_cursor(tb, str, strlen(str));
-
- /* Scroll so that the end of the log is visible */
- gtk_text_buffer_get_iter_at_offset(tb, &text_iter, -1);
- gtk_text_view_scroll_to_iter(tv, &text_iter,
- /*within_margin:*/ 0.0, /*use_align:*/ FALSE, /*xalign:*/ 0, /*yalign:*/ 0);
-}
-
-
-/* event_gui_data_t */
-
-static event_gui_data_t *new_event_gui_data_t(void)
-{
- return xzalloc(sizeof(event_gui_data_t));
-}
-
-static void free_event_gui_data_t(event_gui_data_t *evdata, void *unused)
-{
- if (evdata)
- {
- free(evdata->event_name);
- free(evdata);
- }
-}
-
-
-/* tv_details handling */
-
-static struct problem_item *get_current_problem_item_or_NULL(GtkTreeView *tree_view, gchar **pp_item_name)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection* selection = gtk_tree_view_get_selection(tree_view);
- if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- return NULL;
-
- *pp_item_name = NULL;
- gtk_tree_model_get(model, &iter,
- DETAIL_COLUMN_NAME, pp_item_name,
- -1);
- if (!*pp_item_name) /* paranoia, should never happen */
- return NULL;
- struct problem_item *item = get_problem_data_item_or_NULL(g_cd, *pp_item_name);
-
- return item;
-}
-
-static void tv_details_row_activated(
- GtkTreeView *tree_view,
- GtkTreePath *tree_path_UNUSED,
- GtkTreeViewColumn *column,
- gpointer user_data)
-{
- gchar *item_name;
- struct problem_item *item = get_current_problem_item_or_NULL(tree_view, &item_name);
- if (!item || !(item->flags & CD_FLAG_TXT))
- goto ret;
- if (!strchr(item->content, '\n')) /* one line? */
- goto ret; /* yes */
-
- gchar *arg[3];
- arg[0] = (char *) "xdg-open";
- arg[1] = concat_path_file(g_dump_dir_name, item_name);
- arg[2] = NULL;
-
- g_spawn_sync(NULL, arg, NULL,
- G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL,
- NULL, NULL, NULL, NULL, NULL, NULL);
-
- free(arg[1]);
- ret:
- g_free(item_name);
-}
-
-/* static gboolean tv_details_select_cursor_row(
- GtkTreeView *tree_view,
- gboolean arg1,
- gpointer user_data) {...} */
-
-static void tv_details_cursor_changed(
- GtkTreeView *tree_view,
- gpointer user_data_UNUSED)
-{
- gchar *item_name;
- struct problem_item *item = get_current_problem_item_or_NULL(tree_view, &item_name);
- g_free(item_name);
-
- gboolean editable = (item && (item->flags & CD_FLAG_TXT) && !strchr(item->content, '\n'));
-
- /* Allow user to select the text with mouse.
- * Has undesirable side-effect of allowing user to "edit" the text,
- * but changes aren't saved (the old text reappears as soon as user
- * leaves the field). Need to disable editing somehow.
- */
- g_object_set(G_OBJECT(g_tv_details_renderer_value),
- "editable", editable,
- NULL);
-}
-
-static void g_tv_details_checkbox_toggled(
- GtkCellRendererToggle *cell_renderer_UNUSED,
- gchar *tree_path,
- gpointer user_data_UNUSED)
-{
- //log("%s: path:'%s'", __func__, tree_path);
- GtkTreeIter iter;
- if (!gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(g_ls_details), &iter, tree_path))
- return;
-
- gchar *item_name = NULL;
- gtk_tree_model_get(GTK_TREE_MODEL(g_ls_details), &iter,
- DETAIL_COLUMN_NAME, &item_name,
- -1);
- if (!item_name) /* paranoia, should never happen */
- return;
- struct problem_item *item = get_problem_data_item_or_NULL(g_cd, item_name);
- g_free(item_name);
- if (!item) /* paranoia */
- return;
-
- int cur_value;
- if (item->selected_by_user == 0)
- cur_value = item->default_by_reporter;
- else
- cur_value = !!(item->selected_by_user + 1); /* map -1,1 to 0,1 */
- //log("%s: allowed:%d reqd:%d def:%d user:%d cur:%d", __func__,
- // item->allowed_by_reporter,
- // item->required_by_reporter,
- // item->default_by_reporter,
- // item->selected_by_user,
- // cur_value
- //);
- if (item->allowed_by_reporter && !item->required_by_reporter)
- {
- cur_value = !cur_value;
- item->selected_by_user = cur_value * 2 - 1; /* map 0,1 to -1,1 */
- //log("%s: now ->selected_by_user=%d", __func__, item->selected_by_user);
- gtk_list_store_set(g_ls_details, &iter,
- DETAIL_COLUMN_CHECKBOX, cur_value,
- -1);
- }
-}
-
-
-/* update_gui_state_from_problem_data */
-
-static gint find_by_button(gconstpointer a, gconstpointer button)
-{
- const event_gui_data_t *evdata = a;
- return (evdata->toggle_button != button);
-}
-
-static void analyze_rb_was_toggled(GtkButton *button, gpointer user_data)
-{
- free(g_analyze_event_selected);
- g_analyze_event_selected = NULL;
- GList *found = g_list_find_custom(g_list_analyzers, button, find_by_button);
- if (found)
- {
- event_gui_data_t *evdata = found->data;
- g_analyze_event_selected = xstrdup(evdata->event_name);
- }
-}
-
-static void report_tb_was_toggled(GtkButton *button_unused, gpointer user_data_unused)
-{
- struct strbuf *reporters_string = strbuf_new();
- GList *li = g_list_reporters;
- for (; li; li = li->next)
- {
- event_gui_data_t *event_gui_data = li->data;
- if (gtk_toggle_button_get_active(event_gui_data->toggle_button) == TRUE)
- {
- strbuf_append_strf(reporters_string,
- "%s%s",
- (reporters_string->len != 0 ? ", " : ""),
- event_gui_data->event_name
- );
- g_validate_event(event_gui_data->event_name);
- }
- }
-
- gtk_assistant_set_page_complete(g_assistant,
- pages[PAGENO_REPORTER_SELECTOR].page_widget,
- reporters_string->len != 0 /* true if at least one checkbox is active */
- );
-
- /* Update "list of reporters" label */
- free(g_reporter_events_selected);
- g_reporter_events_selected = strbuf_free_nobuf(reporters_string);
- gtk_label_set_text(g_lbl_reporters, g_reporter_events_selected);
-}
-
-/* event_name contains "EVENT1\nEVENT2\nEVENT3\n".
- * Add new {radio/check}buttons to GtkBox for each EVENTn (type depends on bool radio).
- * Remember them in GList **p_event_list (list of event_gui_data_t's).
- * Set "toggled" callback on each button to given GCallback if it's not NULL.
- * Return active button (or NULL if none created).
- */
-static event_gui_data_t *add_event_buttons(GtkBox *box,
- GList **p_event_list,
- char *event_name,
- GCallback func,
- bool radio)
-{
- //VERB2 log("removing all buttons from box %p", box);
- gtk_container_foreach(GTK_CONTAINER(box), &remove_child_widget, NULL);
- g_list_foreach(*p_event_list, (GFunc)free_event_gui_data_t, NULL);
- g_list_free(*p_event_list);
- *p_event_list = NULL;
-
- if (radio)
- g_black_event_count = 0;
-
- event_gui_data_t *first_button = NULL;
- event_gui_data_t *active_button = NULL;
- while (event_name[0])
- {
- char *event_name_end = strchr(event_name, '\n');
- *event_name_end = '\0';
-
- event_config_t *cfg = get_event_config(event_name);
-
- /* Form a pretty text representation of event */
- /* By default, use event name, just strip "foo_" prefix if it exists: */
- const char *event_screen_name = strchr(event_name, '_');
- if (event_screen_name)
- event_screen_name++;
- else
- event_screen_name = event_name;
-
- const char *event_description = NULL;
- char *tmp_description = NULL;
- bool green_choice = false;
- if (cfg)
- {
- /* .xml has (presumably) prettier description, use it: */
- if (cfg->screen_name)
- event_screen_name = cfg->screen_name;
- event_description = cfg->description;
- if (cfg->ec_creates_items)
- {
- if (get_problem_data_item_or_NULL(g_cd, cfg->ec_creates_items))
- {
- green_choice = true;
- event_description = tmp_description = xasprintf(_("(not needed, '%s' already exists)"), cfg->ec_creates_items);
- }
- }
- }
- if (radio && !green_choice)
- g_black_event_count++;
-
- //VERB2 log("adding button '%s' to box %p", event_name, box);
- char *event_label = xasprintf("%s%s%s",
- event_screen_name,
- (event_description ? " - " : ""),
- event_description ? event_description : ""
- );
- free(tmp_description);
-
- GtkWidget *button = radio
- ? gtk_radio_button_new_with_label_from_widget(
- (first_button ? GTK_RADIO_BUTTON(first_button->toggle_button) : NULL),
- event_label
- )
- : gtk_check_button_new_with_label(event_label);
- free(event_label);
-
- if (green_choice)
- {
- //static const GdkColor red = { .red = 0xffff };
- //gtk_widget_modify_text(button, GTK_STATE_NORMAL, &red);
- GtkWidget *child = gtk_bin_get_child(GTK_BIN(button));
- if (child)
- {
- static const GdkColor green = { .green = 0x7fff };
- gtk_widget_modify_fg(child, GTK_STATE_NORMAL, &green);
- gtk_widget_modify_fg(child, GTK_STATE_ACTIVE, &green);
- gtk_widget_modify_fg(child, GTK_STATE_PRELIGHT, &green);
- }
- }
-
- if (func)
- g_signal_connect(G_OBJECT(button), "toggled", func, NULL);
- if (cfg && cfg->long_descr)
- gtk_widget_set_tooltip_text(button, cfg->long_descr);
-
- event_gui_data_t *event_gui_data = new_event_gui_data_t();
- event_gui_data->event_name = xstrdup(event_name);
- event_gui_data->toggle_button = GTK_TOGGLE_BUTTON(button);
- *p_event_list = g_list_append(*p_event_list, event_gui_data);
-
- if (!first_button)
- first_button = event_gui_data;
-
- if (radio && !green_choice && !active_button)
- {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), true);
- active_button = event_gui_data;
- }
-
- *event_name_end = '\n';
- event_name = event_name_end + 1;
-
- gtk_box_pack_start(box, button, /*expand*/ false, /*fill*/ false, /*padding*/ 0);
- }
-
- if (radio)
- {
- const char *msg_proceed_to_reporting = _("Go to reporting step");
- GtkWidget *button = radio
- ? gtk_radio_button_new_with_label_from_widget(
- (first_button ? GTK_RADIO_BUTTON(first_button->toggle_button) : NULL),
- msg_proceed_to_reporting
- )
- : gtk_check_button_new_with_label(msg_proceed_to_reporting);
- if (func)
- g_signal_connect(G_OBJECT(button), "toggled", func, NULL);
-
- event_gui_data_t *event_gui_data = new_event_gui_data_t();
- event_gui_data->event_name = xstrdup("");
- event_gui_data->toggle_button = GTK_TOGGLE_BUTTON(button);
- *p_event_list = g_list_append(*p_event_list, event_gui_data);
-
- if (!active_button)
- {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), true);
- active_button = event_gui_data;
- }
-
- gtk_box_pack_start(box, button, /*expand*/ false, /*fill*/ false, /*padding*/ 0);
- }
-
- return active_button;
-}
-
-struct cd_stats {
- off_t filesize;
- unsigned filecount;
-};
-
-static void append_item_to_ls_details(gpointer name, gpointer value, gpointer data)
-{
- problem_item *item = (problem_item*)value;
- struct cd_stats *stats = data;
- GtkTreeIter iter;
-
- gtk_list_store_append(g_ls_details, &iter);
- stats->filecount++;
-
- //FIXME: use the human-readable format_problem_item(item) instead of item->content.
- if (item->flags & CD_FLAG_TXT)
- {
- stats->filesize += strlen(item->content);
- /* If not multiline... */
- if (!strchr(item->content, '\n'))
- {
- gtk_list_store_set(g_ls_details, &iter,
- DETAIL_COLUMN_NAME, (char *)name,
- DETAIL_COLUMN_VALUE, item->content,
- -1);
- }
- else
- {
- gtk_list_store_set(g_ls_details, &iter,
- DETAIL_COLUMN_NAME, (char *)name,
- DETAIL_COLUMN_VALUE, _("(click here to view/edit)"),
- -1);
- }
- }
- else if (item->flags & CD_FLAG_BIN)
- {
- struct stat statbuf;
- statbuf.st_size = 0;
- stat(item->content, &statbuf);
- stats->filesize += statbuf.st_size;
- char *msg = xasprintf(_("(binary file, %llu bytes)"), (long long)statbuf.st_size);
- gtk_list_store_set(g_ls_details, &iter,
- DETAIL_COLUMN_NAME, (char *)name,
- DETAIL_COLUMN_VALUE, msg,
- -1);
- free(msg);
- }
-}
-
-void update_gui_state_from_problem_data(void)
-{
- gtk_window_set_title(GTK_WINDOW(g_assistant), g_dump_dir_name);
-
- const char *reason = get_problem_item_content_or_NULL(g_cd, FILENAME_REASON);
- gtk_label_set_text(g_lbl_cd_reason, reason ? reason : _("(no description)"));
-
- gtk_list_store_clear(g_ls_details);
- struct cd_stats stats = { 0 };
- g_hash_table_foreach(g_cd, append_item_to_ls_details, &stats);
- char *msg = xasprintf(_("%llu bytes, %u files"), (long long)stats.filesize, stats.filecount);
- gtk_label_set_text(g_lbl_size, msg);
- free(msg);
-
- load_text_to_text_view(g_tv_backtrace, FILENAME_BACKTRACE);
- load_text_to_text_view(g_tv_comment, FILENAME_COMMENT);
-
- /* Update analyze radio buttons */
- event_gui_data_t *active_button = add_event_buttons(g_box_analyzers, &g_list_analyzers,
- g_analyze_events, G_CALLBACK(analyze_rb_was_toggled),
- /*radio:*/ true
- );
- /* Update the value of currently selected analyzer */
- if (active_button)
- {
- free(g_analyze_event_selected);
- g_analyze_event_selected = xstrdup(active_button->event_name);
- VERB2 log("g_analyze_event_selected='%s'", g_analyze_event_selected);
- }
-
- /* Update reporter checkboxes */
- /* Remember names of selected reporters */
- GList *old_reporters = NULL;
- GList *li = g_list_reporters;
- for (; li; li = li->next)
- {
- event_gui_data_t *event_gui_data = li->data;
- if (gtk_toggle_button_get_active(event_gui_data->toggle_button) == TRUE)
- {
- /* order isn't important. prepend is faster */
- old_reporters = g_list_prepend(old_reporters, xstrdup(event_gui_data->event_name));
- }
- }
- /* Delete old checkboxes and create new ones */
- add_event_buttons(g_box_reporters, &g_list_reporters,
- g_report_events, /*callback:*/ G_CALLBACK(report_tb_was_toggled),
- /*radio:*/ false
- );
- /* Re-select new reporters which were selected before we deleted them */
- GList *li_new = g_list_reporters;
- for (; li_new; li_new = li_new->next)
- {
- event_gui_data_t *new_gui_data = li_new->data;
- GList *li_old = old_reporters;
- for (; li_old; li_old = li_old->next)
- {
- if (strcmp(new_gui_data->event_name, li_old->data) == 0)
- {
- gtk_toggle_button_set_active(new_gui_data->toggle_button, true);
- break;
- }
- }
- }
- list_free_with_free(old_reporters);
-
- /* Update readiness state of reporter selector page and "list of reporters" label */
- report_tb_was_toggled(NULL, NULL);
-
- /* We can't just do gtk_widget_show_all once in main:
- * We created new widgets (buttons). Need to make them visible.
- */
- gtk_widget_show_all(GTK_WIDGET(g_assistant));
-
- if (g_analyze_events[0])
- gtk_widget_show(GTK_WIDGET(g_btn_refresh));
- else
- gtk_widget_hide(GTK_WIDGET(g_btn_refresh));
-}
-
-
-/* start_event_run */
-
-struct analyze_event_data
-{
- struct run_event_state *run_state;
- const char *event_name;
- GList *more_events;
- GList *env_list;
- GtkWidget *page_widget;
- GtkLabel *status_label;
- GtkTextView *tv_log;
- const char *end_msg;
- GIOChannel *channel;
- struct strbuf *event_log;
- int event_log_state;
- int fd;
- /*guint event_source_id;*/
-};
-enum {
- LOGSTATE_FIRSTLINE = 0,
- LOGSTATE_BEGLINE,
- LOGSTATE_ERRLINE,
- LOGSTATE_MIDLINE,
-};
-
-static void set_excluded_envvar(void)
-{
- struct strbuf *item_list = strbuf_new();
- const char *fmt = "%s";
-
- GtkTreeIter iter;
- if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(g_ls_details), &iter))
- {
- do {
- gchar *item_name = NULL;
- gboolean checked = 0;
- gtk_tree_model_get(GTK_TREE_MODEL(g_ls_details), &iter,
- DETAIL_COLUMN_NAME, &item_name,
- DETAIL_COLUMN_CHECKBOX, &checked,
- -1);
- if (!item_name) /* paranoia, should never happen */
- continue;
- if (!checked)
- {
- strbuf_append_strf(item_list, fmt, item_name);
- fmt = ",%s";
- }
- g_free(item_name);
- } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(g_ls_details), &iter));
- }
- char *var = strbuf_free_nobuf(item_list);
- //log("EXCLUDE_FROM_REPORT='%s'", var);
- if (var)
- {
- xsetenv("EXCLUDE_FROM_REPORT", var);
- free(var);
- }
- else
- unsetenv("EXCLUDE_FROM_REPORT");
-}
-
-static int spawn_next_command_in_evd(struct analyze_event_data *evd)
-{
- evd->env_list = export_event_config(evd->event_name);
- int r = spawn_next_command(evd->run_state, g_dump_dir_name, evd->event_name);
- if (r < 0)
- {
- unexport_event_config(evd->env_list);
- evd->env_list = NULL;
- }
- return r;
-}
-
-static void save_to_event_log(struct analyze_event_data *evd, const char *str)
-{
- static const char delim[] = {
- [LOGSTATE_FIRSTLINE] = '>',
- [LOGSTATE_BEGLINE] = ' ',
- [LOGSTATE_ERRLINE] = '*',
- };
-
- while (str[0])
- {
- char *end = strchrnul(str, '\n');
- char end_char = *end;
- if (end_char == '\n')
- end++;
- switch (evd->event_log_state)
- {
- case LOGSTATE_FIRSTLINE:
- case LOGSTATE_BEGLINE:
- case LOGSTATE_ERRLINE:
- /* skip empty lines */
- if (str[0] == '\n')
- goto next;
- strbuf_append_strf(evd->event_log, "%s%c %.*s",
- iso_date_string(NULL),
- delim[evd->event_log_state],
- (int)(end - str), str
- );
- break;
- case LOGSTATE_MIDLINE:
- strbuf_append_strf(evd->event_log, "%.*s", (int)(end - str), str);
- break;
- }
- evd->event_log_state = LOGSTATE_MIDLINE;
- if (end_char != '\n')
- break;
- evd->event_log_state = LOGSTATE_BEGLINE;
- next:
- str = end;
- }
-}
-
-static void update_event_log_on_disk(const char *str)
-{
- /* Load existing log */
- struct dump_dir *dd = dd_opendir(g_dump_dir_name, 0);
- if (!dd)
- return;
- char *event_log = dd_load_text_ext(dd, FILENAME_EVENT_LOG, DD_FAIL_QUIETLY_ENOENT);
-
- /* Append new log part to existing log */
- unsigned len = strlen(event_log);
- if (len != 0 && event_log[len - 1] != '\n')
- event_log = append_to_malloced_string(event_log, "\n");
- event_log = append_to_malloced_string(event_log, str);
-
- /* Trim log according to size watermarks */
- len = strlen(event_log);
- char *new_log = event_log;
- if (len > EVENT_LOG_HIGH_WATERMARK)
- {
- new_log += len - EVENT_LOG_LOW_WATERMARK;
- new_log = strchrnul(new_log, '\n');
- if (new_log[0])
- new_log++;
- }
-
- /* Save */
- dd_save_text(dd, FILENAME_EVENT_LOG, new_log);
- free(event_log);
- dd_close(dd);
-}
-
-static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, gpointer data)
-{
- struct analyze_event_data *evd = data;
-
- /* Read and insert the output into the log pane */
- char buf[257]; /* usually we get one line, no need to have big buf */
- int r;
- while ((r = read(evd->fd, buf, sizeof(buf)-1)) > 0)
- {
- buf[r] = '\0';
- append_to_textview(evd->tv_log, buf);
- save_to_event_log(evd, buf);
- }
-
- if (r < 0 && errno == EAGAIN)
- /* We got all buffered data, but fd is still open. Done for now */
- return TRUE; /* "please don't remove this event (yet)" */
-
- /* EOF/error */
-
- unexport_event_config(evd->env_list);
- evd->env_list = NULL;
-
- /* Wait for child to actually exit, collect status */
- int status;
- waitpid(evd->run_state->command_pid, &status, 0);
- int retval = WEXITSTATUS(status);
- if (WIFSIGNALED(status))
- retval = WTERMSIG(status) + 128;
-
- /* Write a final message to the log */
- if (evd->event_log->len != 0 && evd->event_log->buf[evd->event_log->len - 1] != '\n')
- save_to_event_log(evd, "\n");
- /* If program failed, or if it finished successfully without saying anything... */
- if (retval != 0 || evd->event_log_state == LOGSTATE_FIRSTLINE)
- {
- if (retval != 0) /* If program failed, emit error line */
- evd->event_log_state = LOGSTATE_ERRLINE;
- char *msg;
- if (WIFSIGNALED(status))
- msg = xasprintf("(killed by signal %u)\n", WTERMSIG(status));
- else
- msg = xasprintf("(exited with %u)\n", retval);
- append_to_textview(evd->tv_log, msg);
- save_to_event_log(evd, msg);
- free(msg);
- }
-
- /* Append log to FILENAME_EVENT_LOG */
- update_event_log_on_disk(evd->event_log->buf);
- strbuf_clear(evd->event_log);
- evd->event_log_state = LOGSTATE_FIRSTLINE;
-
- if (geteuid() == 0)
- {
- /* Reset mode/uig/gid to correct values for all files created by event run */
- struct dump_dir *dd = dd_opendir(g_dump_dir_name, 0);
- if (dd)
- {
- dd_sanitize_mode_and_owner(dd);
- dd_close(dd);
- }
- }
-
- /* Stop if exit code is not 0, or no more commands */
- if (retval != 0
- || spawn_next_command_in_evd(evd) < 0
- ) {
- VERB1 log("done running event on '%s': %d", g_dump_dir_name, retval);
- append_to_textview(evd->tv_log, "\n");
-
- for (;;)
- {
- if (!evd->more_events)
- {
- char *msg = xasprintf(evd->end_msg, retval);
- gtk_label_set_text(evd->status_label, msg);
- free(msg);
-
- /* Enable (un-gray out) navigation buttons */
- gtk_widget_set_sensitive(GTK_WIDGET(g_assistant), true);
-
- /*g_source_remove(evd->event_source_id);*/
- close(evd->fd);
- free_run_event_state(evd->run_state);
- strbuf_free(evd->event_log);
- free(evd);
-
- reload_problem_data_from_dump_dir();
- update_gui_state_from_problem_data();
-
- /* Inform abrt-gui that it is a good idea to rescan the directory */
- kill(getppid(), SIGCHLD);
-
- return FALSE; /* "please remove this event" */
- }
-
- evd->event_name = evd->more_events->data;
- evd->more_events = g_list_remove(evd->more_events, evd->more_events->data);
-
- if (prepare_commands(evd->run_state, g_dump_dir_name, evd->event_name) != 0
- && spawn_next_command_in_evd(evd) >= 0
- ) {
- VERB1 log("running event '%s' on '%s'", evd->event_name, g_dump_dir_name);
- char *msg = xasprintf("--- Running %s ---\n", evd->event_name);
- append_to_textview(evd->tv_log, msg);
- free(msg);
- break;
- }
- /* No commands needed?! (This is untypical) */
- }
- }
-
- /* New command was started. Continue waiting for input */
-
- /* Transplant cmd's output fd onto old one, so that main loop
- * is none the wiser that fd it waits on has changed
- */
- xmove_fd(evd->run_state->command_out_fd, evd->fd);
- evd->run_state->command_out_fd = evd->fd; /* just to keep it consistent */
- ndelay_on(evd->fd);
-
- return TRUE; /* "please don't remove this event (yet)" */
-}
-
-static void start_event_run(const char *event_name,
- GList *more_events,
- GtkWidget *page,
- GtkTextView *tv_log,
- GtkLabel *status_label,
- const char *start_msg,
- const char *end_msg
-) {
- /* Start event asynchronously on the dump dir
- * (synchronous run would freeze GUI until completion)
- */
- struct run_event_state *state = new_run_event_state();
-
- if (prepare_commands(state, g_dump_dir_name, event_name) == 0)
- {
- no_cmds:
- /* No commands needed?! (This is untypical) */
- free_run_event_state(state);
-//TODO: better msg?
- char *msg = xasprintf(_("No processing for event '%s' is defined"), event_name);
- gtk_label_set_text(status_label, msg);
- free(msg);
- return;
- }
-
- struct dump_dir *dd = dd_opendir(g_dump_dir_name, DD_OPEN_READONLY);
- dd = steal_if_needed(dd);
- int locked = (dd && dd->locked);
- dd_close(dd);
- if (!locked)
- return; /* user refused to steal, or write error, etc... */
-
- set_excluded_envvar();
- GList *env_list = export_event_config(event_name);
-
- if (spawn_next_command(state, g_dump_dir_name, event_name) < 0)
- {
- unexport_event_config(env_list);
- goto no_cmds;
- }
-
- /* At least one command is needed, and we started first one.
- * Hook its output fd to the main loop.
- */
- struct analyze_event_data *evd = xzalloc(sizeof(*evd));
- evd->run_state = state;
- evd->event_name = event_name;
- evd->more_events = more_events;
- evd->env_list = env_list;
- evd->page_widget = page;
- evd->status_label = status_label;
- evd->tv_log = tv_log;
- evd->end_msg = end_msg;
- evd->event_log = strbuf_new();
- evd->fd = state->command_out_fd;
- ndelay_on(evd->fd);
- evd->channel = g_io_channel_unix_new(evd->fd);
- /*evd->event_source_id = */ g_io_add_watch(evd->channel,
- G_IO_IN | G_IO_ERR | G_IO_HUP, /* need HUP to detect EOF w/o any data */
- consume_cmd_output,
- evd
- );
-
- gtk_label_set_text(status_label, start_msg);
-
- VERB1 log("running event '%s' on '%s'", event_name, g_dump_dir_name);
-//TODO: save_to_event_log(evd, "message that we run event foo")?
- char *msg = xasprintf("--- Running %s ---\n", event_name);
- append_to_textview(evd->tv_log, msg);
- free(msg);
-
- /* Disable (gray out) navigation buttons */
- gtk_widget_set_sensitive(GTK_WIDGET(g_assistant), false);
-}
-
-
-/* Backtrace checkbox handling */
-
-static void add_warning(const char *warning)
-{
- char *label_str = xasprintf("• %s", warning);
- GtkWidget *warning_lbl = gtk_label_new(label_str);
- /* should be safe to free it, gtk calls strdup() to copy it */
- free(label_str);
-
- gtk_misc_set_alignment(GTK_MISC(warning_lbl), 0.0, 0.0);
- gtk_label_set_justify(GTK_LABEL(warning_lbl), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(g_box_warning_labels, warning_lbl, false, false, 0);
- gtk_widget_show(warning_lbl);
-}
-
-static void check_bt_rating_and_allow_send(void)
-{
- bool send = true;
- bool warn = false;
-
- /* erase all warnings */
- gtk_widget_hide(g_widget_warnings_area);
- gtk_container_foreach(GTK_CONTAINER(g_box_warning_labels), &remove_child_widget, NULL);
-
- /*
- * FIXME: this should be bind to a reporter not to a compoment
- * but so far only oopses don't have rating, so for now we
- * skip the "kernel" manually
- */
- const char *analyzer = get_problem_item_content_or_NULL(g_cd, FILENAME_ANALYZER);
-//FIXME: say "no" to special casing!
- if (analyzer && strcmp(analyzer, "Kerneloops") != 0)
- {
- const char *rating = get_problem_item_content_or_NULL(g_cd, FILENAME_RATING);
-//COMPAT, remove after 2.1 release
- if (!rating) rating= get_problem_item_content_or_NULL(g_cd, "rating");
- if (rating) switch (*rating)
- {
- case '4': /* bt is ok - no warning here */
- break;
- case '3': /* bt is usable, but not complete, so show a warning */
- add_warning(_("The backtrace is incomplete, please make sure you provide the steps to reproduce."));
- warn = true;
- break;
- default:
- //FIXME: see CreporterAssistant: 394 for ideas
- add_warning(_("Reporting disabled because the backtrace is unusable."));
- send = false;
- warn = true;
- break;
- }
- }
-
- if (!gtk_toggle_button_get_active(g_tb_approve_bt))
- {
- add_warning(_("You should check the backtrace for sensitive data."));
- add_warning(_("You must agree with sending the backtrace."));
- send = false;
- warn = true;
- }
-
- gtk_assistant_set_page_complete(g_assistant,
- pages[PAGENO_EDIT_BACKTRACE].page_widget,
- send);
- if (warn)
- gtk_widget_show(g_widget_warnings_area);
-}
-
-static void on_bt_approve_toggle(GtkToggleButton *togglebutton, gpointer user_data)
-{
- check_bt_rating_and_allow_send();
-}
-
-static void on_comment_changed(GtkTextBuffer *buffer, gpointer user_data)
-{
- bool good = gtk_text_buffer_get_char_count(buffer) >= 10;
-
- /* The page doesn't exist with report-only option */
- if (pages[PAGENO_EDIT_COMMENT].page_widget == NULL)
- return;
-
- /* Allow next page only when the comment has at least 10 chars */
- gtk_assistant_set_page_complete(g_assistant, pages[PAGENO_EDIT_COMMENT].page_widget, good);
-
- /* And show the eventbox with label */
- if (good)
- gtk_widget_hide(GTK_WIDGET(g_eb_comment));
- else
- gtk_widget_show(GTK_WIDGET(g_eb_comment));
-}
-
-
-/* Refresh button handling */
-
-static void on_btn_refresh_clicked(GtkButton *button)
-{
- /* Save backtrace text if changed */
- save_text_from_text_view(g_tv_backtrace, FILENAME_BACKTRACE);
-
- /* Refresh GUI so that we see new analyze buttons */
- update_gui_state_from_problem_data();
-
- /* Change page to analyzer selector - let user play with them */
- gtk_assistant_set_current_page(g_assistant, PAGENO_ANALYZE_SELECTOR);
-}
-
-
-/* Page navigation handlers */
-
-static void next_page(GtkAssistant *assistant, gpointer user_data)
-{
- /* page_no is actually the previous page, because this
- * function is called before assistant goes to the next page
- */
- int page_no = gtk_assistant_get_current_page(assistant);
- VERB2 log("page_no:%d", page_no);
-
- if (added_pages[page_no]->name == PAGE_ANALYZE_SELECTOR)
- {
- VERB2 log("g_analyze_event_selected:'%s'", g_analyze_event_selected);
- if (g_analyze_event_selected
- && g_analyze_event_selected[0]
- ) {
- start_event_run(g_analyze_event_selected,
- NULL,
- pages[PAGENO_ANALYZE_PROGRESS].page_widget,
- g_tv_analyze_log,
- g_lbl_analyze_log,
- _("Analyzing..."),
- _("Analyzing finished with exit code %d")
- );
- }
- }
-
- if (added_pages[page_no]->name == PAGE_REVIEW_DATA)
- {
- GList *reporters = NULL;
- GList *li = g_list_reporters;
- for (; li; li = li->next)
- {
- event_gui_data_t *event_gui_data = li->data;
- if (gtk_toggle_button_get_active(event_gui_data->toggle_button) == TRUE)
- {
- reporters = g_list_append(reporters, event_gui_data->event_name);
- }
- }
- if (reporters)
- {
- char *first_event_name = reporters->data;
- reporters = g_list_remove(reporters, reporters->data);
- start_event_run(first_event_name,
- reporters,
- pages[PAGENO_REPORT_PROGRESS].page_widget,
- g_tv_report_log,
- g_lbl_report_log,
- _("Reporting..."),
- _("Reporting finished with exit code %d")
- );
- }
- }
-}
-
-static void on_show_event_list_cb(GtkWidget *button, gpointer user_data)
-{
- show_events_list_dialog(GTK_WINDOW(g_assistant));
-}
-
-#if 0
-static void log_ready_state()
-{
- char buf[NUM_PAGES+1];
- for (int i = 0; i < NUM_PAGES; i++)
- {
- char ch = '_';
- if (pages[i].page_widget)
- ch = gtk_assistant_get_page_complete(g_assistant, pages[i].page_widget) ? '+' : '-';
- buf[i] = ch;
- }
- buf[NUM_PAGES] = 0;
- log("Completeness:[%s]", buf);
-}
-#endif
-
-static bool is_in_comma_separated_list(const char *value, const char *list)
-{
- if (!list)
- return false;
- unsigned len = strlen(value);
- while (*list)
- {
- const char *comma = strchrnul(list, ',');
- if ((comma - list == len) && strncmp(value, list, len) == 0)
- return true;
- if (!*comma)
- break;
- list = comma + 1;
- }
- return false;
-}
-
-static void on_page_prepare(GtkAssistant *assistant, GtkWidget *page, gpointer user_data)
-{
- //int page_no = gtk_assistant_get_current_page(g_assistant);
- //log_ready_state();
-
- /* This suppresses [Last] button: assistant thinks that
- * we never have this page ready unless we are on it
- * -> therefore there is at least one non-ready page
- * -> therefore it won't show [Last]
- */
- // Doesn't work: if Completeness:[++++++-+++],
- // then [Last] btn will still be shown.
- //gtk_assistant_set_page_complete(g_assistant,
- // pages[PAGENO_REVIEW_DATA].page_widget,
- // pages[PAGENO_REVIEW_DATA].page_widget == page
- //);
-
- if (pages[PAGENO_EDIT_BACKTRACE].page_widget == page)
- {
- check_bt_rating_and_allow_send();
- }
-
- /* Save text fields if changed */
- save_text_from_text_view(g_tv_backtrace, FILENAME_BACKTRACE);
- save_text_from_text_view(g_tv_comment, FILENAME_COMMENT);
-
- if (pages[PAGENO_SUMMARY].page_widget == page
- || pages[PAGENO_REVIEW_DATA].page_widget == page
- ) {
- GtkWidget *w = GTK_WIDGET(g_tv_details);
- GtkContainer *c = GTK_CONTAINER(gtk_widget_get_parent(w));
- if (c)
- gtk_container_remove(c, w);
- gtk_container_add(pages[PAGENO_SUMMARY].page_widget == page ?
- g_container_details1 : g_container_details2,
- w
- );
- /* Make checkbox column visible only on the last page */
- gtk_tree_view_column_set_visible(g_tv_details_col_checkbox,
- (pages[PAGENO_REVIEW_DATA].page_widget == page)
- );
- //gtk_cell_renderer_set_visible(g_tv_details_renderer_checkbox,
- // (pages[PAGENO_REVIEW_DATA].page_widget == page)
- //);
-
- if (pages[PAGENO_REVIEW_DATA].page_widget == page)
- {
- /* Based on selected reporter, update item checkboxes */
- event_config_t *cfg = get_event_config(g_reporter_events_selected ? g_reporter_events_selected : "");
- //log("%s: event:'%s', cfg:'%p'", __func__, g_reporter_events_selected, cfg);
- if (cfg)
- {
- /* Default settings are... */
- int allowed_by_reporter = 1;
- if (cfg->ec_exclude_items_always && strcmp(cfg->ec_exclude_items_always, "*") == 0)
- allowed_by_reporter = 0;
- int default_by_reporter = allowed_by_reporter;
- if (cfg->ec_exclude_items_by_default && strcmp(cfg->ec_exclude_items_by_default, "*") == 0)
- default_by_reporter = 0;
-
- GHashTableIter iter;
- char *name;
- struct problem_item *item;
- g_hash_table_iter_init(&iter, g_cd);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&item))
- {
- /* Decide whether item is allowed, required, and what's the default */
- item->allowed_by_reporter = allowed_by_reporter;
- if (is_in_comma_separated_list(name, cfg->ec_exclude_items_always))
- item->allowed_by_reporter = 0;
- if ((item->flags & CD_FLAG_BIN) && cfg->ec_exclude_binary_items)
- item->allowed_by_reporter = 0;
-
- item->default_by_reporter = item->allowed_by_reporter ? default_by_reporter : 0;
- if (is_in_comma_separated_list(name, cfg->ec_exclude_items_by_default))
- item->default_by_reporter = 0;
- if (is_in_comma_separated_list(name, cfg->ec_include_items_by_default))
- item->allowed_by_reporter = item->default_by_reporter = 1;
-
- item->required_by_reporter = 0;
- if (is_in_comma_separated_list(name, cfg->ec_requires_items))
- item->default_by_reporter = item->allowed_by_reporter = item->required_by_reporter = 1;
-
- int cur_value;
- if (item->selected_by_user == 0)
- cur_value = item->default_by_reporter;
- else
- cur_value = !!(item->selected_by_user + 1); /* map -1,1 to 0,1 */
-
- //log("%s: '%s' allowed:%d reqd:%d def:%d user:%d", __func__, name,
- // item->allowed_by_reporter,
- // item->required_by_reporter,
- // item->default_by_reporter,
- // item->selected_by_user
- //);
-
- /* Find corresponding line and update checkbox */
- GtkTreeIter iter;
- if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(g_ls_details), &iter))
- {
- do {
- gchar *item_name = NULL;
- gtk_tree_model_get(GTK_TREE_MODEL(g_ls_details), &iter,
- DETAIL_COLUMN_NAME, &item_name,
- -1);
- if (!item_name) /* paranoia, should never happen */
- continue;
- int differ = strcmp(name, item_name);
- g_free(item_name);
- if (differ)
- continue;
- gtk_list_store_set(g_ls_details, &iter,
- DETAIL_COLUMN_CHECKBOX, cur_value,
- -1);
- //log("%s: changed gtk_list_store_set to %d", __func__, (item->allowed_by_reporter && item->selected_by_user >= 0));
- break;
- } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(g_ls_details), &iter));
- }
- }
- }
- }
- }
-
- if (pages[PAGENO_EDIT_COMMENT].page_widget == page)
- on_comment_changed(gtk_text_view_get_buffer(g_tv_comment), NULL);
- //log_ready_state();
-}
-
-static gint select_next_page_no(gint current_page_no, gpointer data)
-{
- /* we don't need any magic here if we're in only-report mode */
- if (g_report_only)
- return current_page_no + 1;
-
- gint prev_page_no = current_page_no;
-
- again:
- current_page_no++;
-
- switch (current_page_no)
- {
-#if 0
- case PAGENO_EDIT_COMMENT:
- if (get_problem_item_content_or_NULL(g_cd, FILENAME_COMMENT))
- goto again; /* no comment, skip this page */
- break;
-#endif
-
- case PAGENO_EDIT_BACKTRACE:
- if (!get_problem_item_content_or_NULL(g_cd, FILENAME_BACKTRACE))
- goto again; /* no backtrace, skip this page */
- break;
-
- case PAGENO_ANALYZE_SELECTOR:
- if (!g_analyze_events[0] || g_black_event_count == 0)
- {
- /* skip analyze selector page and analyze log page */
- current_page_no = PAGENO_REPORTER_SELECTOR-1;
- goto again;
- }
- break;
-
- case PAGENO_ANALYZE_PROGRESS:
- VERB2 log("%s: ANALYZE_PROGRESS: g_analyze_event_selected:'%s'",
- __func__, g_analyze_event_selected);
- if (!g_analyze_event_selected || !g_analyze_event_selected[0])
- goto again; /* skip this page */
- break;
-
- case PAGENO_REPORTER_SELECTOR:
- VERB2 log("%s: REPORTER_SELECTOR: g_black_event_count:%d",
- __func__, g_black_event_count);
- /* if we _did_ run an event (didn't skip it)
- * and still have analyzers which didn't run
- */
- if (prev_page_no == PAGENO_ANALYZE_PROGRESS
- && g_black_event_count != 0
- ) {
- /* Go back to analyzer selectors */
- current_page_no = PAGENO_ANALYZE_SELECTOR-1;
- goto again;
- }
- break;
- case PAGENO_NOT_SHOWN:
- /* No! this would SEGV (infinitely recurse into select_next_page_no) */
- /*gtk_assistant_commit(g_assistant);*/
- current_page_no = PAGENO_ANALYZE_SELECTOR-1;
- goto again;
- }
-
- VERB2 log("%s: selected page #%d", __func__, current_page_no);
- return current_page_no;
-}
-
-
-static gboolean highlight_search(gpointer user_data)
-{
- GtkEntry *entry = GTK_ENTRY(user_data);
- GtkTextBuffer *buffer = gtk_text_view_get_buffer(g_tv_backtrace);
- GtkTextIter start_find;
- GtkTextIter end_find;
- GtkTextIter start_match;
- GtkTextIter end_match;
- int offset = 0;
-
- gtk_text_buffer_get_start_iter(buffer, &start_find);
- gtk_text_buffer_get_end_iter(buffer, &end_find);
- gtk_text_buffer_remove_tag_by_name(buffer, "search_result_bg", &start_find, &end_find);
- VERB1 log("searching: %s", gtk_entry_get_text(entry));
- while (gtk_text_iter_forward_search(&start_find, gtk_entry_get_text(entry),
- GTK_TEXT_SEARCH_TEXT_ONLY, &start_match,
- &end_match, NULL))
- {
- gtk_text_buffer_apply_tag_by_name(buffer, "search_result_bg",
- &start_match, &end_match);
- offset = gtk_text_iter_get_offset(&end_match);
- gtk_text_buffer_get_iter_at_offset(buffer, &start_find, offset);
- }
-
- /* returning false will make glib to remove this event */
- return false;
-}
-
-static void search_timeout(GtkEntry *entry)
-{
- /* this little hack makes the search start searching after 500 milisec after
- * user stops writing into entry box
- * if this part is removed, then the search will be started on every
- * change of the search entry
- */
- if (g_timeout != 0)
- g_source_remove(g_timeout);
- g_timeout = g_timeout_add(500, &highlight_search, (gpointer)entry);
-}
-
-
-/* Initialization */
-
-/* wizard.glade file as a string WIZARD_GLADE_CONTENTS: */
-#include "wizard_glade.c"
-
-static void add_pages()
-{
- GError *error = NULL;
- if (!g_glade_file)
- {
- /* Load UI from internal string */
- gtk_builder_add_objects_from_string(builder,
- WIZARD_GLADE_CONTENTS, sizeof(WIZARD_GLADE_CONTENTS) - 1,
- (gchar**)page_names,
- &error);
- if (error != NULL)
- error_msg_and_die("Error loading glade data: %s", error->message);
- }
- else
- {
- /* -g FILE: load IU from it */
- gtk_builder_add_objects_from_file(builder, g_glade_file, (gchar**)page_names, &error);
- if (error != NULL)
- error_msg_and_die("Can't load %s: %s", g_glade_file, error->message);
- }
-
- int i;
- int page_no = 0;
- for (i = 0; page_names[i] != NULL; i++)
- {
- char *delim = strrchr(page_names[i], '_');
- if (delim != NULL)
- {
- if (g_report_only && (strncmp(delim + 1, "report", strlen("report"))) != 0)
- {
- pages[i].page_widget = NULL;
- continue;
- }
- }
- GtkWidget *page = GTK_WIDGET(gtk_builder_get_object(builder, page_names[i]));
-
- pages[i].page_widget = page;
- added_pages[page_no++] = &pages[i];
-
- gtk_assistant_append_page(g_assistant, page);
- /* If we set all pages to complete the wizard thinks there is nothing
- * to do and shows the button "Last" which allows user to skip all pages
- * so we need to set them all as incomplete and complete them one by one
- * on proper place - on_page_prepare() ?
- */
- gtk_assistant_set_page_complete(g_assistant, page, true);
-
- gtk_assistant_set_page_title(g_assistant, page, pages[i].title);
- gtk_assistant_set_page_type(g_assistant, page, pages[i].type);
-
- VERB1 log("added page: %s", page_names[i]);
- }
-
- /* Set pointers to objects we might need to work with */
- g_lbl_cd_reason = GTK_LABEL( gtk_builder_get_object(builder, "lbl_cd_reason"));
- g_box_analyzers = GTK_BOX( gtk_builder_get_object(builder, "vb_analyzers"));
- g_lbl_analyze_log = GTK_LABEL( gtk_builder_get_object(builder, "lbl_analyze_log"));
- g_tv_analyze_log = GTK_TEXT_VIEW( gtk_builder_get_object(builder, "tv_analyze_log"));
- g_box_reporters = GTK_BOX( gtk_builder_get_object(builder, "vb_reporters"));
- g_lbl_report_log = GTK_LABEL( gtk_builder_get_object(builder, "lbl_report_log"));
- g_tv_report_log = GTK_TEXT_VIEW( gtk_builder_get_object(builder, "tv_report_log"));
- g_tv_backtrace = GTK_TEXT_VIEW( gtk_builder_get_object(builder, "tv_backtrace"));
- g_tv_comment = GTK_TEXT_VIEW( gtk_builder_get_object(builder, "tv_comment"));
- g_eb_comment = GTK_EVENT_BOX( gtk_builder_get_object(builder, "eb_comment"));
- g_tv_details = GTK_TREE_VIEW( gtk_builder_get_object(builder, "tv_details"));
- g_box_warning_labels = GTK_BOX( gtk_builder_get_object(builder, "box_warning_labels"));
- g_tb_approve_bt = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "cb_approve_bt"));
- g_widget_warnings_area = GTK_WIDGET( gtk_builder_get_object(builder, "box_warning_area"));
- g_btn_refresh = GTK_BUTTON( gtk_builder_get_object(builder, "btn_refresh"));
- g_search_entry_bt = GTK_ENTRY( gtk_builder_get_object(builder, "entry_search_bt"));
- g_container_details1 = GTK_CONTAINER( gtk_builder_get_object(builder, "container_details1"));
- g_container_details2 = GTK_CONTAINER( gtk_builder_get_object(builder, "container_details2"));
- g_lbl_reporters = GTK_LABEL( gtk_builder_get_object(builder, "lbl_reporters"));
- g_lbl_size = GTK_LABEL( gtk_builder_get_object(builder, "lbl_size"));
-
- gtk_widget_modify_font(GTK_WIDGET(g_tv_analyze_log), monospace_font);
- gtk_widget_modify_font(GTK_WIDGET(g_tv_report_log), monospace_font);
- gtk_widget_modify_font(GTK_WIDGET(g_tv_backtrace), monospace_font);
- fix_all_wrapped_labels(GTK_WIDGET(g_assistant));
-
- if (pages[PAGENO_EDIT_BACKTRACE].page_widget != NULL)
- gtk_assistant_set_page_complete(g_assistant, pages[PAGENO_EDIT_BACKTRACE].page_widget,
- gtk_toggle_button_get_active(g_tb_approve_bt));
-
- /* Configure btn on select analyzers page */
- GtkWidget *config_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button_cfg1"));
- if (config_btn)
- g_signal_connect(G_OBJECT(config_btn), "clicked", G_CALLBACK(on_show_event_list_cb), NULL);
-
- /* Configure btn on select reporters page */
- config_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button_cfg2"));
- if (config_btn)
- g_signal_connect(G_OBJECT(config_btn), "clicked", G_CALLBACK(on_show_event_list_cb), NULL);
-
- /* Add "Close" button */
- GtkWidget *w;
- w = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
- g_signal_connect(w, "clicked", G_CALLBACK(gtk_main_quit), NULL);
- gtk_widget_show(w);
- gtk_assistant_add_action_widget(g_assistant, w);
- /* and hide "Cancel" button - "Close" is a better name for what we want */
- gtk_assistant_commit(g_assistant);
-
- /* Set color of the comment evenbox */
- GdkColor color;
- gdk_color_parse("#CC3333", &color);
- gtk_widget_modify_bg(GTK_WIDGET(g_eb_comment), GTK_STATE_NORMAL, &color);
-}
-
-static void create_details_treeview()
-{
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- //g_tv_details_renderer_checkbox =
- renderer = gtk_cell_renderer_toggle_new();
- g_tv_details_col_checkbox = column = gtk_tree_view_column_new_with_attributes(
- _("Include"), renderer,
- /* which "attr" of renderer to set from which COLUMN? (can be repeated) */
- "active", DETAIL_COLUMN_CHECKBOX,
- NULL);
- gtk_tree_view_append_column(g_tv_details, column);
- /* This column has a handler */
- g_signal_connect(renderer, "toggled", G_CALLBACK(g_tv_details_checkbox_toggled), NULL);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(
- _("Name"), renderer,
- "text", DETAIL_COLUMN_NAME,
- NULL);
- gtk_tree_view_append_column(g_tv_details, column);
-
- g_tv_details_renderer_value = renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(
- _("Value"), renderer,
- "text", DETAIL_COLUMN_VALUE,
- NULL);
- gtk_tree_view_append_column(g_tv_details, column);
-
- /*
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(
- _("Path"), renderer,
- "text", DETAIL_COLUMN_PATH,
- NULL);
- gtk_tree_view_append_column(g_tv_details, column);
- */
-
- gtk_tree_view_column_set_sort_column_id(column, DETAIL_COLUMN_NAME);
-
- g_ls_details = gtk_list_store_new(DETAIL_NUM_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
- gtk_tree_view_set_model(g_tv_details, GTK_TREE_MODEL(g_ls_details));
-
- g_signal_connect(g_tv_details, "row-activated", G_CALLBACK(tv_details_row_activated), NULL);
- g_signal_connect(g_tv_details, "cursor-changed", G_CALLBACK(tv_details_cursor_changed), NULL);
- /* [Enter] on a row:
- * g_signal_connect(g_tv_details, "select-cursor-row", G_CALLBACK(tv_details_select_cursor_row), NULL);
- */
-}
-
-void create_assistant(void)
-{
- monospace_font = pango_font_description_from_string("monospace");
-
- builder = gtk_builder_new();
-
- g_assistant = GTK_ASSISTANT(gtk_assistant_new());
-
- gtk_assistant_set_forward_page_func(g_assistant, select_next_page_no, NULL, NULL);
-
- GtkWindow *wnd_assistant = GTK_WINDOW(g_assistant);
- g_parent_window = wnd_assistant;
- gtk_window_set_default_size(wnd_assistant, DEFAULT_WIDTH, DEFAULT_HEIGHT);
- /* set_default sets icon for every windows used in this app, so we don't
- * have to set the icon for those windows manually
- */
- gtk_window_set_default_icon_name("abrt");
-
- GObject *obj_assistant = G_OBJECT(g_assistant);
- g_signal_connect(obj_assistant, "cancel", G_CALLBACK(gtk_main_quit), NULL);
- g_signal_connect(obj_assistant, "close", G_CALLBACK(gtk_main_quit), NULL);
- g_signal_connect(obj_assistant, "apply", G_CALLBACK(next_page), NULL);
- g_signal_connect(obj_assistant, "prepare", G_CALLBACK(on_page_prepare), NULL);
-
- add_pages();
-
- create_details_treeview();
-
- g_signal_connect(g_tb_approve_bt, "toggled", G_CALLBACK(on_bt_approve_toggle), NULL);
- g_signal_connect(g_btn_refresh, "clicked", G_CALLBACK(on_btn_refresh_clicked), NULL);
- g_signal_connect(gtk_text_view_get_buffer(g_tv_comment), "changed", G_CALLBACK(on_comment_changed), NULL);
-
- /* init searching */
- GtkTextBuffer *backtrace_buf = gtk_text_view_get_buffer(g_tv_backtrace);
- /* found items background */
- gtk_text_buffer_create_tag(backtrace_buf, "search_result_bg", "background", "red", NULL);
- g_signal_connect(g_search_entry_bt, "changed", G_CALLBACK(search_timeout), NULL);
-}
diff --git a/libreport/src/gui-wizard-gtk/wizard.glade b/libreport/src/gui-wizard-gtk/wizard.glade
deleted file mode 100644
index 49acd67d..00000000
--- a/libreport/src/gui-wizard-gtk/wizard.glade
+++ /dev/null
@@ -1,801 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <requires lib="gtk+" version="2.16"/>
- <object class="GtkWindow" id="window0">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_0">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">3</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="lbl_cd_reason">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="wrap">True</property>
- <attributes>
- <attribute name="style" value="normal"/>
- <attribute name="weight" value="bold"/>
- <attribute name="foreground" value="#ffff00000000"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label7">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">On the following screens, you will be asked to describe how the problem occurred, to choose how to analyze the problem (if needed), to review collected data, and to choose where the problem should be reported. Click 'Forward' to proceed.</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkExpander" id="expander1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <child>
- <object class="GtkScrolledWindow" id="container_details1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">GTK_SHADOW_OUT</property>
- <child>
- <object class="GtkTreeView" id="tv_details">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="dump_elements">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Details</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window1">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">How did this problem happen (step-by-step)? How can it be reproduced? Any additional comments useful for diagnosing the problem?</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow4">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="shadow_type">GTK_SHADOW_OUT</property>
- <child>
- <object class="GtkTextView" id="tv_comment">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="wrap_mode">word</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEventBox" id="eb_comment">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">You need to fill the how to before you can proceed...</property>
- <property name="single_line_mode">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">&lt;b&gt;Your comments are not private.&lt;/b&gt; They may be included into publicly visible problem reports.</property>
- <property name="use_markup">True</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window2">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="lbl_page5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Select how you would like to analyze the problem:</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vb_analyzers">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkButton" id="button_cfg1">
- <property name="label" translatable="yes">Configure _Events</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="image_position">right</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window3">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="lbl_analyze_log">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Analyzing did not start yet</property>
- <property name="use_markup">True</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">GTK_SHADOW_OUT</property>
- <child>
- <object class="GtkTextView" id="tv_analyze_log">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="accepts_tab">False</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window4">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_4_report">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="lbl_page3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Select how you would like to report the problem:</property>
- <property name="use_markup">True</property>
- <property name="justify">fill</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vb_reporters">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkButton" id="button_cfg2">
- <property name="label" translatable="yes">Configure _Events</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="image_position">right</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window5">
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Use this button to generate more informative backtrace after you installed additional debug packages</property>
- <child>
- <object class="GtkVBox" id="page_5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="lbl_page4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Backtrace provides developers with details of the crash, helping them track down the source of the problem. Please review it and remove any sensitive data you would rather not share:</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">GTK_SHADOW_OUT</property>
- <child>
- <object class="GtkTextView" id="tv_backtrace">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="wrap_mode">word</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <child>
- <object class="GtkHBox" id="box_warning_area">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <child>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-dialog-warning</property>
- <property name="icon-size">6</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkAlignment" id="alignment1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="box_warning_labels">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkEntry" id="entry_search_bt">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="secondary_icon_stock">gtk-find</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="btn_refresh">
- <property name="label" translatable="yes">Regenerate backtrace</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Can create more informative backtrace if you installed additional debug packages</property>
- <property name="use_action_appearance">False</property>
- <signal name="clicked" handler="on_b_refresh_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="cb_approve_bt">
- <property name="label" translatable="yes">I _agree with submitting the backtrace</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window6">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_6_report">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="lbl_page6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Click 'Apply' to start reporting</property>
- <property name="justify">fill</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">10</property>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Size:</property>
- <property name="justify">right</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label8">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Reporter(s):</property>
- <property name="justify">right</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="lbl_reporters">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="lbl_size">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="container_details2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">GTK_SHADOW_OUT</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window7">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_7_report">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="lbl_report_log">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Reporting did not start yet</property>
- <property name="use_markup">True</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow6">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">GTK_SHADOW_OUT</property>
- <child>
- <object class="GtkTextView" id="tv_report_log">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="accepts_tab">False</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window8">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_8_report">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Reporting has finished. You can close this window now.</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">If you want to report the problem to a different destination, collect additional information, or provide a better problem description and repeat reporting process, press 'Forward'.</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- </object>
- <object class="GtkWindow" id="window9">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="page_9_report">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">3</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- </object>
-</interface>
diff --git a/libreport/src/gui-wizard-gtk/wizard.h b/libreport/src/gui-wizard-gtk/wizard.h
deleted file mode 100644
index 84e64380..00000000
--- a/libreport/src/gui-wizard-gtk/wizard.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "libreport-gtk.h"
-
-void create_assistant(void);
-void update_gui_state_from_problem_data(void);
-void show_error_as_msgbox(const char *msg);
-
-
-extern char *g_glade_file;
-extern char *g_dump_dir_name;
-extern char *g_analyze_events;
-extern char *g_report_events;
-extern problem_data_t *g_cd;
-extern int g_report_only;
-void reload_problem_data_from_dump_dir(void);
diff --git a/libreport/src/include/Makefile.am b/libreport/src/include/Makefile.am
deleted file mode 100644
index f2afd2c3..00000000
--- a/libreport/src/include/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-libreport_includedir = $(includedir)/libreport
-libreport_include_HEADERS = \
- abrt_dbus.h \
- dump_dir.h \
- event_config.h \
- hash_sha1.h \
- libreport.h \
- libreport_problem_data.h \
- libreport_types.h \
- logging.h \
- parse_options.h \
- problem_data.h \
- read_write.h \
- report.h \
- run_event.h \
- strbuf.h \
- xfuncs.h \ No newline at end of file
diff --git a/libreport/src/include/abrt_dbus.h b/libreport/src/include/abrt_dbus.h
deleted file mode 100644
index efa70472..00000000
--- a/libreport/src/include/abrt_dbus.h
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef ABRT_DBUS_H
-#define ABRT_DBUS_H
-
-#include <dbus/dbus.h>
-#include "libreport.h"
-
-
-#define ABRTD_DBUS_NAME "com.redhat.abrt"
-#define ABRTD_DBUS_PATH "/com/redhat/abrt"
-#define ABRTD_DBUS_IFACE "com.redhat.abrt"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern DBusConnection* g_dbus_conn;
-
-/*
- * Glib integration machinery
- */
-
-/* Hook up to DBus and to glib main loop.
- * Usage cases:
- *
- * - server:
- * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err);
- * attach_dbus_conn_to_glib_main_loop(conn, "/some/path", handler_of_calls_to_some_path);
- * rc = dbus_bus_request_name(conn, "server.name", DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
- *
- * - client which does not receive signals (only makes calls and emits signals):
- * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err);
- * // needed only if you need to use async dbus calls (not shown below):
- * attach_dbus_conn_to_glib_main_loop(conn, NULL, NULL);
- * // synchronous method call:
- * msg = dbus_message_new_method_call("some.serv", "/path/on/serv", "optional.iface.on.serv", "method_name");
- * reply = dbus_connection_send_with_reply_and_block(conn, msg, timeout, &err);
- * // emitting signal:
- * msg = dbus_message_new_signal("/path/sig/emitted/from", "iface.sig.emitted.from", "sig_name");
- * // (note: "iface.sig.emitted.from" is not optional for signals!)
- * dbus_message_set_destination(msg, "peer"); // optional
- * dbus_connection_send(conn, msg, &serial); // &serial can be NULL
- * dbus_connection_unref(conn); // if you don't want to *stay* connected
- *
- * - client which receives and processes signals:
- * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err);
- * attach_dbus_conn_to_glib_main_loop(conn, NULL, NULL);
- * dbus_connection_add_filter(conn, handle_message, NULL, NULL)
- * dbus_bus_add_match(system_conn, "type='signal',...", &err);
- * // signal is a dbus message which looks like this:
- * // sender=XXX dest=YYY(or null) path=/path/sig/emitted/from interface=iface.sig.emitted.from member=sig_name
- * // and handler_for_signals(conn,msg,opaque) will be called by glib
- * // main loop to process received signals (and other messages
- * // if you ask for them in dbus_bus_add_match[es], but this
- * // would turn you into a server if you handle them too) ;]
- */
-void attach_dbus_conn_to_glib_main_loop(DBusConnection* conn,
- /* NULL if you are just a client */
- const char* object_path_to_register,
- /* makes sense only if you use object_path_to_register: */
- DBusHandlerResult (*message_received_func)(DBusConnection *conn, DBusMessage *msg, void* data)
-);
-
-/* Log dbus error if err has it set. Then log msg if it's !NULL.
- * In both cases return 1. Otherwise return 0.
- */
-int log_dbus_error(const char *msg, DBusError *err);
-
-/* Perform "DeleteDebugDump" call over g_dbus_conn */
-int32_t call_DeleteDebugDump(const char *dump_dir_name);
-
-/* Connect to system bus, find abrtd, perform "DeleteDebugDump" call, close g_dbus_conn */
-/* now static: int connect_to_abrtd_and_call_DeleteDebugDump(const char *dump_dir_name); */
-int delete_dump_dir_possibly_using_abrtd(const char *dump_dir_name);
-
-
-/*
- * Helpers for building DBus messages
- */
-//void store_bool(DBusMessageIter* iter, bool val);
-void store_int32(DBusMessageIter* iter, int32_t val);
-void store_uint32(DBusMessageIter* iter, uint32_t val);
-void store_int64(DBusMessageIter* iter, int64_t val);
-void store_uint64(DBusMessageIter* iter, uint64_t val);
-void store_string(DBusMessageIter* iter, const char* val);
-
-/*
- * Helpers for parsing DBus messages
- */
-enum {
- ABRT_DBUS_ERROR = -1,
- ABRT_DBUS_LAST_FIELD = 0,
- ABRT_DBUS_MORE_FIELDS = 1,
- /* note that dbus_message_iter_next() returns FALSE on last field
- * and TRUE if there are more fields.
- * It maps exactly on the above constants. */
-};
-/* Checks type, loads data, advances to the next arg.
- * Returns TRUE if next arg exists.
- */
-//int load_bool(DBusMessageIter* iter, bool& val);
-int load_int32(DBusMessageIter* iter, int32_t *val);
-int load_uint32(DBusMessageIter* iter, uint32_t *val);
-int load_int64(DBusMessageIter* iter, int64_t *val);
-int load_uint64(DBusMessageIter* iter, uint64_t *val);
-int load_charp(DBusMessageIter* iter, const char **val);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/*
- * C++ style stuff
- */
-
-#ifdef __cplusplus
-
-#include <map>
-#include <vector>
-
-/*
- * Helpers for building DBus messages
- */
-
-static inline std::string ssprintf(const char *format, ...)
-{
- va_list p;
- char *string_ptr;
-
- va_start(p, format);
- string_ptr = xvasprintf(format, p);
- va_end(p);
-
- std::string res = string_ptr;
- free(string_ptr);
- return res;
-}
-
-//static inline void store_val(DBusMessageIter* iter, bool val) { store_bool(iter, val); }
-static inline void store_val(DBusMessageIter* iter, int32_t val) { store_int32(iter, val); }
-static inline void store_val(DBusMessageIter* iter, uint32_t val) { store_uint32(iter, val); }
-static inline void store_val(DBusMessageIter* iter, int64_t val) { store_int64(iter, val); }
-static inline void store_val(DBusMessageIter* iter, uint64_t val) { store_uint64(iter, val); }
-static inline void store_val(DBusMessageIter* iter, const char* val) { store_string(iter, val); }
-static inline void store_val(DBusMessageIter* iter, const std::string& val) { store_string(iter, val.c_str()); }
-
-/* Templates for vector and map */
-template <typename T> struct abrt_dbus_type {};
-//template <> struct abrt_dbus_type<bool> { static const char* csig() { return "b"; } };
-template <> struct abrt_dbus_type<int32_t> { static const char* csig() { return "i"; } static std::string sig(); };
-template <> struct abrt_dbus_type<uint32_t> { static const char* csig() { return "u"; } static std::string sig(); };
-template <> struct abrt_dbus_type<int64_t> { static const char* csig() { return "x"; } static std::string sig(); };
-template <> struct abrt_dbus_type<uint64_t> { static const char* csig() { return "t"; } static std::string sig(); };
-template <> struct abrt_dbus_type<std::string> { static const char* csig() { return "s"; } static std::string sig(); };
-#define ABRT_DBUS_SIG(T) (abrt_dbus_type<T>::csig() ? abrt_dbus_type<T>::csig() : abrt_dbus_type<T>::sig().c_str())
-template <typename E>
-struct abrt_dbus_type< std::vector<E> > {
- static const char* csig() { return NULL; }
- static std::string sig() { return ssprintf("a%s", ABRT_DBUS_SIG(E)); }
-};
-template <typename K, typename V>
-struct abrt_dbus_type< std::map<K,V> > {
- static const char* csig() { return NULL; }
- static std::string sig() { return ssprintf("a{%s%s}", ABRT_DBUS_SIG(K), ABRT_DBUS_SIG(V)); }
-};
-
-template <typename E>
-static void store_vector(DBusMessageIter* iter, const std::vector<E>& val)
-{
- DBusMessageIter sub_iter;
- if (!dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, ABRT_DBUS_SIG(E), &sub_iter))
- die_out_of_memory();
-
- typename std::vector<E>::const_iterator vit = val.begin();
- for (; vit != val.end(); ++vit)
- {
- store_val(&sub_iter, *vit);
- }
-
- if (!dbus_message_iter_close_container(iter, &sub_iter))
- die_out_of_memory();
-}
-/*
-template<>
-static void store_vector(DBus::MessageIter &iter, const std::vector<uint8_t>& val)
-{
- if we use such vector, MUST add specialized code here (see in dbus-c++ source)
-}
-*/
-template <typename K, typename V>
-static void store_map(DBusMessageIter* iter, const std::map<K,V>& val)
-{
- DBusMessageIter sub_iter;
- if (!dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
- ssprintf("{%s%s}", ABRT_DBUS_SIG(K), ABRT_DBUS_SIG(V)).c_str(),
- &sub_iter))
- die_out_of_memory();
-
- typename std::map<K,V>::const_iterator mit = val.begin();
- for (; mit != val.end(); ++mit)
- {
- DBusMessageIter sub_sub_iter;
- if (!dbus_message_iter_open_container(&sub_iter, DBUS_TYPE_DICT_ENTRY, NULL, &sub_sub_iter))
- die_out_of_memory();
- store_val(&sub_sub_iter, mit->first);
- store_val(&sub_sub_iter, mit->second);
- if (!dbus_message_iter_close_container(&sub_iter, &sub_sub_iter))
- die_out_of_memory();
- }
-
- if (!dbus_message_iter_close_container(iter, &sub_iter))
- die_out_of_memory();
-}
-
-template <typename E>
-static inline void store_val(DBusMessageIter* iter, const std::vector<E>& val) { store_vector(iter, val); }
-template <typename K, typename V>
-static inline void store_val(DBusMessageIter* iter, const std::map<K,V>& val) { store_map(iter, val); }
-
-
-/*
- * Helpers for parsing DBus messages
- */
-
-//static inline int load_val(DBusMessageIter* iter, bool &val) { return load_bool(iter, &val); }
-static inline int load_val(DBusMessageIter* iter, int32_t &val) { return load_int32(iter, &val); }
-static inline int load_val(DBusMessageIter* iter, uint32_t &val) { return load_uint32(iter, &val); }
-static inline int load_val(DBusMessageIter* iter, int64_t &val) { return load_int64(iter, &val); }
-static inline int load_val(DBusMessageIter* iter, uint64_t &val) { return load_uint64(iter, &val); }
-static inline int load_val(DBusMessageIter* iter, const char*& val) { return load_charp(iter, &val); }
-static inline int load_val(DBusMessageIter* iter, std::string& val)
-{
- const char* str;
- int r = load_charp(iter, &str);
- val = str;
- return r;
-}
-
-/* Templates for vector and map */
-template <typename E>
-static int load_vector(DBusMessageIter* iter, std::vector<E>& val)
-{
- int type = dbus_message_iter_get_arg_type(iter);
- if (type != DBUS_TYPE_ARRAY)
- {
- error_msg("array expected in dbus message, but not found ('%c')", type);
- return -1;
- }
-
- DBusMessageIter sub_iter;
- dbus_message_iter_recurse(iter, &sub_iter);
-
- int r;
-//int cnt = 0;
- /* When the vector has 0 elements, we see DBUS_TYPE_INVALID here */
- type = dbus_message_iter_get_arg_type(&sub_iter);
- if (type != DBUS_TYPE_INVALID)
- {
- do {
- E elem;
-//cnt++;
- r = load_val(&sub_iter, elem);
- if (r < 0)
- return r;
- val.push_back(elem);
- } while (r == ABRT_DBUS_MORE_FIELDS);
- }
-//log("%s: %d elems", __func__, cnt);
-
- return dbus_message_iter_next(iter);
-}
-/*
-template<>
-static int load_vector(DBusMessageIter* iter, std::vector<uint8_t>& val)
-{
- if we use such vector, MUST add specialized code here (see in dbus-c++ source)
-}
-*/
-template <typename K, typename V>
-static int load_map(DBusMessageIter* iter, std::map<K,V>& val)
-{
- int type = dbus_message_iter_get_arg_type(iter);
- if (type != DBUS_TYPE_ARRAY)
- {
- error_msg("array expected in dbus message, but not found ('%c')", type);
- return -1;
- }
-
- DBusMessageIter sub_iter;
- dbus_message_iter_recurse(iter, &sub_iter);
-
- bool next_exists;
- int r;
-//int cnt = 0;
- do {
- type = dbus_message_iter_get_arg_type(&sub_iter);
- if (type != DBUS_TYPE_DICT_ENTRY)
- {
- /* When the map has 0 elements, we see DBUS_TYPE_INVALID (on the first iteration) */
- if (type == DBUS_TYPE_INVALID)
- break;
- error_msg("sub_iter type is not DBUS_TYPE_DICT_ENTRY (%c)!", type);
- return -1;
- }
-
- DBusMessageIter sub_sub_iter;
- dbus_message_iter_recurse(&sub_iter, &sub_sub_iter);
-
- K key;
- r = load_val(&sub_sub_iter, key);
- if (r != ABRT_DBUS_MORE_FIELDS)
- {
- if (r == ABRT_DBUS_LAST_FIELD)
- error_msg("malformed map element in dbus message");
- return -1;
- }
- V value;
- r = load_val(&sub_sub_iter, value);
- if (r != ABRT_DBUS_LAST_FIELD)
- {
- if (r == ABRT_DBUS_MORE_FIELDS)
- error_msg("malformed map element in dbus message");
- return -1;
- }
- val[key] = value;
-//cnt++;
- next_exists = dbus_message_iter_next(&sub_iter);
- } while (next_exists);
-//log("%s: %d elems", __func__, cnt);
-
- return dbus_message_iter_next(iter);
-}
-
-template <typename E>
-static inline int load_val(DBusMessageIter* iter, std::vector<E>& val) { return load_vector(iter, val); }
-template <typename K, typename V>
-static inline int load_val(DBusMessageIter* iter, std::map<K,V>& val) { return load_map(iter, val); }
-
-#endif /* __cplusplus */
-
-#endif
diff --git a/libreport/src/include/dump_dir.h b/libreport/src/include/dump_dir.h
deleted file mode 100644
index c88ebe7f..00000000
--- a/libreport/src/include/dump_dir.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- On-disk storage of problem data
-
- Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef DUMP_DIR_H_
-#define DUMP_DIR_H_
-
-/* For DIR */
-#include <sys/types.h>
-#include <dirent.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum {
- DD_FAIL_QUIETLY_ENOENT = (1 << 0),
- DD_FAIL_QUIETLY_EACCES = (1 << 1),
- DD_OPEN_READONLY = (1 << 2),
-};
-
-struct dump_dir {
- char *dd_dirname;
- DIR *next_dir;
- int locked;
- uid_t dd_uid;
- gid_t dd_gid;
- /* mode fo saved files */
- mode_t mode;
-};
-
-void dd_close(struct dump_dir *dd);
-
-struct dump_dir *dd_opendir(const char *dir, int flags);
-/* Pass uid = (uid_t)-1L to disable chown'ing of newly created files
- * (IOW: if you aren't running under root):
- */
-struct dump_dir *dd_create(const char *dir, uid_t uid, mode_t mode);
-
-void dd_create_basic_files(struct dump_dir *dd, uid_t uid);
-int dd_exist(struct dump_dir *dd, const char *path);
-void dd_sanitize_mode_and_owner(struct dump_dir *dd);
-
-DIR *dd_init_next_file(struct dump_dir *dd);
-int dd_get_next_file(struct dump_dir *dd, char **short_name, char **full_name);
-
-enum {
- /* DD_FAIL_QUIETLY_ENOENT bit is valid for dd_load_text_ext too, */
- DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (DD_OPEN_READONLY << 1),
-};
-char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned flags);
-char* dd_load_text(const struct dump_dir *dd, const char *name);
-void dd_save_text(struct dump_dir *dd, const char *name, const char *data);
-void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size);
-/* Returns 0 if directory is deleted or not found */
-int dd_delete(struct dump_dir *dd);
-
-void delete_dump_dir(const char *dirname);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/event_config.h b/libreport/src/include/event_config.h
deleted file mode 100644
index cdac4083..00000000
--- a/libreport/src/include/event_config.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- Copyright (C) 2011 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include <glib.h>
-
-#ifndef EVENT_CONFIG_H
-#define EVENT_CONFIG_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum
-{
- OPTION_TYPE_TEXT,
- OPTION_TYPE_BOOL,
- OPTION_TYPE_PASSWORD,
- OPTION_TYPE_NUMBER,
- OPTION_TYPE_HINT_HTML,
- OPTION_TYPE_INVALID,
-} option_type_t;
-
-/*
- * struct to hold information about config options
- * it's supposed to hold information about:
- * type -> which designates the widget used to display it and we can do some test based on the type
- * label
- * allowed value(s) -> regexp?
- * name -> env variable name
- * value -> value retrieved from the gui, so when we want to set the env
- * evn variables, we can just traverse the list of the options
- * and set the env variables according to name:value in this structure
- */
-typedef struct
-{
- char *eo_name; //name of the value which should be used for env variable
- char *eo_value;
- char *eo_label;
- char *eo_note_html;
- option_type_t eo_type;
- int eo_allow_empty;
- //char *description; //can be used as tooltip in gtk app
- //char *allowed_value;
- //int required;
-} event_option_t;
-
-event_option_t *new_event_option(void);
-void free_event_option(event_option_t *p);
-
-//structure to hold the option data
-typedef struct
-{
- char *screen_name; //ui friendly name of the event: "Bugzilla" "RedHat Support Upload"
- char *description; // "Report to..."/"Save to file". Should be one sentence, not long
- char *long_descr; // Long(er) explanation, if needed
-
- char *ec_creates_items;
- char *ec_requires_items;
- char *ec_exclude_items_by_default;
- char *ec_include_items_by_default;
- char *ec_exclude_items_always;
- bool ec_exclude_binary_items;
-
- GList *options;
-} event_config_t;
-
-event_config_t *new_event_config(void);
-void free_event_config(event_config_t *p);
-
-
-void load_event_description_from_file(event_config_t *event_config, const char* filename);
-
-// (Re)loads data from /etc/abrt/events/*.{conf,xml}
-void load_event_config_data(void);
-/* Frees all loaded data */
-void free_event_config_data(void);
-event_config_t *get_event_config(const char *event_name);
-event_option_t *get_event_option_from_list(const char *option_name, GList *event_options);
-
-extern GHashTable *g_event_config_list; // for iterating through entire list of all loaded configs
-
-GList *export_event_config(const char *event_name);
-void unexport_event_config(GList *env_list);
-
-GHashTable *validate_event(const char *event_name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/hash_sha1.h b/libreport/src/include/hash_sha1.h
deleted file mode 100644
index 7299608b..00000000
--- a/libreport/src/include/hash_sha1.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Based on shasum from http://www.netsw.org/crypto/hash/
- * Majorly hacked up to use Dr Brian Gladman's sha1 code
- *
- * Copyright (C) 2002 Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
- * Copyright (C) 2003 Glenn L. McGrath
- * Copyright (C) 2003 Erik Andersen
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * ---------------------------------------------------------------------------
- * Issue Date: 10/11/2002
- *
- * This is a byte oriented version of SHA1 that operates on arrays of bytes
- * stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef HASH_SHA1_H
-#define HASH_SHA1_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SHA1_RESULT_LEN (5 * 4)
-
-typedef struct sha1_ctx_t {
- uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */
- /* for sha256: void (*process_block)(struct md5_ctx_t*); */
- uint64_t total64; /* must be directly before hash[] */
- uint32_t hash[8]; /* 4 elements for md5, 5 for sha1, 8 for sha256 */
-} sha1_ctx_t;
-
-#define sha1_begin abrt_sha1_begin
-void sha1_begin(sha1_ctx_t *ctx);
-#define sha1_hash abrt_sha1_hash
-void sha1_hash(sha1_ctx_t *ctx, const void *buffer, size_t len);
-#define sha1_end abrt_sha1_end
-void sha1_end(sha1_ctx_t *ctx, void *resbuf);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/libreport.h b/libreport/src/include/libreport.h
deleted file mode 100644
index cd8a5cb9..00000000
--- a/libreport/src/include/libreport.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#ifndef LIBREPORT_H_
-#define LIBREPORT_H_
-
-#include <assert.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/poll.h>
-#include <sys/mman.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <arpa/inet.h> /* sockaddr_in, sockaddr_in6 etc */
-#include <termios.h>
-#include <time.h>
-#include <unistd.h>
-/* Try to pull in PATH_MAX */
-#include <limits.h>
-#include <sys/param.h>
-#ifndef PATH_MAX
-# define PATH_MAX 256
-#endif
-#include <pwd.h>
-#include <grp.h>
-/* C++ bits */
-#ifdef __cplusplus
-# include <string>
-#endif
-#include <glib.h>
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* Must be after #include "config.h" */
-#if ENABLE_NLS
-# include <libintl.h>
-# define _(S) gettext(S)
-#else
-# define _(S) (S)
-#endif
-
-/* Some libc's forget to declare these, do it ourself */
-extern char **environ;
-#if defined(__GLIBC__) && __GLIBC__ < 2
-int vdprintf(int d, const char *format, va_list ap);
-#endif
-
-#undef NORETURN
-#define NORETURN __attribute__ ((noreturn))
-
-#undef ERR_PTR
-#define ERR_PTR ((void*)(uintptr_t)1)
-
-#undef ARRAY_SIZE
-#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
-
-#include "xfuncs.h"
-#include "logging.h"
-#include "read_write.h"
-#include "strbuf.h"
-#include "hash_sha1.h"
-#include "parse_options.h"
-
-#include "problem_data.h"
-#include "libreport_types.h"
-#include "dump_dir.h"
-//#include "hooklib.h"
-#include "run_event.h"
-#include "event_config.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define prefixcmp libreport_prefixcmp
-int prefixcmp(const char *str, const char *prefix);
-#define suffixcmp libreport_suffixcmp
-int suffixcmp(const char *str, const char *suffix);
-#define strtrim libreport_strtrim
-char *strtrim(char *str);
-#define concat_path_file libreport_concat_path_file
-char *concat_path_file(const char *path, const char *filename);
-#define append_to_malloced_string libreport_append_to_malloced_string
-char *append_to_malloced_string(char *mstr, const char *append);
-#define skip_whitespace libreport_skip_whitespace
-char* skip_whitespace(const char *s);
-#define skip_non_whitespace libreport_skip_non_whitespace
-char* skip_non_whitespace(const char *s);
-/* Like strcpy but can copy overlapping strings. */
-#define overlapping_strcpy libreport_overlapping_strcpy
-void overlapping_strcpy(char *dst, const char *src);
-
-/* A-la fgets, but malloced and of unlimited size */
-#define xmalloc_fgets libreport_xmalloc_fgets
-char *xmalloc_fgets(FILE *file);
-/* Similar, but removes trailing \n */
-#define xmalloc_fgetline libreport_xmalloc_fgetline
-char *xmalloc_fgetline(FILE *file);
-
-/* On error, copyfd_XX prints error messages and returns -1 */
-enum {
- COPYFD_SPARSE = 1 << 0,
-};
-#define copyfd_eof libreport_copyfd_eof
-off_t copyfd_eof(int src_fd, int dst_fd, int flags);
-#define copyfd_size libreport_copyfd_size
-off_t copyfd_size(int src_fd, int dst_fd, off_t size, int flags);
-#define copyfd_exact_size libreport_copyfd_exact_size
-void copyfd_exact_size(int src_fd, int dst_fd, off_t size);
-#define copy_file libreport_copy_file
-off_t copy_file(const char *src_name, const char *dst_name, int mode);
-#define copy_file_recursive libreport_copy_file_recursive
-int copy_file_recursive(const char *source, const char *dest);
-
-/* Returns malloc'ed block */
-#define encode_base64 libreport_encode_base64
-char *encode_base64(const void *src, int length);
-
-#define xatou libreport_xatou
-unsigned xatou(const char *numstr);
-#define xatoi libreport_xatoi
-int xatoi(const char *numstr);
-/* Using xatoi() instead of naive atoi() is not always convenient -
- * in many places people want *non-negative* values, but store them
- * in signed int. Therefore we need this one:
- * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc.
- * It should really be named xatoi_nonnegative (since it allows 0),
- * but that would be too long.
- */
-#define xatoi_positive libreport_xatoi_positive
-int xatoi_positive(const char *numstr);
-
-//unused for now
-//unsigned long long monotonic_ns(void);
-//unsigned long long monotonic_us(void);
-//unsigned monotonic_sec(void);
-
-enum {
- /* on return, pipefds[1] is fd to which parent may write
- * and deliver data to child's stdin: */
- EXECFLG_INPUT = 1 << 0,
- /* on return, pipefds[0] is fd from which parent may read
- * child's stdout: */
- EXECFLG_OUTPUT = 1 << 1,
- /* open child's stdin to /dev/null: */
- EXECFLG_INPUT_NUL = 1 << 2,
- /* open child's stdout to /dev/null: */
- EXECFLG_OUTPUT_NUL = 1 << 3,
- /* redirect child's stderr to stdout: */
- EXECFLG_ERR2OUT = 1 << 4,
- /* open child's stderr to /dev/null: */
- EXECFLG_ERR_NUL = 1 << 5,
- /* suppress perror_msg("Can't execute 'foo'") if exec fails */
- EXECFLG_QUIET = 1 << 6,
- EXECFLG_SETGUID = 1 << 7,
- EXECFLG_SETSID = 1 << 8,
-};
-/*
- * env_vec: list of variables to set in environment (if string has
- * "VAR=VAL" form) or unset in environment (if string has no '=' char).
- *
- * Returns pid.
- */
-#define fork_execv_on_steroids libreport_fork_execv_on_steroids
-pid_t fork_execv_on_steroids(int flags,
- char **argv,
- int *pipefds,
- char **env_vec,
- const char *dir,
- uid_t uid);
-/* Returns malloc'ed string. NULs are retained, and extra one is appended
- * after the last byte (this NUL is not accounted for in *size_p) */
-#define run_in_shell_and_save_output libreport_run_in_shell_and_save_output
-char *run_in_shell_and_save_output(int flags,
- const char *cmd,
- const char *dir,
- size_t *size_p);
-
-/* Random utility functions */
-
-#define is_in_string_list libreport_is_in_string_list
-bool is_in_string_list(const char *name, char **v);
-
-/* Frees every element'd data using free(),
- * then frees list itself using g_list_free(list):
- */
-#define list_free_with_free libreport_list_free_with_free
-void list_free_with_free(GList *list);
-
-#define get_dirsize libreport_get_dirsize
-double get_dirsize(const char *pPath);
-#define get_dirsize_find_largest_dir libreport_get_dirsize_find_largest_dir
-double get_dirsize_find_largest_dir(
- const char *pPath,
- char **worst_dir, /* can be NULL */
- const char *excluded /* can be NULL */
-);
-
-/* Emit a string of hex representation of bytes */
-#define bin2hex libreport_bin2hex
-char* bin2hex(char *dst, const char *str, int count);
-/* Convert "xxxxxxxx" hex string to binary, no more than COUNT bytes */
-#define hex2bin libreport_hex2bin
-char* hex2bin(char *dst, const char *str, int count);
-
-/* Returns command line of running program.
- * Caller is responsible to free() the returned value.
- * If the pid is not valid or command line can not be obtained,
- * empty string is returned.
- */
-#define get_cmdline libreport_get_cmdline
-char* get_cmdline(pid_t pid);
-#define get_environ libreport_get_environ
-char* get_environ(pid_t pid);
-
-/* Returns 1 if abrtd daemon is running, 0 otherwise. */
-#define daemon_is_ok libreport_daemon_is_ok
-int daemon_is_ok();
-
-/* Takes ptr to time_t, or NULL if you want to use current time.
- * Returns "YYYY-MM-DD-hh:mm:ss" string.
- */
-#define iso_date_string libreport_iso_date_string
-char *iso_date_string(time_t *pt);
-
-enum {
- MAKEDESC_SHOW_FILES = (1 << 0),
- MAKEDESC_SHOW_MULTILINE = (1 << 1),
- MAKEDESC_SHOW_ONLY_LIST = (1 << 2),
-};
-#define make_description libreport_make_description
-char *make_description(problem_data_t *problem_data, char **names_to_skip, unsigned max_text_size, unsigned desc_flags);
-#define make_description_bz libreport_make_description_bz
-char* make_description_bz(problem_data_t *problem_data);
-#define make_description_logger libreport_make_description_logger
-char* make_description_logger(problem_data_t *problem_data);
-#define make_description_mailx libreport_make_description_mailx
-char* make_description_mailx(problem_data_t *problem_data);
-
-#define parse_release_for_bz libreport_parse_release_for_bz
-void parse_release_for_bz(const char *pRelease, char **product, char **version);
-#define parse_release_for_rhts libreport_parse_release_for_rhts
-void parse_release_for_rhts(const char *pRelease, char **product, char **version);
-
-/**
- * Loads settings and stores it in second parameter. On success it
- * returns true, otherwise returns false.
- *
- * @param path A path of config file.
- * Config file consists of "key=value" lines.
- * @param settings A read plugin's settings.
- * @param skipKeysWithoutValue
- * If true, lines in format "key=" (without value) are skipped.
- * Otherwise empty value "" is inserted into pSettings.
- * @return if it success it returns true, otherwise it returns false.
- */
-#define load_conf_file libreport_load_conf_file
-bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue);
-
-/* Tries to create a copy of dump_dir_name in base_dir, with same or similar basename.
- * Returns NULL if copying failed. In this case, logs a message before returning. */
-#define steal_directory libreport_steal_directory
-struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name);
-
-#define kernel_tainted_short libreport_kernel_tainted_short
-char *kernel_tainted_short(unsigned tainted);
-
-#define kernel_tainted_long libreport_kernel_tainted_long
-GList *kernel_tainted_long(unsigned tainted);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/libreport_problem_data.h b/libreport/src/include/libreport_problem_data.h
deleted file mode 100644
index 31ef7d25..00000000
--- a/libreport/src/include/libreport_problem_data.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- Copyright (C) 2009 Abrt team.
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef PROBLEM_DATA_H_
-#define PROBLEM_DATA_H_
-
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct dump_dir;
-
-enum {
- CD_FLAG_BIN = (1 << 0),
- CD_FLAG_TXT = (1 << 1),
- CD_FLAG_ISEDITABLE = (1 << 2),
- CD_FLAG_ISNOTEDITABLE = (1 << 3),
- /* Show this element in "short" info (abrt-cli -l) */
- CD_FLAG_LIST = (1 << 4),
- CD_FLAG_UNIXTIME = (1 << 5),
-};
-
-struct problem_item {
- char *content;
- unsigned flags;
- /* Used by UI for presenting "item allowed/not allowed" checkboxes: */
- int selected_by_user; /* 0 "don't know", -1 "no", 1 "yes" */
- int allowed_by_reporter; /* 0 "no", 1 "yes" */
- int default_by_reporter; /* 0 "no", 1 "yes" */
- int required_by_reporter; /* 0 "no", 1 "yes" */
-};
-typedef struct problem_item problem_item;
-
-char *format_problem_item(struct problem_item *item);
-
-
-/* In-memory problem data structure and accessors */
-
-typedef GHashTable problem_data_t;
-
-problem_data_t *new_problem_data(void);
-
-void add_basics_to_problem_data(problem_data_t *pd);
-
-static inline void free_problem_data(problem_data_t *problem_data)
-{
- if (problem_data)
- g_hash_table_destroy(problem_data);
-}
-
-void add_to_problem_data_ext(problem_data_t *problem_data,
- const char *name,
- const char *content,
- unsigned flags);
-/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */
-void add_to_problem_data(problem_data_t *problem_data,
- const char *name,
- const char *content);
-
-static inline struct problem_item *get_problem_data_item_or_NULL(problem_data_t *problem_data, const char *key)
-{
- return (struct problem_item *)g_hash_table_lookup(problem_data, key);
-}
-const char *get_problem_item_content_or_NULL(problem_data_t *problem_data, const char *key);
-/* Aborts if key is not found: */
-const char *get_problem_item_content_or_die(problem_data_t *problem_data, const char *key);
-
-
-/* Conversions between in-memory and on-disk formats */
-
-void load_problem_data_from_dump_dir(problem_data_t *problem_data, struct dump_dir *dd, char **excluding);
-problem_data_t *create_problem_data_from_dump_dir(struct dump_dir *dd);
-/* Helper for typical operation in reporters: */
-problem_data_t *create_problem_data_for_reporting(const char *dump_dir_name);
-
-struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/libreport_types.h b/libreport/src/include/libreport_types.h
deleted file mode 100644
index 4636bb7d..00000000
--- a/libreport/src/include/libreport_types.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright (C) 2009 Denys Vlasenko (dvlasenk@redhat.com)
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef ABRT_TYPES_H_
-#define ABRT_TYPES_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* TODO: rename to map_string_t */
-typedef GHashTable map_string_h;
-
-#define new_map_string abrt_new_map_string
-map_string_h *new_map_string(void);
-#define free_map_string abrt_free_map_string
-void free_map_string(map_string_h *ms);
-#define get_map_string_item_or_empty abrt_get_map_string_item_or_empty
-const char *get_map_string_item_or_empty(map_string_h *ms, const char *key);
-static inline
-const char *get_map_string_item_or_NULL(map_string_h *ms, const char *key)
-{
- return (const char*)g_hash_table_lookup(ms, key);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/logging.h b/libreport/src/include/logging.h
deleted file mode 100644
index 316c1a22..00000000
--- a/libreport/src/include/logging.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#ifndef LOGGING_H
-#define LOGGING_H
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <sys/syslog.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NORETURN __attribute__ ((noreturn))
-
-enum {
- LOGMODE_NONE = 0,
- LOGMODE_STDIO = (1 << 0),
- LOGMODE_SYSLOG = (1 << 1),
- LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
- LOGMODE_CUSTOM = (1 << 2),
-};
-
-#define g_custom_logger abrt_g_custom_logger
-extern void (*g_custom_logger)(const char*);
-#define msg_prefix abrt_msg_prefix
-extern const char *msg_prefix;
-#define msg_eol abrt_msg_eol
-extern const char *msg_eol;
-#define logmode abrt_logmode
-extern int logmode;
-#define xfunc_error_retval abrt_xfunc_error_retval
-extern int xfunc_error_retval;
-
-/* Verbosity level */
-#define g_verbose abrt_g_verbose
-extern int g_verbose;
-/* VERB1 log("what you sometimes want to see, even on a production box") */
-#define VERB1 if (g_verbose >= 1)
-/* VERB2 log("debug message, not going into insanely small details") */
-#define VERB2 if (g_verbose >= 2)
-/* VERB3 log("lots and lots of details") */
-#define VERB3 if (g_verbose >= 3)
-/* there is no level > 3 */
-
-#define abrt_
-#define xfunc_die abrt_xfunc_die
-void xfunc_die(void) NORETURN;
-#define log_msg abrt_log_msg
-void log_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-/* It's a macro, not function, since it collides with log() from math.h */
-#undef log
-#define log(...) log_msg(__VA_ARGS__)
-/* error_msg family will use g_custom_logger. log_msg does not. */
-#define error_msg abrt_error_msg
-void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-#define error_msg_and_die abrt_error_msg_and_die
-void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-/* Reports error message with libc's errno error description attached. */
-#define perror_msg abrt_perror_msg
-void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-#define perror_msg_and_die abrt_perror_msg_and_die
-void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-#define die_out_of_memory abrt_die_out_of_memory
-void die_out_of_memory(void) NORETURN;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/parse_options.h b/libreport/src/include/parse_options.h
deleted file mode 100644
index d86662e2..00000000
--- a/libreport/src/include/parse_options.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef PARSE_OPTIONS_H
-#define PARSE_OPTIONS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-const char *abrt_init(char **argv);
-#define export_abrt_envvars abrt_export_abrt_envvars
-void export_abrt_envvars(int pfx);
-#define g_progname abrt_g_progname
-extern const char *g_progname;
-
-
-enum parse_opt_type {
- OPTION_BOOL,
- OPTION_GROUP,
- OPTION_STRING,
- OPTION_INTEGER,
- OPTION_OPTSTRING,
- OPTION_LIST,
- OPTION_END,
-};
-
-struct options {
- enum parse_opt_type type;
- int short_name;
- const char *long_name;
- void *value;
- const char *argh;
- const char *help;
-};
-
-/*
- * s - short_name
- * l - long_name
- * v - value
- * a - option parameter name (for help text)
- * h - help
- */
-#define OPT_END() { OPTION_END }
-#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }
-#define OPT_BOOL( s, l, v, h) { OPTION_BOOL , (s), (l), (v), NULL , (h) }
-#define OPT_INTEGER( s, l, v, h) { OPTION_INTEGER , (s), (l), (v), "NUM", (h) }
-#define OPT_STRING( s, l, v, a, h) { OPTION_STRING , (s), (l), (v), (a) , (h) }
-#define OPT_OPTSTRING(s, l, v, a, h) { OPTION_OPTSTRING, (s), (l), (v), (a) , (h) }
-#define OPT_LIST( s, l, v, a, h) { OPTION_LIST , (s), (l), (v), (a) , (h) }
-
-#define OPT__VERBOSE(v) OPT_BOOL('v', "verbose", (v), _("Be verbose"))
-
-#define parse_opts abrt_parse_opts
-unsigned parse_opts(int argc, char **argv, const struct options *opt,
- const char *usage);
-
-#define show_usage_and_die abrt_show_usage_and_die
-void show_usage_and_die(const char *usage, const struct options *opt);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/problem_data.h b/libreport/src/include/problem_data.h
deleted file mode 100644
index f23cb050..00000000
--- a/libreport/src/include/problem_data.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- Copyright (C) 2009 ABRT team.
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef ABRT_PROBLEM_DATA_H_
-#define ABRT_PROBLEM_DATA_H_
-
-#include "libreport_problem_data.h"
-#include "libreport_types.h"
-#include "dump_dir.h"
-
-// Text bigger than this usually is attached, not added inline
-// was 2k, now bumbed up to 20k:
-#define CD_TEXT_ATT_SIZE (20*1024)
-
-// Filenames in dump directory:
-// filled by a hook:
-#define FILENAME_REASON "reason" /* mandatory */
-#define FILENAME_UID "uid" /* mandatory */
-#define FILENAME_TIME "time" /* mandatory */
-#define FILENAME_ANALYZER "analyzer"
-#define FILENAME_EXECUTABLE "executable"
-#define FILENAME_BINARY "binary"
-#define FILENAME_CMDLINE "cmdline"
-#define FILENAME_COREDUMP "coredump"
-#define FILENAME_BACKTRACE "backtrace"
-#define FILENAME_MAPS "maps"
-#define FILENAME_SMAPS "smaps"
-#define FILENAME_ENVIRON "environ"
-#define FILENAME_DUPHASH "duphash"
-// Name of the function where the application crashed.
-// Optional.
-#define FILENAME_CRASH_FUNCTION "crash_function"
-// filled by CDebugDump::Create() (which also fills FILENAME_UID):
-#define FILENAME_ARCHITECTURE "architecture"
-#define FILENAME_KERNEL "kernel"
-// From /etc/system-release or /etc/redhat-release
-#define FILENAME_OS_RELEASE "os_release"
-// Filled by <what?>
-#define FILENAME_PACKAGE "package"
-#define FILENAME_COMPONENT "component"
-#define FILENAME_COMMENT "comment"
-#define FILENAME_RATING "backtrace_rating"
-#define FILENAME_HOSTNAME "hostname"
-// Optional. Set to "1" by abrt-handle-upload for every unpacked dump
-#define FILENAME_REMOTE "remote"
-#define FILENAME_TAINTED "kernel_tainted"
-#define FILENAME_TAINTED_SHORT "kernel_tainted_short"
-#define FILENAME_TAINTED_LONG "kernel_tainted_long"
-
-#define FILENAME_UUID "uuid"
-#define FILENAME_COUNT "count"
-/* Multi-line list of places problem was reported.
- * Recommended line format:
- * "Reporter: VAR=VAL VAR=VAL"
- * Use add_reported_to(dd, "line_without_newline"): it adds line
- * only if it is not already there.
- */
-#define FILENAME_REPORTED_TO "reported_to"
-#define FILENAME_EVENT_LOG "event_log"
-
-// Not stored as files, added "on the fly":
-#define CD_DUMPDIR "Directory"
-//UNUSED:
-//// "Which events are possible (make sense) on this dump dir?"
-//// (a string with "\n" terminated event names)
-//#define CD_EVENTS "Events"
-
-/* FILENAME_EVENT_LOG is trimmed to below LOW_WATERMARK
- * when it reaches HIGH_WATERMARK size
- */
-enum {
- EVENT_LOG_HIGH_WATERMARK = 30 * 1024,
- EVENT_LOG_LOW_WATERMARK = 20 * 1024,
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define add_reported_to abrt_add_reported_to
-void add_reported_to(struct dump_dir *dd, const char *line);
-
-#define log_problem_data abrt_log_problem_data
-void log_problem_data(problem_data_t *problem_data, const char *pfx);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/read_write.h b/libreport/src/include/read_write.h
deleted file mode 100644
index dc85f33b..00000000
--- a/libreport/src/include/read_write.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#ifndef READ_WRITE_H
-#define READ_WRITE_H
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-// NB: will return short read on error, not -1,
-// if some data was read before error occurred
-#define xread abrt_xread
-void xread(int fd, void *buf, size_t count);
-
-#define safe_read abrt_safe_read
-ssize_t safe_read(int fd, void *buf, size_t count);
-#define safe_write abrt_safe_write
-ssize_t safe_write(int fd, const void *buf, size_t count);
-
-#define full_read abrt_full_read
-ssize_t full_read(int fd, void *buf, size_t count);
-#define full_write abrt_full_write
-ssize_t full_write(int fd, const void *buf, size_t count);
-
-#define full_write_str abrt_full_write_str
-ssize_t full_write_str(int fd, const char *buf);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/report.h b/libreport/src/include/report.h
deleted file mode 100644
index a5e1fa8e..00000000
--- a/libreport/src/include/report.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright (C) 2011 ABRT team.
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef REPORT_H_
-#define REPORT_H_
-
-#include "problem_data.h"
-
-enum {
- LIBREPORT_NOWAIT = 0,
- LIBREPORT_WAIT = (1 << 0), /* wait for report to finish and reload the problem data */
- LIBREPORT_ANALYZE = (1 << 1), /* run analyzers? */
- /* ("run reporters" is always on, has no flag (for now?)) */
- LIBREPORT_RELOAD_DATA = (1 << 3), /* reload problem data after run (needs WAIT) */
-};
-
-int report_problem_in_dir(const char *dirname, int flags);
-
-/* Reports a problem stored in problem_data_t.
- * It's first saved to /tmp and then processed as a dump dir.
- */
-int report_problem_in_memory(problem_data_t *pd, int flags);
-
-/* Simple wrapper for trivial uses */
-int report_problem(problem_data_t *pd);
-
-#endif /* REPORT_H_ */
diff --git a/libreport/src/include/run_event.h b/libreport/src/include/run_event.h
deleted file mode 100644
index 8e2ad589..00000000
--- a/libreport/src/include/run_event.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- Copyright (C) 2009 ABRT team.
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef RUN_EVENT_H_
-#define RUN_EVENT_H_
-
-#include "problem_data.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct dump_dir;
-
-struct run_event_state {
- int children_count;
-
- /* Used only for post-create dup detection. TODO: document its API */
- int (*post_run_callback)(const char *dump_dir_name, void *param);
- void *post_run_param;
-
- /* Can take ownership of log_line, which is malloced. In this case, return NULL.
- * Otherwise should return log_line (it will be freed by caller)
- */
- char* (*logging_callback)(char *log_line, void *param);
- void *logging_param;
-
- /* Internal data for async command execution */
- GList *rule_list;
- pid_t command_pid;
- int command_out_fd;
-};
-struct run_event_state *new_run_event_state(void);
-void free_run_event_state(struct run_event_state *state);
-
-/* Asynchronous command execution */
-
-/* Returns 0 if no commands found for this dump_dir_name+event, else >0 */
-int prepare_commands(struct run_event_state *state, const char *dump_dir_name, const char *event);
-/* Returns -1 is no more commands needs to be executed,
- * else sets state->command_pid and state->command_out_fd and returns >=0
- */
-int spawn_next_command(struct run_event_state *state, const char *dump_dir_name, const char *event);
-/* Cleans up internal state created in prepare_commands */
-void free_commands(struct run_event_state *state);
-
-/* Synchronous command execution */
-
-/* Returns exit code of first failed action, or first nonzero return value
- * of post_run_callback. If all actions are successful, returns 0.
- */
-int run_event_on_dir_name(struct run_event_state *state, const char *dump_dir_name, const char *event);
-int run_event_on_problem_data(struct run_event_state *state, problem_data_t *data, const char *event);
-
-/* Querying for possible events */
-
-/* Scans event.conf for events starting with pfx which are applicable
- * to dd, or (if dd is NULL), to dump_dir.
- * Returns a malloced string with '\n'-terminated event names.
- */
-char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/strbuf.h b/libreport/src/include/strbuf.h
deleted file mode 100644
index 44c6599a..00000000
--- a/libreport/src/include/strbuf.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- strbuf.h - string buffer
-
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef STRBUF_H
-#define STRBUF_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct strbuf
-{
- /* Size of the allocated buffer. Always > 0. */
- int alloc;
- /* Length of the string, without the ending \0. */
- int len;
- char *buf;
-};
-
-/**
- * Creates and initializes a new string buffer.
- * @returns
- * It never returns NULL. The returned pointer must be released by
- * calling the function strbuf_free().
- */
-#define strbuf_new abrt_strbuf_new
-struct strbuf *strbuf_new(void);
-
-/**
- * Releases the memory held by the string buffer.
- * @param strbuf
- * If the strbuf is NULL, no operation is performed.
- */
-#define strbuf_free abrt_strbuf_free
-void strbuf_free(struct strbuf *strbuf);
-
-/**
- * Releases the strbuf, but not the internal buffer. The internal
- * string buffer is returned. Caller is responsible to release the
- * returned memory using free().
- */
-#define strbuf_free_nobuf abrt_strbuf_free_nobuf
-char* strbuf_free_nobuf(struct strbuf *strbuf);
-
-/**
- * The string content is set to an empty string, erasing any previous
- * content and leaving its length at 0 characters.
- */
-#define strbuf_clear abrt_strbuf_clear
-void strbuf_clear(struct strbuf *strbuf);
-
-/**
- * The current content of the string buffer is extended by adding a
- * character c at its end.
- */
-#define strbuf_append_char abrt_strbuf_append_char
-struct strbuf *strbuf_append_char(struct strbuf *strbuf, char c);
-
-/**
- * The current content of the string buffer is extended by adding a
- * string str at its end.
- */
-#define strbuf_append_str abrt_strbuf_append_str
-struct strbuf *strbuf_append_str(struct strbuf *strbuf,
- const char *str);
-
-/**
- * The current content of the string buffer is extended by inserting a
- * string str at its beginning.
- */
-#define strbuf_prepend_str abrt_strbuf_prepend_str
-struct strbuf *strbuf_prepend_str(struct strbuf *strbuf,
- const char *str);
-
-/**
- * The current content of the string buffer is extended by adding a
- * sequence of data formatted as the format argument specifies.
- */
-#define strbuf_append_strf abrt_strbuf_append_strf
-struct strbuf *strbuf_append_strf(struct strbuf *strbuf,
- const char *format, ...);
-
-/**
- * The current content of the string buffer is extended by inserting a
- * sequence of data formatted as the format argument specifies at the
- * buffer beginning.
- */
-#define strbuf_prepend_strf abrt_strbuf_prepend_strf
-struct strbuf *strbuf_prepend_strf(struct strbuf *strbuf,
- const char *format, ...);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/include/xfuncs.h b/libreport/src/include/xfuncs.h
deleted file mode 100644
index 5f2504b6..00000000
--- a/libreport/src/include/xfuncs.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef ABRT_XFUNCS_H
-#define ABRT_XFUNCS_H
-
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <stdbool.h>
-#include <stdarg.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ndelay_on abrt_ndelay_on
-int ndelay_on(int fd);
-#define ndelay_off abrt_ndelay_off
-int ndelay_off(int fd);
-#define close_on_exec_on abrt_close_on_exec_on
-int close_on_exec_on(int fd);
-
-#define xmalloc abrt_xmalloc
-void* xmalloc(size_t size);
-#define xrealloc abrt_xrealloc
-void* xrealloc(void *ptr, size_t size);
-#define xzalloc abrt_xzalloc
-void* xzalloc(size_t size);
-#define xstrdup abrt_xstrdup
-char* xstrdup(const char *s);
-#define xstrndup abrt_xstrndup
-char* xstrndup(const char *s, int n);
-
-#define xpipe abrt_xpipe
-void xpipe(int filedes[2]);
-#define xdup abrt_xdup
-void xdup(int from);
-#define xdup2 abrt_xdup2
-void xdup2(int from, int to);
-#define xmove_fd abrt_xmove_fd
-void xmove_fd(int from, int to);
-
-#define xwrite abrt_xwrite
-void xwrite(int fd, const void *buf, size_t count);
-#define xwrite_str abrt_xwrite_str
-void xwrite_str(int fd, const char *str);
-
-#define xlseek abrt_xlseek
-off_t xlseek(int fd, off_t offset, int whence);
-
-#define xchdir abrt_xchdir
-void xchdir(const char *path);
-
-#define xvasprintf abrt_xvasprintf
-char* xvasprintf(const char *format, va_list p);
-#define xasprintf abrt_xasprintf
-char* xasprintf(const char *format, ...);
-
-#define xsetenv abrt_xsetenv
-void xsetenv(const char *key, const char *value);
-/*
- * Utility function to unsetenv a string which was possibly putenv'ed.
- * The problem here is that "natural" optimization:
- * strchrnul(var_val, '=')[0] = '\0';
- * unsetenv(var_val);
- * is BUGGY: if string was put into environment via putenv,
- * its modification (s/=/NUL/) is illegal, and unsetenv will fail to unset it.
- * Of course, saving/restoring the char wouldn't work either.
- * This helper creates a copy up to '=', unsetenv's it, and frees:
- */
-#define safe_unsetenv abrt_safe_unsetenv
-void safe_unsetenv(const char *var_val);
-
-#define xsocket abrt_xsocket
-int xsocket(int domain, int type, int protocol);
-#define xbind abrt_xbind
-void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
-#define xlisten abrt_xlisten
-void xlisten(int s, int backlog);
-#define xsendto abrt_xsendto
-ssize_t xsendto(int s, const void *buf, size_t len,
- const struct sockaddr *to, socklen_t tolen);
-
-#define xstat abrt_xstat
-void xstat(const char *name, struct stat *stat_buf);
-
-#define xopen3 abrt_xopen3
-int xopen3(const char *pathname, int flags, int mode);
-#define xopen abrt_xopen
-int xopen(const char *pathname, int flags);
-#define xunlink abrt_xunlink
-void xunlink(const char *pathname);
-
-/* Just testing dent->d_type == DT_REG is wrong: some filesystems
- * do not report the type, they report DT_UNKNOWN for every dirent
- * (and this is not a bug in filesystem, this is allowed by standards).
- * This function handles this case. Note: it returns 0 on symlinks
- * even if they point to regular files.
- */
-#define is_regular_file abrt_is_regular_file
-int is_regular_file(struct dirent *dent, const char *dirname);
-
-#define dot_or_dotdot abrt_dot_or_dotdot
-bool dot_or_dotdot(const char *filename);
-#define last_char_is abrt_last_char_is
-char *last_char_is(const char *s, int c);
-
-#define string_to_bool abrt_string_to_bool
-bool string_to_bool(const char *s);
-
-#define xseteuid abrt_xseteuid
-void xseteuid(uid_t euid);
-#define xsetegid abrt_xsetegid
-void xsetegid(gid_t egid);
-#define xsetreuid abrt_xsetreuid
-void xsetreuid(uid_t ruid, uid_t euid);
-#define xsetregid abrt_xsetregid
-void xsetregid(gid_t rgid, gid_t egid);
-
-/* Returns getpwuid(uid)->pw_dir or NULL */
-#define get_home_dir abrt_get_home_dir
-const char *get_home_dir(uid_t uid);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libreport/src/lib/Makefile.am b/libreport/src/lib/Makefile.am
deleted file mode 100644
index f90f2f9f..00000000
--- a/libreport/src/lib/Makefile.am
+++ /dev/null
@@ -1,94 +0,0 @@
-# libreport - the stuff shared among most of abrt (like xmalloc, logging)
-lib_LTLIBRARIES = \
- libreport.la \
- libabrt_dbus.la
-
-# Not used just yet:
-# time.cpp
-# xconnect.cpp
-
-libreport_la_SOURCES = \
- xfuncs.c \
- is_in_string_list.c \
- encbase64.c \
- binhex.c \
- stdio_helpers.c \
- hash_sha1.c \
- read_write.c \
- logging.c \
- copyfd.c \
- copy_file_recursive.c \
- concat_path_file.c \
- append_to_malloced_string.c \
- overlapping_strcpy.c \
- skip_whitespace.c \
- glib_support.c \
- iso_date_string.c \
- strbuf.c \
- xatonum.c \
- spawn.c \
- dirsize.c \
- dump_dir.c \
- get_cmdline.c \
- load_plugin_settings.c \
- make_descr.c \
- run_event.c \
- problem_data.c \
- create_dump_dir.c \
- abrt_types.c \
- parse_release.c \
- parse_options.c \
- steal_directory.c \
- event_xml_parser.c \
- event_config.c \
- kernel-tainted.c \
- report.c
-libreport_la_CPPFLAGS = \
- -Wall -Wwrite-strings -Werror \
- -I$(srcdir)/../include \
- -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DVAR_RUN=\"$(VAR_RUN)\" \
- -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
- -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
- -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
- -DCONF_DIR=\"$(CONF_DIR)\" \
- -DEVENTS_DIR=\"$(EVENTS_DIR)\" \
- -DBIN_DIR=\"$(bindir)\" \
- $(GLIB_CFLAGS) \
- -D_GNU_SOURCE
-libreport_la_LDFLAGS = \
- -version-info 0:1:0
-libreport_la_LIBADD = \
- $(GLIB_LIBS)
-
-libreportconfdir = $(CONF_DIR)
-dist_libreportconf_DATA = \
- report_event.conf
-
-libabrt_dbus_la_SOURCES = \
- abrt_dbus.c
-libabrt_dbus_la_CPPFLAGS = \
- -I$(srcdir)/../include/report -I$(srcdir)/../include \
- -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DVAR_RUN=\"$(VAR_RUN)\" \
- -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
- -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
- -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
- -DCONF_DIR=\"$(CONF_DIR)\" \
- -DEVENTS_DIR=\"$(EVENTS_DIR)\" \
- $(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
- -Wall -Wwrite-strings -Werror \
- -D_GNU_SOURCE
-libabrt_dbus_la_LDFLAGS = \
- -version-info 0:1:0
-libabrt_dbus_la_LIBADD = \
- libreport.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS)
-
-$(DESTDIR)/$(DEBUG_DUMPS_DIR):
- $(mkdir_p) '$@'
-# no need to chmod it here
-#chmod 1777 '$@'
-install-data-local: $(DESTDIR)/$(DEBUG_DUMPS_DIR)
diff --git a/libreport/src/lib/abrt_dbus.c b/libreport/src/lib/abrt_dbus.c
deleted file mode 100644
index d412ad5c..00000000
--- a/libreport/src/lib/abrt_dbus.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <dbus/dbus.h>
-//#include "abrtlib.h"
-#include "abrt_dbus.h"
-
-DBusConnection* g_dbus_conn;
-
-
-/*
- * Helpers for building DBus messages
- */
-
-//void store_bool(DBusMessageIter* iter, bool val)
-//{
-// dbus_bool_t db = val;
-// if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &db))
-// die_out_of_memory();
-//}
-void store_int32(DBusMessageIter* iter, int32_t val)
-{
- if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &val))
- die_out_of_memory();
-}
-void store_uint32(DBusMessageIter* iter, uint32_t val)
-{
- if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &val))
- die_out_of_memory();
-}
-void store_int64(DBusMessageIter* iter, int64_t val)
-{
- if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_INT64, &val))
- die_out_of_memory();
-}
-void store_uint64(DBusMessageIter* iter, uint64_t val)
-{
- if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &val))
- die_out_of_memory();
-}
-
-/* dbus daemon will simply close our connection if we send broken utf8.
- * Therefore we must never do that.
- */
-static char *sanitize_utf8(const char *src)
-{
- const char *initial_src = src;
- char *sanitized = NULL;
- unsigned sanitized_pos = 0;
-
- while (*src)
- {
- int bytes = 0;
-
- unsigned c = (unsigned char) *src;
- if (c <= 0x7f)
- {
- bytes = 1;
- goto good_byte;
- }
-
- /* Unicode -> utf8: */
- /* 80-7FF -> 110yyyxx 10xxxxxx */
- /* 800-FFFF -> 1110yyyy 10yyyyxx 10xxxxxx */
- /* 10000-1FFFFF -> 11110zzz 10zzyyyy 10yyyyxx 10xxxxxx */
- /* 200000-3FFFFFF -> 111110tt 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx */
- /* 4000000-FFFFFFFF -> 111111tt 10tttttt 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx */
- do {
- c <<= 1;
- bytes++;
- } while ((c & 0x80) && bytes < 6);
- if (bytes == 1)
- {
- /* A bare "continuation" byte. Say, 80 */
- goto bad_byte;
- }
-
- c = (uint8_t)(c) >> bytes;
- {
- const char *pp = src;
- int cnt = bytes;
- while (--cnt)
- {
- unsigned ch = (unsigned char) *++pp;
- if ((ch & 0xc0) != 0x80) /* Missing "continuation" byte. Example: e0 80 */
- {
- goto bad_byte;
- }
- c = (c << 6) + (ch & 0x3f);
- }
- }
- /* TODO */
- /* Need to check that c isn't produced by overlong encoding */
- /* Example: 11000000 10000000 converts to NUL */
- /* 11110000 10000000 10000100 10000000 converts to 0x100 */
- /* correct encoding: 11000100 10000000 */
- if (c <= 0x7f) /* crude check: only catches bad encodings which map to chars <= 7f */
- {
- goto bad_byte;
- }
-
- good_byte:
- while (--bytes >= 0)
- {
- c = (unsigned char) *src++;
- if (sanitized)
- {
- sanitized = (char*) xrealloc(sanitized, sanitized_pos + 2);
- sanitized[sanitized_pos++] = c;
- sanitized[sanitized_pos] = '\0';
- }
- }
- continue;
-
- bad_byte:
- if (!sanitized)
- {
- sanitized_pos = src - initial_src;
- sanitized = xstrndup(initial_src, sanitized_pos);
- }
- sanitized = (char*) xrealloc(sanitized, sanitized_pos + 5);
- sanitized[sanitized_pos++] = '[';
- c = (unsigned char) *src++;
- sanitized[sanitized_pos++] = "0123456789ABCDEF"[c >> 4];
- sanitized[sanitized_pos++] = "0123456789ABCDEF"[c & 0xf];
- sanitized[sanitized_pos++] = ']';
- sanitized[sanitized_pos] = '\0';
- }
-
- if (sanitized)
- VERB2 log("note: bad utf8, converted '%s' -> '%s'", initial_src, sanitized);
-
- return sanitized; /* usually NULL: the whole string is ok */
-}
-void store_string(DBusMessageIter* iter, const char* val)
-{
- const char *sanitized = sanitize_utf8(val);
- if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, sanitized ? &sanitized : &val))
- die_out_of_memory();
- free((char*)sanitized);
-}
-
-
-/*
- * Helpers for parsing DBus messages
- */
-
-//int load_bool(DBusMessageIter* iter, bool& val)
-//{
-// int type = dbus_message_iter_get_arg_type(iter);
-// if (type != DBUS_TYPE_BOOLEAN)
-// error_msg_and_die("%s expected in dbus message, but not found ('%c')", "bool", type);
-// dbus_bool_t db;
-// dbus_message_iter_get_basic(iter, &db);
-// val = db;
-// return dbus_message_iter_next(iter);
-//}
-int load_int32(DBusMessageIter* iter, int32_t *val)
-{
- int type = dbus_message_iter_get_arg_type(iter);
- if (type != DBUS_TYPE_INT32)
- {
- error_msg("%s expected in dbus message, but not found ('%c')", "int32", type);
- return -1;
- }
- dbus_message_iter_get_basic(iter, val);
- return dbus_message_iter_next(iter);
-}
-int load_uint32(DBusMessageIter* iter, uint32_t *val)
-{
- int type = dbus_message_iter_get_arg_type(iter);
- if (type != DBUS_TYPE_UINT32)
- {
- error_msg("%s expected in dbus message, but not found ('%c')", "uint32", type);
- return -1;
- }
- dbus_message_iter_get_basic(iter, val);
- return dbus_message_iter_next(iter);
-}
-int load_int64(DBusMessageIter* iter, int64_t *val)
-{
- int type = dbus_message_iter_get_arg_type(iter);
- if (type != DBUS_TYPE_INT64)
- {
- error_msg("%s expected in dbus message, but not found ('%c')", "int64", type);
- return -1;
- }
- dbus_message_iter_get_basic(iter, val);
- return dbus_message_iter_next(iter);
-}
-int load_uint64(DBusMessageIter* iter, uint64_t *val)
-{
- int type = dbus_message_iter_get_arg_type(iter);
- if (type != DBUS_TYPE_UINT64)
- {
- error_msg("%s expected in dbus message, but not found ('%c')", "uint64", type);
- return -1;
- }
- dbus_message_iter_get_basic(iter, val);
- return dbus_message_iter_next(iter);
-}
-int load_charp(DBusMessageIter* iter, const char** val)
-{
- *val = NULL;
-
- int type = dbus_message_iter_get_arg_type(iter);
- if (type != DBUS_TYPE_STRING)
- {
- error_msg("%s expected in dbus message, but not found ('%c')", "string", type);
- return -1;
- }
- dbus_message_iter_get_basic(iter, val);
-//log("load_charp:'%s'", *val);
- return dbus_message_iter_next(iter);
-}
-
-
-/*
- * Glib integration machinery
- */
-
-/* Callback: "glib says dbus fd is active" */
-static gboolean handle_dbus_fd(GIOChannel *gio, GIOCondition condition, gpointer data)
-{
- DBusWatch *watch = (DBusWatch*)data;
-
- VERB3 log("%s(gio, condition:%x [bits:IN/PRI/OUT/ERR/HUP...], data)", __func__, (int)condition);
-
- /* Notify the D-Bus library when a previously-added watch
- * is ready for reading or writing, or has an exception such as a hangup.
- */
- int glib_flags = (int)condition;
- int dbus_flags = 0;
- if (glib_flags & G_IO_IN) dbus_flags |= DBUS_WATCH_READABLE;
- if (glib_flags & G_IO_OUT) dbus_flags |= DBUS_WATCH_WRITABLE;
- if (glib_flags & G_IO_ERR) dbus_flags |= DBUS_WATCH_ERROR;
- if (glib_flags & G_IO_HUP) dbus_flags |= DBUS_WATCH_HANGUP;
- /*
- * TODO:
- * If dbus_watch_handle returns FALSE, then the file descriptor
- * may still be ready for reading or writing, but more memory
- * is needed in order to do the reading or writing. If you ignore
- * the FALSE return, your application may spin in a busy loop
- * on the file descriptor until memory becomes available,
- * but nothing more catastrophic should happen.
- */
- dbus_watch_handle(watch, dbus_flags);
-
- while (dbus_connection_dispatch(g_dbus_conn) == DBUS_DISPATCH_DATA_REMAINS)
- VERB3 log("%s: more data to process, looping", __func__);
- return TRUE; /* "glib, do not remove this event source!" */
-}
-
-typedef struct watch_app_info_t
-{
- GIOChannel *channel;
- guint event_source_id;
- bool watch_enabled;
-} watch_app_info_t;
-/* Callback: "dbus_watch_get_enabled() may return a different value than it did before" */
-static void toggled_watch(DBusWatch *watch, void* data)
-{
- VERB3 log("%s(watch:%p, data)", __func__, watch);
-
- watch_app_info_t* app_info = (watch_app_info_t*)dbus_watch_get_data(watch);
- if (dbus_watch_get_enabled(watch))
- {
- if (!app_info->watch_enabled)
- {
- app_info->watch_enabled = true;
- int dbus_flags = dbus_watch_get_flags(watch);
- int glib_flags = 0;
- if (dbus_flags & DBUS_WATCH_READABLE) glib_flags |= G_IO_IN;
- if (dbus_flags & DBUS_WATCH_WRITABLE) glib_flags |= G_IO_OUT;
- VERB3 log(" adding watch to glib main loop. dbus_flags:%x glib_flags:%x", dbus_flags, glib_flags);
- app_info->event_source_id = g_io_add_watch(app_info->channel, (GIOCondition)glib_flags, handle_dbus_fd, watch);
- }
- /* else: it was already enabled */
- }
- else
- {
- if (app_info->watch_enabled)
- {
- app_info->watch_enabled = false;
- /* does it free the hidden GSource too? */
- VERB3 log(" removing watch from glib main loop");
- g_source_remove(app_info->event_source_id);
- }
- /* else: it was already disabled */
- }
-}
-/* Callback: "libdbus needs a new watch to be monitored by the main loop" */
-static dbus_bool_t add_watch(DBusWatch *watch, void* data)
-{
- VERB3 log("%s(watch:%p, data)", __func__, watch);
-
- watch_app_info_t* app_info = (watch_app_info_t*)xzalloc(sizeof(*app_info));
- dbus_watch_set_data(watch, app_info, free);
-
- int fd = dbus_watch_get_unix_fd(watch);
- VERB3 log(" dbus_watch_get_unix_fd():%d", fd);
- app_info->channel = g_io_channel_unix_new(fd);
- /* _unconditionally_ adding it to event loop would be an error */
- toggled_watch(watch, data);
- return TRUE;
-}
-/* Callback: "libdbus no longer needs a watch to be monitored by the main loop" */
-static void remove_watch(DBusWatch *watch, void* data)
-{
- VERB3 log("%s()", __func__);
- watch_app_info_t* app_info = (watch_app_info_t*)dbus_watch_get_data(watch);
- if (app_info->watch_enabled)
- {
- app_info->watch_enabled = false;
- g_source_remove(app_info->event_source_id);
- }
- g_io_channel_unref(app_info->channel);
-}
-
-/* Callback: "libdbus needs a new timeout to be monitored by the main loop" */
-static dbus_bool_t add_timeout(DBusTimeout *timeout, void* data)
-{
- VERB3 log("%s()", __func__);
- return TRUE;
-}
-/* Callback: "libdbus no longer needs a timeout to be monitored by the main loop" */
-static void remove_timeout(DBusTimeout *timeout, void* data)
-{
- VERB3 log("%s()", __func__);
-}
-/* Callback: "dbus_timeout_get_enabled() may return a different value than it did before" */
-static void timeout_toggled(DBusTimeout *timeout, void* data)
-{
-//seems to be never called, let's make it noisy
- error_msg_and_die("%s(): FIXME: some dbus machinery is missing here", __func__);
-}
-
-/* Callback: "DBusObjectPathVTable is unregistered (or its connection is freed)" */
-static void unregister_vtable(DBusConnection *conn, void* data)
-{
- VERB3 log("%s()", __func__);
-}
-
-
-/*
- * Simple logging handler for dbus errors.
- */
-int log_dbus_error(const char *msg, DBusError *err)
-{
- int ret = 0;
- if (dbus_error_is_set(err))
- {
- error_msg("dbus error: %s", err->message);
- ret = 1;
- }
- if (msg)
- {
- error_msg(msg);
- ret = 1;
- }
- return ret;
-}
-
-
-/*
- * Initialization. Works as follows:
- *
- * we have a DBusConnection* (say, obtained with dbus_bus_get)
- * we call dbus_connection_set_watch_functions
- * libdbus calls back add_watch(watch:0x2341090, data), this watch is for writing
- * we call toggled_watch, but it finds that watch is not to be enabled yet
- * libdbus calls back add_watch(watch:0x23410e0, data), this watch is for reading
- * we call toggled_watch, it adds watch's fd to glib main loop with POLLIN
- * (note: these watches are different objects, but they have the same fd)
- * we call dbus_connection_set_timeout_functions
- * we call dbus_connection_register_object_path
- *
- * Note: if user will later call dbus_bus_request_name(conn, ...):
- * libdbus calls back add_timeout()
- * libdbus calls back remove_timeout()
- * note - no callback to timeout_toggled()!
- * (therefore there is no code yet in timeout_toggled (see above), it's not used)
- */
-void attach_dbus_conn_to_glib_main_loop(DBusConnection* conn,
- const char* object_path,
- DBusHandlerResult (*message_received_func)(DBusConnection *conn, DBusMessage *msg, void* data)
-) {
- if (g_dbus_conn)
- error_msg_and_die("Internal bug: can't connect to more than one dbus");
- g_dbus_conn = conn;
-
-//do we need this? why?
-//log("dbus_connection_set_dispatch_status_function");
-// dbus_connection_set_dispatch_status_function(conn,
-// dispatch, /* void dispatch(DBusConnection *conn, DBusDispatchStatus new_status, void* data) */
-// NULL, /* data */
-// NULL /* free_data_function */
-// )
- VERB3 log("dbus_connection_set_watch_functions");
- if (!dbus_connection_set_watch_functions(conn,
- add_watch,
- remove_watch,
- toggled_watch,
- NULL, /* data */
- NULL /* free_data_function */
- )
- ) {
- die_out_of_memory();
- }
- VERB3 log("dbus_connection_set_timeout_functions");
- if (!dbus_connection_set_timeout_functions(conn,
- add_timeout,
- remove_timeout,
- timeout_toggled,
- NULL, /* data */
- NULL /* free_data_function */
- )
- ) {
- die_out_of_memory();
- }
-
- if (object_path && message_received_func)
- {
- /* Table */
- const DBusObjectPathVTable vtable = {
- /* .unregister_function = */ unregister_vtable,
- /* .message_function = */ message_received_func,
- };
- VERB3 log("dbus_connection_register_object_path");
- if (!dbus_connection_register_object_path(conn,
- object_path,
- &vtable,
- NULL /* data */
- )
- ) {
- die_out_of_memory();
- }
- }
-}
-
-
-/*
- * Support functions for clients
- */
-
-/* helpers */
-static DBusMessage* new_call_msg(const char* method)
-{
- DBusMessage* msg = dbus_message_new_method_call(ABRTD_DBUS_NAME, ABRTD_DBUS_PATH, ABRTD_DBUS_IFACE, method);
- if (!msg)
- die_out_of_memory();
- return msg;
-}
-
-static DBusMessage* send_get_reply_and_unref(DBusMessage* msg)
-{
- dbus_uint32_t serial;
- if (TRUE != dbus_connection_send(g_dbus_conn, msg, &serial))
- error_msg_and_die("Error sending DBus message");
- dbus_message_unref(msg);
-
- while (true)
- {
- DBusMessage *received = dbus_connection_pop_message(g_dbus_conn);
- if (!received)
- {
- if (FALSE == dbus_connection_read_write(g_dbus_conn, -1))
- error_msg_and_die("dbus connection closed");
- continue;
- }
-
- int tp = dbus_message_get_type(received);
- const char *error_str = dbus_message_get_error_name(received);
-#if 0
- /* Debugging */
- printf("type:%u (CALL:%u, RETURN:%u, ERROR:%u, SIGNAL:%u)\n", tp,
- DBUS_MESSAGE_TYPE_METHOD_CALL,
- DBUS_MESSAGE_TYPE_METHOD_RETURN,
- DBUS_MESSAGE_TYPE_ERROR,
- DBUS_MESSAGE_TYPE_SIGNAL
- );
- const char *sender = dbus_message_get_sender(received);
- if (sender)
- printf("sender: %s\n", sender);
- const char *path = dbus_message_get_path(received);
- if (path)
- printf("path: %s\n", path);
- const char *member = dbus_message_get_member(received);
- if (member)
- printf("member: %s\n", member);
- const char *interface = dbus_message_get_interface(received);
- if (interface)
- printf("interface: %s\n", interface);
- const char *destination = dbus_message_get_destination(received);
- if (destination)
- printf("destination: %s\n", destination);
- if (error_str)
- printf("error: '%s'\n", error_str);
-#endif
-
- DBusError err;
- dbus_error_init(&err);
-
- if (dbus_message_is_signal(received, ABRTD_DBUS_IFACE, "Update"))
- {
- const char *update_msg;
- if (!dbus_message_get_args(received, &err,
- DBUS_TYPE_STRING, &update_msg,
- DBUS_TYPE_INVALID))
- {
- error_msg_and_die("dbus Update message: arguments mismatch");
- }
- printf(">> %s\n", update_msg);
- }
- else if (dbus_message_is_signal(received, ABRTD_DBUS_IFACE, "Warning"))
- {
- const char *warning_msg;
- if (!dbus_message_get_args(received, &err,
- DBUS_TYPE_STRING, &warning_msg,
- DBUS_TYPE_INVALID))
- {
- error_msg_and_die("dbus Warning message: arguments mismatch");
- }
- log(">! %s", warning_msg);
- }
- else
- if (tp == DBUS_MESSAGE_TYPE_METHOD_RETURN
- && dbus_message_get_reply_serial(received) == serial
- ) {
- return received;
- }
- else
- if (tp == DBUS_MESSAGE_TYPE_ERROR
- && dbus_message_get_reply_serial(received) == serial
- ) {
- error_msg_and_die("dbus call returned error: '%s'", error_str);
- }
-
- dbus_message_unref(received);
- }
-}
-
-int32_t call_DeleteDebugDump(const char *dump_dir_name)
-{
- DBusMessage* msg = new_call_msg(__func__ + 5);
- dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &dump_dir_name,
- DBUS_TYPE_INVALID);
-
- DBusMessage *reply = send_get_reply_and_unref(msg);
-
- DBusMessageIter in_iter;
- dbus_message_iter_init(reply, &in_iter);
-
- int32_t result;
- int r = load_int32(&in_iter, &result);
- if (r != ABRT_DBUS_LAST_FIELD) /* more values present, or bad type */
- error_msg_and_die("dbus call %s: return type mismatch", __func__ + 5);
-
- dbus_message_unref(reply);
- return result;
-}
-
-static int connect_to_abrtd_and_call_DeleteDebugDump(const char *dump_dir_name)
-{
- DBusError err;
- dbus_error_init(&err);
- g_dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
- if (log_dbus_error(
- g_dbus_conn ? NULL :
- "error requesting system DBus, possible reasons: "
- "dbus config is incorrect; dbus-daemon is not running, "
- "or dbus daemon needs to be restarted to reload dbus config",
- &err
- )
- ) {
- if (g_dbus_conn)
- dbus_connection_unref(g_dbus_conn);
- g_dbus_conn = NULL;
- return 1;
- }
-
- int ret = call_DeleteDebugDump(dump_dir_name);
- if (ret == ENOENT)
- error_msg("Dump directory '%s' is not found", dump_dir_name);
- else if (ret != 0)
- error_msg("Can't delete dump directory '%s'", dump_dir_name);
-
- dbus_connection_unref(g_dbus_conn);
- g_dbus_conn = NULL;
-
- return ret;
-}
-
-int delete_dump_dir_possibly_using_abrtd(const char *dump_dir_name)
-{
- /* Try to delete it ourselves */
- struct dump_dir *dd = dd_opendir(dump_dir_name, DD_OPEN_READONLY);
- if (dd)
- {
- if (dd->locked) /* it is not readonly */
- return dd_delete(dd);
- dd_close(dd);
- }
-
- VERB1 log("Deleting '%s' via abrtd dbus call", dump_dir_name);
- return connect_to_abrtd_and_call_DeleteDebugDump(dump_dir_name);
-}
diff --git a/libreport/src/lib/abrt_types.c b/libreport/src/lib/abrt_types.c
deleted file mode 100644
index 0b51821d..00000000
--- a/libreport/src/lib/abrt_types.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Copyright (C) 2010 ABRT Team
- Copyright (C) 2010 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-map_string_h *new_map_string(void)
-{
- return g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
-}
-
-void free_map_string(map_string_h *ms)
-{
- if (ms)
- g_hash_table_destroy(ms);
-}
-
-const char *get_map_string_item_or_empty(map_string_h *ms, const char *key)
-{
- const char *v = (const char*)g_hash_table_lookup(ms, key);
- if (!v) v = "";
- return v;
-}
diff --git a/libreport/src/lib/append_to_malloced_string.c b/libreport/src/lib/append_to_malloced_string.c
deleted file mode 100644
index c55a258f..00000000
--- a/libreport/src/lib/append_to_malloced_string.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-char *append_to_malloced_string(char *mstr, const char *append)
-{
- unsigned mlen = strlen(mstr);
- mstr = (char*) xrealloc(mstr, mlen + strlen(append) + 1);
- strcpy(mstr + mlen, append);
- return mstr;
-}
diff --git a/libreport/src/lib/binhex.c b/libreport/src/lib/binhex.c
deleted file mode 100644
index ed6dea08..00000000
--- a/libreport/src/lib/binhex.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- Copyright (C) 2011 ABRT team
- Copyright (C) 2011 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "libreport.h"
-
-static const char hexdigits_locase[] = "0123456789abcdef";
-
-/* Emit a string of hex representation of bytes */
-char *bin2hex(char *dst, const char *str, int count)
-{
- while (count) {
- unsigned char c = *str++;
- /* put lowercase hex digits */
- *dst++ = hexdigits_locase[c >> 4];
- *dst++ = hexdigits_locase[c & 0xf];
- count--;
- }
- return dst;
-}
-
-/* Convert "xxxxxxxx" hex string to binary, no more than COUNT bytes */
-char *hex2bin(char *dst, const char *str, int count)
-{
- /* Parts commented out with // allow parsing
- * of strings like "xx:x:x:xx:xx:xx:xxxxxx"
- * (IPv6, ethernet addresses and the like).
- */
- errno = EINVAL;
- while (*str && count) {
- uint8_t val;
- uint8_t c;
-
- c = *str++;
- if (isdigit(c))
- val = c - '0';
- else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
- val = (c|0x20) - ('a' - 10);
- else
- return NULL;
- val <<= 4;
- c = *str;
- if (isdigit(c))
- val |= c - '0';
- else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
- val |= (c|0x20) - ('a' - 10);
- //else if (c == ':' || c == '\0')
- // val >>= 4;
- else
- return NULL;
-
- *dst++ = val;
- //if (c != '\0')
- str++;
- //if (*str == ':')
- // str++;
- count--;
- }
- errno = (*str ? ERANGE : 0);
- return dst;
-}
diff --git a/libreport/src/lib/concat_path_file.c b/libreport/src/lib/concat_path_file.c
deleted file mode 100644
index d7f199a5..00000000
--- a/libreport/src/lib/concat_path_file.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Utility routines.
- *
- * Copyright (C) 2001 Erik Andersen
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/* Concatenate path and filename to new allocated buffer.
- * Add '/' only as needed (no duplicate // are produced).
- * If path is NULL, it is assumed to be "/".
- * filename should not be NULL.
- */
-
-#include "libreport.h"
-
-char *concat_path_file(const char *path, const char *filename)
-{
- if (!path)
- path = "";
- const char *end = path + strlen(path);
- while (*filename == '/')
- filename++;
- return xasprintf("%s%s%s", path, (end != path && end[-1] != '/' ? "/" : ""), filename);
-}
diff --git a/libreport/src/lib/copy_file_recursive.c b/libreport/src/lib/copy_file_recursive.c
deleted file mode 100644
index ebfd8dae..00000000
--- a/libreport/src/lib/copy_file_recursive.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- Copyright (C) 2011 ABRT team
- Copyright (C) 2011 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "libreport.h"
-
-int copy_file_recursive(const char *source, const char *dest)
-{
- /* This is a recursive function, try to minimize stack usage */
- /* NB: each struct stat is ~100 bytes */
- struct stat source_stat;
- struct stat dest_stat;
- int retval = 0;
- int dest_exists = 0;
-
- if (strcmp(source, ".lock") == 0)
- goto skip;
-
- if (stat(source, &source_stat) < 0) {
- perror_msg("Can't stat '%s'", source);
- return -1;
- }
-
- if (lstat(dest, &dest_stat) < 0) {
- if (errno != ENOENT) {
- perror_msg("Can't stat '%s'", dest);
- return -1;
- }
- } else {
- if (source_stat.st_dev == dest_stat.st_dev
- && source_stat.st_ino == dest_stat.st_ino
- ) {
- error_msg("'%s' and '%s' are the same file", source, dest);
- return -1;
- }
- dest_exists = 1;
- }
-
- if (S_ISDIR(source_stat.st_mode)) {
- DIR *dp;
- struct dirent *d;
-
- if (dest_exists) {
- if (!S_ISDIR(dest_stat.st_mode)) {
- error_msg("Target '%s' is not a directory", dest);
- return -1;
- }
- /* race here: user can substitute a symlink between
- * this check and actual creation of files inside dest */
- } else {
- /* Create DEST */
- mode_t mode = source_stat.st_mode;
- /* Allow owner to access new dir (at least for now) */
- mode |= S_IRWXU;
- if (mkdir(dest, mode) < 0) {
- perror_msg("Can't create directory '%s'", dest);
- return -1;
- }
- }
- /* Recursively copy files in SOURCE */
- dp = opendir(source);
- if (dp == NULL) {
- retval = -1;
- goto ret;
- }
-
- while (retval == 0 && (d = readdir(dp)) != NULL) {
- char *new_source, *new_dest;
-
- if (dot_or_dotdot(d->d_name))
- continue;
- new_source = concat_path_file(source, d->d_name);
- new_dest = concat_path_file(dest, d->d_name);
- if (copy_file_recursive(new_source, new_dest) < 0)
- retval = -1;
- free(new_source);
- free(new_dest);
- }
- closedir(dp);
-
- goto ret;
- }
-
- if (S_ISREG(source_stat.st_mode)) {
- int src_fd;
- int dst_fd;
- mode_t new_mode;
-
- src_fd = open(source, O_RDONLY);
- if (src_fd < 0) {
- perror_msg("Can't open '%s'", source);
- return -1;
- }
-
- /* Do not try to open with weird mode fields */
- new_mode = source_stat.st_mode;
-
- // security problem versus (sym)link attacks
- // dst_fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, new_mode);
- /* safe way: */
- dst_fd = open(dest, O_WRONLY|O_CREAT|O_EXCL, new_mode);
- if (dst_fd < 0) {
- close(src_fd);
- return -1;
- }
-
- if (copyfd_eof(src_fd, dst_fd, COPYFD_SPARSE) == -1)
- retval = -1;
- close(src_fd);
- /* Careful: do check that buffered writes succeeded... */
- if (close(dst_fd) < 0) {
- perror_msg("Error writing to '%s'", dest);
- retval = -1;
- } else {
- /* (Try to) copy atime and mtime */
- struct timeval atime_mtime[2];
- atime_mtime[0].tv_sec = source_stat.st_atime;
- // note: if "st_atim.tv_nsec" doesn't compile, try "st_atimensec":
- atime_mtime[0].tv_usec = source_stat.st_atim.tv_nsec / 1000;
- atime_mtime[1].tv_sec = source_stat.st_mtime;
- atime_mtime[1].tv_usec = source_stat.st_mtim.tv_nsec / 1000;
- // note: can use utimensat when it is more widely supported:
- utimes(dest, atime_mtime);
- }
- goto ret;
- }
-
- /* Neither dir not regular file: skip */
-
- skip:
- log("Skipping '%s'", source);
- ret:
- return retval;
-}
diff --git a/libreport/src/lib/copyfd.c b/libreport/src/lib/copyfd.c
deleted file mode 100644
index 8d805069..00000000
--- a/libreport/src/lib/copyfd.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-/*
- * Utility routines.
- *
- */
-#include "libreport.h"
-
-#define CONFIG_FEATURE_COPYBUF_KB 4
-
-static const char msg_write_error[] = "write error";
-static const char msg_read_error[] = "read error";
-
-static off_t full_fd_action(int src_fd, int dst_fd, off_t size, int flags)
-{
- int status = -1;
- off_t total = 0;
- int last_was_seek = 0;
-#if CONFIG_FEATURE_COPYBUF_KB <= 4
- char buffer[CONFIG_FEATURE_COPYBUF_KB * 1024];
- enum { buffer_size = sizeof(buffer) };
-#else
- char *buffer;
- int buffer_size;
-
- /* We want page-aligned buffer, just in case kernel is clever
- * and can do page-aligned io more efficiently */
- buffer = mmap(NULL, CONFIG_FEATURE_COPYBUF_KB * 1024,
- PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON,
- /* ignored: */ -1, 0);
- buffer_size = CONFIG_FEATURE_COPYBUF_KB * 1024;
- if (buffer == MAP_FAILED) {
- buffer = alloca(4 * 1024);
- buffer_size = 4 * 1024;
- }
-#endif
-
- if (src_fd < 0)
- goto out;
-
- if (!size) {
- size = buffer_size;
- status = 1; /* copy until eof */
- }
-
- while (1) {
- ssize_t rd;
-
- rd = safe_read(src_fd, buffer, size > buffer_size ? buffer_size : size);
-
- if (!rd) { /* eof - all done */
- if (last_was_seek) {
- if (lseek(dst_fd, -1, SEEK_CUR) < 0
- || safe_write(dst_fd, "", 1) != 1
- ) {
- perror_msg("%s", msg_write_error);
- break;
- }
- }
- status = 0;
- break;
- }
- if (rd < 0) {
- perror_msg("%s", msg_read_error);
- break;
- }
- /* dst_fd == -1 is a fake, else... */
- if (dst_fd >= 0) {
- if (flags & COPYFD_SPARSE) {
- ssize_t cnt = rd;
- while (--cnt >= 0)
- if (buffer[cnt] != 0)
- goto need2write;
- if (lseek(dst_fd, rd, SEEK_CUR) < 0) {
- flags &= ~COPYFD_SPARSE;
- goto need2write;
- }
- last_was_seek = 1;
- } else {
- need2write:
- {
- ssize_t wr = full_write(dst_fd, buffer, rd);
- if (wr < rd) {
- perror_msg("%s", msg_write_error);
- break;
- }
- last_was_seek = 0;
- }
- }
- }
- total += rd;
- if (status < 0) { /* if we aren't copying till EOF... */
- size -= rd;
- if (!size) {
- /* 'size' bytes copied - all done */
- status = 0;
- break;
- }
- }
- }
- out:
-
-#if CONFIG_FEATURE_COPYBUF_KB > 4
- if (buffer_size != 4 * 1024)
- munmap(buffer, buffer_size);
-#endif
- return status ? -1 : total;
-}
-
-off_t copyfd_size(int fd1, int fd2, off_t size, int flags)
-{
- if (size) {
- return full_fd_action(fd1, fd2, size, flags);
- }
- return 0;
-}
-
-void copyfd_exact_size(int fd1, int fd2, off_t size)
-{
- off_t sz = copyfd_size(fd1, fd2, size, /*flags:*/ 0);
- if (sz == size)
- return;
- if (sz != -1)
- error_msg_and_die("short read");
- /* if sz == -1, copyfd_XX already complained */
- xfunc_die();
-}
-
-off_t copyfd_eof(int fd1, int fd2, int flags)
-{
- return full_fd_action(fd1, fd2, 0, flags);
-}
-
-off_t copy_file(const char *src_name, const char *dst_name, int mode)
-{
- off_t r;
- int src = open(src_name, O_RDONLY);
- if (src < 0)
- {
- perror_msg("Can't open '%s'", src_name);
- return -1;
- }
- int dst = open(dst_name, O_WRONLY | O_TRUNC | O_CREAT, mode);
- if (dst < 0)
- {
- close(src);
- perror_msg("Can't open '%s'", dst_name);
- return -1;
- }
- r = copyfd_eof(src, dst, /*flags:*/ 0);
- close(src);
- close(dst);
- return r;
-}
diff --git a/libreport/src/lib/create_dump_dir.c b/libreport/src/lib/create_dump_dir.c
deleted file mode 100644
index 33d9bd7c..00000000
--- a/libreport/src/lib/create_dump_dir.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "libreport.h"
-
-static struct dump_dir *try_dd_create(const char *base_dir_name, const char *dir_name)
-{
- char *path = concat_path_file(base_dir_name, dir_name);
- struct dump_dir *dd = dd_create(path, (uid_t)-1L, 0640);
- if (dd)
- dd_create_basic_files(dd, (uid_t)-1L);
- free(path);
- return dd;
-}
-
-struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name)
-{
- char dir_name[sizeof("abrt-tmp-YYYY-MM-DD-HH:MM:SS-%lu") + sizeof(long)*3];
- sprintf(dir_name, "abrt-tmp-%s-%lu", iso_date_string(NULL), (long)getpid());
-
- struct dump_dir *dd;
- if (base_dir_name)
- dd = try_dd_create(base_dir_name, dir_name);
- else
- {
- /* Try /var/run/abrt */
- dd = try_dd_create(LOCALSTATEDIR"/run/abrt", dir_name);
- /* Try $HOME/tmp */
- if (!dd)
- {
- char *home = getenv("HOME");
- if (home && home[0])
- {
- home = concat_path_file(home, "tmp");
- /*mkdir(home, 0777); - do we want this? */
- dd = try_dd_create(home, dir_name);
- free(home);
- }
- }
-//TODO: try user's home dir obtained by getpwuid(getuid())?
- /* Try /tmp */
- if (!dd)
- dd = try_dd_create("/tmp", dir_name);
- }
- if (!dd)
- return NULL;
-
- GHashTableIter iter;
- char *name;
- struct problem_item *value;
- g_hash_table_iter_init(&iter, problem_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- if (name[0] == '.' || strchr(name, '/'))
- {
- error_msg("Problem data field name contains disallowed chars: '%s'", name);
- goto next;
- }
-
-//FIXME: what to do with CD_FLAG_BINs??
- if (value->flags & CD_FLAG_BIN)
- goto next;
-
- dd_save_text(dd, name, value->content);
- next: ;
- }
-
- return dd;
-}
diff --git a/libreport/src/lib/daemon_is_ok.c b/libreport/src/lib/daemon_is_ok.c
deleted file mode 100644
index b4856b14..00000000
--- a/libreport/src/lib/daemon_is_ok.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-int daemon_is_ok()
-{
- int fd = open(VAR_RUN"/abrtd.pid", O_RDONLY);
- if (fd < 0)
- {
- return 0;
- }
-
- char pid[sizeof(pid_t)*3 + 2];
- int len = read(fd, pid, sizeof(pid)-1);
- close(fd);
- if (len <= 0)
- return 0;
-
- pid[len] = '\0';
- *strchrnul(pid, '\n') = '\0';
- /* paranoia: we don't want to check /proc//stat or /proc///stat */
- if (pid[0] == '\0' || pid[0] == '/')
- return 0;
-
- char path[sizeof("/proc/%s/stat") + sizeof(pid)];
- sprintf(path, "/proc/%s/stat", pid);
- struct stat sb;
- if (stat(path, &sb) == -1)
- {
- return 0;
- }
-
- /* TODO: maybe readlink /proc/PID/exe and check that it is "xxx/abrt"? */
-
- return 1;
-}
diff --git a/libreport/src/lib/dirsize.c b/libreport/src/lib/dirsize.c
deleted file mode 100644
index 88733ae0..00000000
--- a/libreport/src/lib/dirsize.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com)
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-double get_dirsize(const char *pPath)
-{
- DIR *dp = opendir(pPath);
- if (dp == NULL)
- return 0;
-
- struct dirent *ep;
- struct stat statbuf;
- double size = 0;
- while ((ep = readdir(dp)) != NULL)
- {
- if (dot_or_dotdot(ep->d_name))
- continue;
- char *dname = concat_path_file(pPath, ep->d_name);
- if (lstat(dname, &statbuf) != 0)
- {
- free(dname);
- continue;
- }
- if (S_ISDIR(statbuf.st_mode))
- {
- size += get_dirsize(dname);
- }
- else if (S_ISREG(statbuf.st_mode))
- {
- size += statbuf.st_size;
- }
- free(dname);
- }
- closedir(dp);
- return size;
-}
-
-double get_dirsize_find_largest_dir(
- const char *pPath,
- char **worst_dir,
- const char *excluded)
-{
- if (worst_dir)
- *worst_dir = NULL;
-
- DIR *dp = opendir(pPath);
- if (dp == NULL)
- return 0;
-
- struct dirent *ep;
- struct stat statbuf;
- double size = 0;
- double maxsz = 0;
- while ((ep = readdir(dp)) != NULL)
- {
- if (dot_or_dotdot(ep->d_name))
- continue;
- char *dname = concat_path_file(pPath, ep->d_name);
- if (lstat(dname, &statbuf) != 0)
- {
- free(dname);
- continue;
- }
- if (S_ISDIR(statbuf.st_mode))
- {
- double sz = get_dirsize(dname);
- size += sz;
-
- if (worst_dir && (!excluded || strcmp(excluded, ep->d_name) != 0))
- {
- /* Calculate "weighted" size and age
- * w = sz_kbytes * age_mins */
- sz /= 1024;
- long age = (time(NULL) - statbuf.st_mtime) / 60;
- if (age > 0)
- sz *= age;
-
- if (sz > maxsz)
- {
- maxsz = sz;
- free(*worst_dir);
- *worst_dir = xstrdup(ep->d_name);
- }
- }
- }
- else if (S_ISREG(statbuf.st_mode))
- {
- size += statbuf.st_size;
- }
- free(dname);
- }
- closedir(dp);
- return size;
-}
diff --git a/libreport/src/lib/dump_dir.c b/libreport/src/lib/dump_dir.c
deleted file mode 100644
index 8891f911..00000000
--- a/libreport/src/lib/dump_dir.c
+++ /dev/null
@@ -1,839 +0,0 @@
-/*
- Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <sys/utsname.h>
-#include "libreport.h"
-#include "strbuf.h"
-
-// Locking logic:
-//
-// The directory is locked by creating a symlink named .lock inside it,
-// whose value (where it "points to") is the pid of locking process.
-// We use symlink, not an ordinary file, because symlink creation
-// is an atomic operation.
-//
-// There are two cases where after .lock creation, we might discover
-// that directory is not really free:
-// * another process just created new directory, but didn't manage
-// to lock it before us.
-// * another process is deleting the directory, and we managed to sneak in
-// and create .lock after it deleted all files (including .lock)
-// but before it rmdir'ed the empty directory.
-//
-// Both these cases are detected by the fact that file named "time"
-// is not present (it must be present in any valid dump dir).
-// If after locking the dir we don't see time file, we remove the lock
-// at once and back off. What happens in concurrent processes
-// we interfered with?
-// * "create new dump dir" process just re-tries locking.
-// * "delete dump dir" process just retries rmdir.
-//
-// There is another case when we don't find time file:
-// when the directory is not really a *dump* dir - user gave us
-// an ordinary directory name by mistake.
-// We detect it by bailing out of "lock, check time file; sleep
-// and retry if it doesn't exist" loop using a counter.
-//
-// To make locking work reliably, it's important to set timeouts
-// correctly. For example, dd_create should retry locking
-// its newly-created directory much faster than dd_opendir
-// tries to lock the directory it tries to open.
-
-
-// How long to sleep between "symlink fails with EEXIST,
-// readlink fails with ENOENT" tries. Someone just unlocked the dir.
-// We never bail out in this case, we retry forever.
-// The value can be really small:
-#define SYMLINK_RETRY_USLEEP (10*1000)
-
-// How long to sleep when lock file with valid pid is seen by dd_opendir
-// (we are waiting for other process to unlock or die):
-#define WAIT_FOR_OTHER_PROCESS_USLEEP (500*1000)
-
-// How long to sleep when lock file with valid pid is seen by dd_create
-// (some idiot jumped the gun and locked the dir we just created).
-// Must not be the same as WAIT_FOR_OTHER_PROCESS_USLEEP (we depend on this)
-// and should be small (we have the priority in locking, this is OUR dir):
-#define CREATE_LOCK_USLEEP (10*1000)
-
-// How long to sleep after we locked a dir, found no time file
-// (either we are racing with someone, or it's not a dump dir)
-// and unlocked it;
-// and after how many tries to give up and declare it's not a dump dir:
-#define NO_TIME_FILE_USLEEP (50*1000)
-#define NO_TIME_FILE_COUNT 10
-
-// How long to sleep after we unlocked an empty dir, but then rmdir failed
-// (some idiot jumped the gun and locked the dir we are deleting);
-// and after how many tries to give up:
-#define RMDIR_FAIL_USLEEP (10*1000)
-#define RMDIR_FAIL_COUNT 50
-
-
-static char *load_text_file(const char *path, unsigned flags);
-
-static bool isdigit_str(const char *str)
-{
- do
- {
- if (*str < '0' || *str > '9') return false;
- str++;
- } while (*str);
- return true;
-}
-
-static bool exist_file_dir(const char *path)
-{
- struct stat buf;
- if (stat(path, &buf) == 0)
- {
- if (S_ISDIR(buf.st_mode) || S_ISREG(buf.st_mode))
- {
- return true;
- }
- }
- return false;
-}
-
-/* Return values:
- * -1: error (in this case, errno is 0 if error message is already logged)
- * 0: failed to lock (someone else has it locked)
- * 1: success
- */
-static int get_and_set_lock(const char* lock_file, const char* pid)
-{
- while (symlink(pid, lock_file) != 0)
- {
- if (errno != EEXIST)
- {
- if (errno != ENOENT && errno != ENOTDIR && errno != EACCES)
- {
- perror_msg("Can't create lock file '%s'", lock_file);
- errno = 0;
- }
- return -1;
- }
-
- char pid_buf[sizeof(pid_t)*3 + 4];
- ssize_t r = readlink(lock_file, pid_buf, sizeof(pid_buf) - 1);
- if (r < 0)
- {
- if (errno == ENOENT)
- {
- /* Looks like lock_file was deleted */
- usleep(SYMLINK_RETRY_USLEEP); /* avoid CPU eating loop */
- continue;
- }
- perror_msg("Can't read lock file '%s'", lock_file);
- errno = 0;
- return -1;
- }
- pid_buf[r] = '\0';
-
- if (strcmp(pid_buf, pid) == 0)
- {
- log("Lock file '%s' is already locked by us", lock_file);
- return 0;
- }
- if (isdigit_str(pid_buf))
- {
- char pid_str[sizeof("/proc/") + sizeof(pid_buf)];
- sprintf(pid_str, "/proc/%s", pid_buf);
- if (access(pid_str, F_OK) == 0)
- {
- log("Lock file '%s' is locked by process %s", lock_file, pid_buf);
- return 0;
- }
- log("Lock file '%s' was locked by process %s, but it crashed?", lock_file, pid_buf);
- }
- /* The file may be deleted by now by other process. Ignore ENOENT */
- if (unlink(lock_file) != 0 && errno != ENOENT)
- {
- perror_msg("Can't remove stale lock file '%s'", lock_file);
- errno = 0;
- return -1;
- }
- }
-
- VERB1 log("Locked '%s'", lock_file);
- return 1;
-}
-
-static int dd_lock(struct dump_dir *dd, unsigned sleep_usec, int flags)
-{
- if (dd->locked)
- error_msg_and_die("Locking bug on '%s'", dd->dd_dirname);
-
- char pid_buf[sizeof(long)*3 + 2];
- sprintf(pid_buf, "%lu", (long)getpid());
-
- unsigned dirname_len = strlen(dd->dd_dirname);
- char lock_buf[dirname_len + sizeof("/.lock")];
- strcpy(lock_buf, dd->dd_dirname);
- strcpy(lock_buf + dirname_len, "/.lock");
-
- unsigned count = NO_TIME_FILE_COUNT;
- retry:
- while (1)
- {
- int r = get_and_set_lock(lock_buf, pid_buf);
- if (r < 0)
- return r; /* error */
- if (r > 0)
- break; /* locked successfully */
- /* Other process has the lock, wait for it to go away */
- usleep(sleep_usec);
- }
-
- /* Are we called by dd_opendir (as opposed to dd_create)? */
- if (sleep_usec == WAIT_FOR_OTHER_PROCESS_USLEEP) /* yes */
- {
- strcpy(lock_buf + dirname_len, "/time");
- if (access(lock_buf, F_OK) != 0)
- {
- /* time file doesn't exist. We managed to lock the directory
- * which was just created by somebody else, or is almost deleted
- * by delete_file_dir.
- * Unlock and back off.
- */
- strcpy(lock_buf + dirname_len, "/.lock");
- xunlink(lock_buf);
- VERB1 log("Unlocked '%s' (no time file)", lock_buf);
- if (--count == 0)
- {
- errno = EISDIR; /* "this is an ordinary dir, not dump dir" */
- return -1;
- }
- usleep(NO_TIME_FILE_USLEEP);
- goto retry;
- }
- }
-
- dd->locked = true;
- return 0;
-}
-
-static void dd_unlock(struct dump_dir *dd)
-{
- if (dd->locked)
- {
- dd->locked = 0;
-
- unsigned dirname_len = strlen(dd->dd_dirname);
- char lock_buf[dirname_len + sizeof("/.lock")];
- strcpy(lock_buf, dd->dd_dirname);
- strcpy(lock_buf + dirname_len, "/.lock");
- xunlink(lock_buf);
-
- VERB1 log("Unlocked '%s'", lock_buf);
- }
-}
-
-static inline struct dump_dir *dd_init(void)
-{
- return (struct dump_dir*)xzalloc(sizeof(struct dump_dir));
-}
-
-int dd_exist(struct dump_dir *dd, const char *path)
-{
- char *full_path = concat_path_file(dd->dd_dirname, path);
- int ret = exist_file_dir(full_path);
- free(full_path);
- return ret;
-}
-
-void dd_close(struct dump_dir *dd)
-{
- if (!dd)
- return;
-
- dd_unlock(dd);
- if (dd->next_dir)
- {
- closedir(dd->next_dir);
- /* free(dd->next_dir); - WRONG! */
- }
-
- free(dd->dd_dirname);
- free(dd);
-}
-
-static char* rm_trailing_slashes(const char *dir)
-{
- unsigned len = strlen(dir);
- while (len != 0 && dir[len-1] == '/')
- len--;
- return xstrndup(dir, len);
-}
-
-struct dump_dir *dd_opendir(const char *dir, int flags)
-{
- struct dump_dir *dd = dd_init();
-
- dir = dd->dd_dirname = rm_trailing_slashes(dir);
-
- struct stat stat_buf;
- stat(dir, &stat_buf);
- /* & 0666 should remove the executable bit */
- dd->mode = (stat_buf.st_mode & 0666);
-
- errno = 0;
- if (dd_lock(dd, WAIT_FOR_OTHER_PROCESS_USLEEP, flags) < 0)
- {
- if ((flags & DD_OPEN_READONLY) && errno == EACCES)
- {
- /* Directory is not writable. If it seems to be readable,
- * return "read only" dd, not NULL */
- if (stat(dir, &stat_buf) == 0
- && S_ISDIR(stat_buf.st_mode)
- && access(dir, R_OK) == 0
- ) {
- return dd;
- }
- }
- if (errno == EISDIR)
- {
- /* EISDIR: dd_lock can lock the dir, but it sees no time file there,
- * even after it retried many times. It must be an ordinary directory!
- *
- * Without this check, e.g. abrt-action-print happily prints any current
- * directory when run without arguments, because its option -d DIR
- * defaults to "."!
- */
- error_msg("'%s' is not a dump directory", dir);
- }
- else if (errno == ENOENT || errno == ENOTDIR)
- {
- if (!(flags & DD_FAIL_QUIETLY_ENOENT))
- error_msg("'%s' does not exist", dir);
- }
- else
- {
- if (!(flags & DD_FAIL_QUIETLY_EACCES))
- perror_msg("Can't access '%s'", dir);
- }
- dd_close(dd);
- return NULL;
- }
-
- dd->dd_uid = (uid_t)-1L;
- dd->dd_gid = (gid_t)-1L;
- if (geteuid() == 0)
- {
- /* In case caller would want to create more files, he'll need uid:gid */
- struct stat stat_buf;
- if (stat(dir, &stat_buf) != 0 || !S_ISDIR(stat_buf.st_mode))
- {
- error_msg("Can't stat '%s', or it is not a directory", dir);
- dd_close(dd);
- return NULL;
- }
- dd->dd_uid = stat_buf.st_uid;
- dd->dd_gid = stat_buf.st_gid;
- }
-
- return dd;
-}
-
-/* Create a fresh empty debug dump dir.
- *
- * Security: we should not allow users to write new files or write
- * into existing ones, but they should be able to read them.
- *
- * @param uid
- * Crashed application's User Id
- *
- * We currently have only three callers:
- * kernel oops hook: uid -> not saved, so everyone can steal and work with it
- * this hook runs under 0:0
- * ccpp hook: uid=uid of crashed user's binary
- * this hook runs under 0:0
- * python hook: uid=uid of crashed user's script
- * this hook runs under abrt:gid
- *
- * Currently, we set dir's gid to passwd(uid)->pw_gid parameter, and we set uid to
- * abrt's user id. We do not allow write access to group.
- */
-struct dump_dir *dd_create(const char *dir, uid_t uid, mode_t mode)
-{
- /* a little trick to copy read bits from file mode to exec bit of dir mode*/
- mode_t dir_mode = mode | ((mode & 0444) >> 2);
- struct dump_dir *dd = dd_init();
-
- dd->mode = mode;
-
- /* Unlike dd_opendir, can't use realpath: the directory doesn't exist yet,
- * realpath will always return NULL. We don't really have to:
- * dd_opendir(".") makes sense, dd_create(".") does not.
- */
- dir = dd->dd_dirname = rm_trailing_slashes(dir);
-
- const char *last_component = strrchr(dir, '/');
- if (last_component)
- last_component++;
- else
- last_component = dir;
- if (dot_or_dotdot(last_component))
- {
- /* dd_create("."), dd_create(".."), dd_create("dir/."),
- * dd_create("dir/..") and similar are madness, refuse them.
- */
- error_msg("Bad dir name '%s'", dir);
- dd_close(dd);
- return NULL;
- }
-
- bool created_parents = false;
- try_again:
- /* Was creating it with mode 0700 and user as the owner, but this allows
- * the user to replace any file in the directory, changing security-sensitive data
- * (e.g. "uid", "analyzer", "executable")
- */
- if (mkdir(dir, dir_mode) == -1)
- {
- int err = errno;
- if (!created_parents && errno == ENOENT)
- {
- char *p = dd->dd_dirname + 1;
- while ((p = strchr(p, '/')) != NULL)
- {
- *p = '\0';
- int r = (mkdir(dd->dd_dirname, 0755) == 0 || errno == EEXIST);
- *p++ = '/';
- if (!r)
- goto report_err;
- }
- created_parents = true;
- goto try_again;
- }
- report_err:
- errno = err;
- perror_msg("Can't create directory '%s'", dir);
- dd_close(dd);
- return NULL;
- }
-
- if (dd_lock(dd, CREATE_LOCK_USLEEP, /*flags:*/ 0) < 0)
- {
- dd_close(dd);
- return NULL;
- }
-
- /* mkdir's mode (above) can be affected by umask, fix it */
- if (chmod(dir, dir_mode) == -1)
- {
- perror_msg("can't change mode of '%s'", dir);
- dd_close(dd);
- return NULL;
- }
-
- dd->dd_uid = (uid_t)-1L;
- dd->dd_gid = (gid_t)-1L;
- if (uid != (uid_t)-1L)
- {
- /* Get ABRT's user id */
- dd->dd_uid = 0;
- struct passwd *pw = getpwnam("abrt");
- if (pw)
- dd->dd_uid = pw->pw_uid;
- else
- error_msg("user 'abrt' does not exist, using uid 0");
-
- /* Get crashed application's group id */
- /*dd->dd_gid = 0; - dd_init did this already */
- pw = getpwuid(uid);
- if (pw)
- dd->dd_gid = pw->pw_gid;
- else
- error_msg("User %lu does not exist, using gid 0", (long)uid);
-
- if (chown(dir, dd->dd_uid, dd->dd_gid) == -1)
- {
- perror_msg("can't change '%s' ownership to %lu:%lu", dir,
- (long)dd->dd_uid, (long)dd->dd_gid);
- }
- }
-
- return dd;
-}
-
-void dd_create_basic_files(struct dump_dir *dd, uid_t uid)
-{
- char long_str[sizeof(long) * 3 + 2];
-
- time_t t = time(NULL);
- sprintf(long_str, "%lu", (long)t);
- dd_save_text(dd, FILENAME_TIME, long_str);
-
- /* it doesn't make sense to create the uid file if uid == -1 */
- if (uid != (uid_t)-1L)
- {
- sprintf(long_str, "%li", (long)uid);
- dd_save_text(dd, FILENAME_UID, long_str);
- }
-
- struct utsname buf;
- uname(&buf); /* never fails */
- dd_save_text(dd, FILENAME_KERNEL, buf.release);
- dd_save_text(dd, FILENAME_ARCHITECTURE, buf.machine);
- dd_save_text(dd, FILENAME_HOSTNAME, buf.nodename);
-
- char *release = load_text_file("/etc/system-release",
- DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
- if (!release)
- release = load_text_file("/etc/redhat-release", /*flags:*/ 0);
- dd_save_text(dd, FILENAME_OS_RELEASE, release);
- free(release);
-}
-
-void dd_sanitize_mode_and_owner(struct dump_dir *dd)
-{
- /* Don't sanitize if we aren't run under root:
- * we assume that during file creation (by whatever means,
- * even by "hostname >file" in abrt_event.conf)
- * normal umask-based mode setting takes care of correct mode,
- * and uid:gid is, of course, set to user's uid and gid.
- *
- * For root operating on /var/spool/abrt/USERS_PROBLEM, this isn't true:
- * "hostname >file", for example, would create file OWNED BY ROOT!
- * This routine resets mode and uid:gid for all such files.
- */
- if (dd->dd_uid == (uid_t)-1)
- return;
-
- if (!dd->locked)
- error_msg_and_die("dump_dir is not opened"); /* bug */
-
- DIR *d = opendir(dd->dd_dirname);
- if (!d)
- return;
-
- struct dirent *dent;
- while ((dent = readdir(d)) != NULL)
- {
- if (dent->d_name[0] == '.') /* ".lock", ".", ".."? skip */
- continue;
- char *full_path = concat_path_file(dd->dd_dirname, dent->d_name);
- struct stat statbuf;
- if (lstat(full_path, &statbuf) == 0 && S_ISREG(statbuf.st_mode))
- {
- if ((statbuf.st_mode & 0777) != dd->mode)
- chmod(full_path, dd->mode);
- if (statbuf.st_uid != dd->dd_uid || statbuf.st_gid != dd->dd_gid)
- {
- if (chown(full_path, dd->dd_uid, dd->dd_gid) != 0)
- {
- perror_msg("can't change '%s' ownership to %lu:%lu", full_path,
- (long)dd->dd_uid, (long)dd->dd_gid);
- }
- }
- }
- free(full_path);
- }
- closedir(d);
-}
-
-static int delete_file_dir(const char *dir, bool skip_lock_file)
-{
- DIR *d = opendir(dir);
- if (!d)
- {
- /* The caller expects us to error out only if the directory
- * still exists (not deleted). If directory
- * *doesn't exist*, return 0 and clear errno.
- */
- if (errno == ENOENT || errno == ENOTDIR)
- {
- errno = 0;
- return 0;
- }
- return -1;
- }
-
- bool unlink_lock_file = false;
- struct dirent *dent;
- while ((dent = readdir(d)) != NULL)
- {
- if (dot_or_dotdot(dent->d_name))
- continue;
- if (skip_lock_file && strcmp(dent->d_name, ".lock") == 0)
- {
- unlink_lock_file = true;
- continue;
- }
- char *full_path = concat_path_file(dir, dent->d_name);
- if (unlink(full_path) == -1 && errno != ENOENT)
- {
- int err = 0;
- if (errno == EISDIR)
- {
- errno = 0;
- err = delete_file_dir(full_path, /*skip_lock_file:*/ false);
- }
- if (errno || err)
- {
- perror_msg("Can't remove '%s'", full_path);
- free(full_path);
- closedir(d);
- return -1;
- }
- }
- free(full_path);
- }
- closedir(d);
-
- /* Here we know for sure that all files/subdirs we found via readdir
- * were deleted successfully. If rmdir below fails, we assume someone
- * is racing with us and created a new file.
- */
-
- if (unlink_lock_file)
- {
- char *full_path = concat_path_file(dir, ".lock");
- xunlink(full_path);
- free(full_path);
-
- unsigned cnt = RMDIR_FAIL_COUNT;
- do {
- if (rmdir(dir) == 0)
- return 0;
- /* Someone locked the dir after unlink, but before rmdir.
- * This "someone" must be dd_lock().
- * It detects this (by seeing that there is no time file)
- * and backs off at once. So we need to just retry rmdir,
- * with minimal sleep.
- */
- usleep(RMDIR_FAIL_USLEEP);
- } while (--cnt != 0);
- }
-
- int r = rmdir(dir);
- if (r)
- perror_msg("Can't remove directory '%s'", dir);
- return r;
-}
-
-int dd_delete(struct dump_dir *dd)
-{
- int r = delete_file_dir(dd->dd_dirname, /*skip_lock_file:*/ true);
- dd->locked = 0; /* delete_file_dir already removed .lock */
- dd_close(dd);
- return r;
-}
-
-static char *load_text_file(const char *path, unsigned flags)
-{
- FILE *fp = fopen(path, "r");
- if (!fp)
- {
- if (!(flags & DD_FAIL_QUIETLY_ENOENT))
- perror_msg("Can't open file '%s'", path);
- return (flags & DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE ? NULL : xstrdup(""));
- }
-
- struct strbuf *buf_content = strbuf_new();
- int oneline = 0;
- int ch;
- while ((ch = fgetc(fp)) != EOF)
- {
-//TODO? \r -> \n?
-//TODO? strip trailing spaces/tabs?
- if (ch == '\n')
- oneline = (oneline << 1) | 1;
- if (ch == '\0')
- ch = ' ';
- if (isspace(ch) || ch >= ' ') /* used !iscntrl, but it failed on unicode */
- strbuf_append_char(buf_content, ch);
- }
- fclose(fp);
-
- char last = oneline != 0 ? buf_content->buf[buf_content->len - 1] : 0;
- if (last == '\n')
- {
- /* If file contains exactly one '\n' and it is at the end, remove it.
- * This enables users to use simple "echo blah >file" in order to create
- * short string items in dump dirs.
- */
- if (oneline == 1)
- buf_content->buf[--buf_content->len] = '\0';
- }
- else /* last != '\n' */
- {
- /* Last line is unterminated, fix it */
- /* Cases: */
- /* oneline=0: "qwe" - DONT fix this! */
- /* oneline=1: "qwe\nrty" - two lines in fact */
- /* oneline>1: "qwe\nrty\uio" */
- if (oneline >= 1)
- strbuf_append_char(buf_content, '\n');
- }
-
- return strbuf_free_nobuf(buf_content);
-}
-
-static bool save_binary_file(const char *path, const char* data, unsigned size, uid_t uid, gid_t gid, mode_t mode)
-{
- /* the mode is set by the caller, see dd_create() for security analysis */
- unlink(path);
- int fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
- if (fd < 0)
- {
- perror_msg("Can't open file '%s'", path);
- return false;
- }
-
- if (uid != (uid_t)-1L)
- {
- if (fchown(fd, uid, gid) == -1)
- {
- perror_msg("can't change '%s' ownership to %lu:%lu", path, (long)uid, (long)gid);
- }
- }
-
- unsigned r = full_write(fd, data, size);
- close(fd);
- if (r != size)
- {
- error_msg("Can't save file '%s'", path);
- return false;
- }
-
- return true;
-}
-
-char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned flags)
-{
-// if (!dd->locked)
-// error_msg_and_die("dump_dir is not opened"); /* bug */
-
- /* Compat with old abrt dumps. Remove in abrt-2.1 */
- if (strcmp(name, "release") == 0)
- name = FILENAME_OS_RELEASE;
-
- char *full_path = concat_path_file(dd->dd_dirname, name);
- char *ret = load_text_file(full_path, flags);
- free(full_path);
-
- return ret;
-}
-
-char* dd_load_text(const struct dump_dir *dd, const char *name)
-{
- return dd_load_text_ext(dd, name, /*flags:*/ 0);
-}
-
-void dd_save_text(struct dump_dir *dd, const char *name, const char *data)
-{
- if (!dd->locked)
- error_msg_and_die("dump_dir is not opened"); /* bug */
-
- char *full_path = concat_path_file(dd->dd_dirname, name);
- save_binary_file(full_path, data, strlen(data), dd->dd_uid, dd->dd_gid, dd->mode);
- free(full_path);
-}
-
-void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)
-{
- if (!dd->locked)
- error_msg_and_die("dump_dir is not opened"); /* bug */
-
- char *full_path = concat_path_file(dd->dd_dirname, name);
- save_binary_file(full_path, data, size, dd->dd_uid, dd->dd_gid, dd->mode);
- free(full_path);
-}
-
-void add_reported_to(struct dump_dir *dd, const char *line)
-{
- if (!dd->locked)
- error_msg_and_die("dump_dir is not opened"); /* bug */
-
- char *reported_to = dd_load_text_ext(dd, FILENAME_REPORTED_TO, DD_FAIL_QUIETLY_ENOENT | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
- if (reported_to)
- {
- unsigned len_line = strlen(line);
- char *p = reported_to;
- while (*p)
- {
- if (strncmp(p, line, len_line) == 0 && (p[len_line] == '\n' || p[len_line] == '\0'))
- goto ret;
- p = strchrnul(p, '\n');
- if (!*p)
- break;
- p++;
- }
- if (p != reported_to && p[-1] != '\n')
- reported_to = append_to_malloced_string(reported_to, "\n");
- reported_to = append_to_malloced_string(reported_to, line);
- reported_to = append_to_malloced_string(reported_to, "\n");
- }
- else
- reported_to = xasprintf("%s\n", line);
- dd_save_text(dd, FILENAME_REPORTED_TO, reported_to);
- ret:
- free(reported_to);
-}
-
-DIR *dd_init_next_file(struct dump_dir *dd)
-{
-// if (!dd->locked)
-// error_msg_and_die("dump_dir is not opened"); /* bug */
-
- if (dd->next_dir)
- closedir(dd->next_dir);
-
- dd->next_dir = opendir(dd->dd_dirname);
- if (!dd->next_dir)
- {
- error_msg("Can't open directory '%s'", dd->dd_dirname);
- }
-
- return dd->next_dir;
-}
-
-int dd_get_next_file(struct dump_dir *dd, char **short_name, char **full_name)
-{
- if (dd->next_dir == NULL)
- return 0;
-
- struct dirent *dent;
- while ((dent = readdir(dd->next_dir)) != NULL)
- {
- if (is_regular_file(dent, dd->dd_dirname))
- {
- if (short_name)
- *short_name = xstrdup(dent->d_name);
- if (full_name)
- *full_name = concat_path_file(dd->dd_dirname, dent->d_name);
- return 1;
- }
- }
-
- closedir(dd->next_dir);
- dd->next_dir = NULL;
- return 0;
-}
-
-/* Utility function */
-void delete_dump_dir(const char *dirname)
-{
- struct dump_dir *dd = dd_opendir(dirname, /*flags:*/ 0);
- if (dd)
- {
- dd_delete(dd);
- }
-}
diff --git a/libreport/src/lib/encbase64.c b/libreport/src/lib/encbase64.c
deleted file mode 100644
index 9ba11e6c..00000000
--- a/libreport/src/lib/encbase64.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2006 Rob Landley <rob@landley.net>
- *
- * Copyright (C) 2010 ABRT team
- * Copyright (C) 2010 RedHat Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#include "libreport.h" /* xmalloc */
-
-/* Conversion table for base 64 */
-static const char tbl_base64[65 /*+ 2*/] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
- 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', '+', '/',
- '=' /* termination character */,
- // '\n', '\0' /* needed for uudecode.c */
-};
-
-/* Conversion table for uuencode
-const char tbl_uuencode[65] ALIGN1 = {
- '`', '!', '"', '#', '$', '%', '&', '\'',
- '(', ')', '*', '+', ',', '-', '.', '/',
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', ':', ';', '<', '=', '>', '?',
- '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
- 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
- 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
- '`'
-};
-*/
-
-/*
- * Encode bytes at S of length LENGTH.
- * Result will be 0-terminated, and must point to a writable
- * buffer of at least 1+BASE64_LENGTH(length) bytes,
- * where BASE64_LENGTH(len) = 4 * ((LENGTH + 2) / 3)
- */
-static void encode_64bit(char *p, const void *src, int length, const char *tbl)
-{
- const unsigned char *s = (const unsigned char *)src;
-
- /* Transform the 3x8 bits to 4x6 bits */
- while (length > 0) {
- unsigned s1, s2;
-
- /* Are s[1], s[2] valid or should be assumed 0? */
- s1 = s2 = 0;
- length -= 3; /* can be >=0, -1, -2 */
- if (length >= -1) {
- s1 = s[1];
- if (length >= 0)
- s2 = s[2];
- }
- *p++ = tbl[s[0] >> 2];
- *p++ = tbl[((s[0] & 3) << 4) + (s1 >> 4)];
- *p++ = tbl[((s1 & 0xf) << 2) + (s2 >> 6)];
- *p++ = tbl[s2 & 0x3f];
- s += 3;
- }
- /* Zero-terminate */
- *p = '\0';
- /* If length is -2 or -1, pad last char or two */
- while (length) {
- *--p = tbl[64];
- length++;
- }
-}
-
-char *encode_base64(const void *src, int length)
-{
- char *dst = (char *)xmalloc(4 * ((length + 2) / 3) + 1);
- encode_64bit(dst, src, length, tbl_base64);
- return dst;
-}
diff --git a/libreport/src/lib/event_config.c b/libreport/src/lib/event_config.c
deleted file mode 100644
index 35ed8d36..00000000
--- a/libreport/src/lib/event_config.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-GHashTable *g_event_config_list;
-static GHashTable *g_event_config_symlinks;
-
-event_option_t *new_event_option(void)
-{
- return xzalloc(sizeof(event_option_t));
-}
-
-event_config_t *new_event_config(void)
-{
- return xzalloc(sizeof(event_config_t));
-}
-
-void free_event_option(event_option_t *p)
-{
- if (!p)
- return;
- free(p->eo_name);
- free(p->eo_value);
- free(p->eo_label);
- free(p->eo_note_html);
- //free(p->eo_description);
- //free(p->eo_allowed_value);
- free(p);
-}
-
-void free_event_config(event_config_t *p)
-{
- if (!p)
- return;
-
- free(p->screen_name);
- free(p->description);
- free(p->long_descr);
- free(p->ec_creates_items);
- free(p->ec_requires_items);
- free(p->ec_exclude_items_by_default);
- free(p->ec_include_items_by_default);
- free(p->ec_exclude_items_always);
- GList *opt;
- for (opt = p->options; opt; opt = opt->next)
- free_event_option(opt->data);
- g_list_free(p->options);
-
- free(p);
-}
-
-
-static int cmp_event_option_name_with_string(gconstpointer a, gconstpointer b)
-{
- const event_option_t *evopt = a;
- return !evopt->eo_name || strcmp(evopt->eo_name, (char *)b) != 0;
-}
-
-event_option_t *get_event_option_from_list(const char *name, GList *options)
-{
- GList *elem = g_list_find_custom(options, name, &cmp_event_option_name_with_string);
- if (elem)
- return (event_option_t *)elem->data;
- return NULL;
-}
-
-static void load_config_files(const char *dir_path)
-{
- DIR *dir;
- struct dirent *dent;
-
- /* Load .conf files */
- dir = opendir(dir_path);
- if (!dir)
- return;
- while ((dent = readdir(dir)) != NULL)
- {
- char *ext = strrchr(dent->d_name, '.');
- if (!ext)
- continue;
- if (strcmp(ext + 1, "conf") != 0)
- continue;
-
- char *fullname = concat_path_file(dir_path, dent->d_name);
-
- *ext = '\0';
- event_config_t *event_config = get_event_config(dent->d_name);
- bool new_config = (!event_config);
- if (new_config)
- event_config = new_event_config();
-
- map_string_h *keys_and_values = new_map_string();
-
- load_conf_file(fullname, keys_and_values, /*skipKeysWithoutValue:*/ false);
- free(fullname);
-
- /* Insert or replace every key/value from keys_and_values to event_config->option */
- GHashTableIter iter;
- char *name;
- char *value;
- g_hash_table_iter_init(&iter, keys_and_values);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- event_option_t *opt;
- GList *elem = g_list_find_custom(event_config->options, name,
- cmp_event_option_name_with_string);
- if (elem)
- {
- opt = elem->data;
- // log("conf: replacing '%s' value:'%s'->'%s'", name, opt->value, value);
- free(opt->eo_value);
- }
- else
- {
- // log("conf: new value %s='%s'", name, value);
- opt = new_event_option();
- opt->eo_name = xstrdup(name);
- }
- opt->eo_value = xstrdup(value);
- if (!elem)
- event_config->options = g_list_append(event_config->options, opt);
- }
-
- free_map_string(keys_and_values);
-
- if (new_config)
- g_hash_table_replace(g_event_config_list, xstrdup(dent->d_name), event_config);
- }
- closedir(dir);
-}
-
-/* (Re)loads data from /etc/abrt/events/foo.{xml,conf} and ~/.abrt/events/foo.conf */
-void load_event_config_data(void)
-{
- free_event_config_data();
-
- if (!g_event_config_list)
- g_event_config_list = g_hash_table_new_full(
- /*hash_func*/ g_str_hash,
- /*key_equal_func:*/ g_str_equal,
- /*key_destroy_func:*/ free,
- /*value_destroy_func:*/ (GDestroyNotify) free_event_config
- );
- if (!g_event_config_symlinks)
- g_event_config_symlinks = g_hash_table_new_full(
- /*hash_func*/ g_str_hash,
- /*key_equal_func:*/ g_str_equal,
- /*key_destroy_func:*/ free,
- /*value_destroy_func:*/ free
- );
-
- DIR *dir;
- struct dirent *dent;
-
- /* Load .xml files */
- dir = opendir(EVENTS_DIR);
- if (!dir)
- return;
- while ((dent = readdir(dir)) != NULL)
- {
- char *ext = strrchr(dent->d_name, '.');
- if (!ext)
- continue;
- if (strcmp(ext + 1, "xml") != 0)
- continue;
-
- char *fullname = concat_path_file(EVENTS_DIR, dent->d_name);
- *ext = '\0';
-
- struct stat buf;
- if (0 != lstat(fullname, &buf))
- continue;
- if (S_ISLNK(buf.st_mode))
- {
- GError *error = NULL;
- gchar *link = g_file_read_link(fullname, &error);
- if (error != NULL)
- error_msg_and_die("Error reading symlink '%s': %s", fullname, error->message);
-
- gchar *target = g_path_get_basename(link);
- char *ext = strrchr(target, '.');
- if (!ext || 0 != strcmp(ext + 1, "xml"))
- error_msg_and_die("Invalid event symlink '%s': expected it to"
- " point to another xml file", fullname);
- *ext = '\0';
- g_hash_table_replace(g_event_config_symlinks, xstrdup(dent->d_name), target);
- g_free(link);
- /* don't free target, it is owned by the hash table now */
- continue;
- }
-
- event_config_t *event_config = get_event_config(dent->d_name);
- bool new_config = (!event_config);
- if (new_config)
- event_config = new_event_config();
-
- load_event_description_from_file(event_config, fullname);
- free(fullname);
-
- if (new_config)
- g_hash_table_replace(g_event_config_list, xstrdup(dent->d_name), event_config);
- }
- closedir(dir);
-
- load_config_files(EVENTS_DIR);
-
- char *HOME = getenv("HOME");
- if (!HOME || !HOME[0])
- return;
- HOME = concat_path_file(HOME, ".abrt/events");
- load_config_files(HOME);
- free(HOME);
-}
-
-/* Frees all loaded data */
-void free_event_config_data(void)
-{
- if (g_event_config_list)
- {
- g_hash_table_destroy(g_event_config_list);
- g_event_config_list = NULL;
- }
- if (g_event_config_symlinks)
- {
- g_hash_table_destroy(g_event_config_symlinks);
- g_event_config_symlinks = NULL;
- }
-}
-
-event_config_t *get_event_config(const char *name)
-{
- if (!g_event_config_list)
- return NULL;
- if (g_event_config_symlinks)
- {
- char *link = g_hash_table_lookup(g_event_config_symlinks, name);
- if (link)
- name = link;
- }
- return g_hash_table_lookup(g_event_config_list, name);
-}
-
-GList *export_event_config(const char *event_name)
-{
- GList *env_list = NULL;
-
- event_config_t *config = get_event_config(event_name);
- if (config)
- {
- GList *lopt;
- for (lopt = config->options; lopt; lopt = lopt->next)
- {
- event_option_t *opt = lopt->data;
- if (!opt->eo_value)
- continue;
- char *var_val = xasprintf("%s=%s", opt->eo_name, opt->eo_value);
- VERB3 log("Exporting '%s'", var_val);
- env_list = g_list_prepend(env_list, var_val);
- putenv(var_val);
- }
- }
-
- return env_list;
-}
-
-void unexport_event_config(GList *env_list)
-{
- while (env_list)
- {
- char *var_val = env_list->data;
- VERB3 log("Unexporting '%s'", var_val);
- safe_unsetenv(var_val);
- env_list = g_list_remove(env_list, var_val);
- free(var_val);
- }
-}
-
-/* return NULL if successful otherwise appropriate error message */
-static char *validate_event_option(event_option_t *opt)
-{
- if (!opt->eo_allow_empty && (!opt->eo_value || !opt->eo_value[0]))
- return xstrdup(_("Missing mandatory value"));
-
- /* if value is NULL and allow-empty yes than it doesn't make sence to check it */
- if (!opt->eo_value)
- return NULL;
-
- const gchar *s = NULL;
- if (!g_utf8_validate(opt->eo_value, -1, &s))
- return xasprintf(_("Invalid utf8 character '%c'"), *s);
-
- switch (opt->eo_type) {
- case OPTION_TYPE_TEXT:
- case OPTION_TYPE_PASSWORD:
- break;
- case OPTION_TYPE_NUMBER:
- {
- char *endptr;
- errno = 0;
- long r = strtol(opt->eo_value, &endptr, 10);
- (void) r;
- if (errno != 0 || endptr == opt->eo_value || *endptr != '\0')
- return xasprintf(_("Invalid number '%s'"), opt->eo_value);
-
- break;
- }
- case OPTION_TYPE_BOOL:
- if (strcmp(opt->eo_value, "yes") != 0
- && strcmp(opt->eo_value, "no") != 0
- && strcmp(opt->eo_value, "on") != 0
- && strcmp(opt->eo_value, "off") != 0
- && strcmp(opt->eo_value, "1") != 0
- && strcmp(opt->eo_value, "0") != 0)
- {
- return xasprintf(_("Invalid boolean value '%s'"), opt->eo_value);
- }
- break;
- case OPTION_TYPE_HINT_HTML:
- return NULL;
- default:
- return xstrdup(_("Unsupported option type"));
- };
-
- return NULL;
-}
-
-GHashTable *validate_event(const char *event_name)
-{
- event_config_t *config = get_event_config(event_name);
- if (!config)
- return NULL;
-
- GHashTable *errors = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
- GList *li;
-
- for (li = config->options; li; li = li->next)
- {
- event_option_t *opt = (event_option_t *)li->data;
- char *err = validate_event_option(opt);
- if (err)
- g_hash_table_insert(errors, xstrdup(opt->eo_name), err);
- }
-
- if (g_hash_table_size(errors))
- return errors;
-
- g_hash_table_destroy(errors);
-
- return NULL;
-}
diff --git a/libreport/src/lib/event_xml_parser.c b/libreport/src/lib/event_xml_parser.c
deleted file mode 100644
index 4a2e4493..00000000
--- a/libreport/src/lib/event_xml_parser.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-#include "event_config.h"
-
-#define EVENT_ELEMENT "event"
-#define LABEL_ELEMENT "label"
-#define DESCRIPTION_ELEMENT "description"
-#define LONG_DESCR_ELEMENT "long-description"
-#define ALLOW_EMPTY_ELEMENT "allow-empty"
-#define NOTE_HTML_ELEMENT "note-html"
-#define CREATES_ELEMENT "creates-items"
-#define OPTION_ELEMENT "option"
-//#define ACTION_ELEMENT "action"
-#define NAME_ELEMENT "name"
-#define DEFAULT_VALUE_ELEMENT "default-value"
-
-#define REQUIRES_ELEMENT "requires-items"
-#define EXCL_BY_DEFAULT_ELEMENT "exclude-items-by-default"
-#define INCL_BY_DEFAULT_ELEMENT "include-items-by-default"
-#define EXCL_ALWAYS_ELEMENT "exclude-items-always"
-#define EXCL_BINARY_ELEMENT "exclude-binary-items"
-
-
-struct my_parse_data
-{
- event_config_t *event_config;
- event_option_t *cur_option;
- const char *cur_locale;
- char *attribute_lang;
-};
-
-static const char *const option_types[] =
-{
- [OPTION_TYPE_TEXT ] = "text",
- [OPTION_TYPE_BOOL ] = "bool",
- [OPTION_TYPE_PASSWORD ] = "password",
- [OPTION_TYPE_NUMBER ] = "number",
- [OPTION_TYPE_HINT_HTML] = "hint-html",
- [OPTION_TYPE_INVALID ] = NULL
-};
-
-// Return xml:lang value for <foo xml:lang="value"> if value matches current locale,
-// "" if foo has no xml:lang attribute at all,
-// else (if xml:lang is for some other locale) return NULL
-//
-static char *get_element_lang(struct my_parse_data *parse_data, const gchar **att_names, const gchar **att_values)
-{
- char *short_locale_end = strchr(parse_data->cur_locale, '_');
- VERB3 log("locale: %s", parse_data->cur_locale);
- int i;
- for (i = 0; att_names[i] != NULL; ++i)
- {
- VERB3 log("attr: %s:%s", att_names[i], att_values[i]);
- if (strcmp(att_names[i], "xml:lang") == 0)
- {
- if (strcmp(att_values[i], parse_data->cur_locale) == 0)
- {
- VERB3 log("found translation for: %s", parse_data->cur_locale);
- return xstrdup(att_values[i]);
- }
-
- /* try to match shorter locale
- * e.g: "cs" with cs_CZ
- */
- if (short_locale_end
- && strncmp(att_values[i], parse_data->cur_locale, short_locale_end - parse_data->cur_locale) == 0
- ) {
- VERB3 log("found translation for shortlocale: %s", parse_data->cur_locale);
- return xstrndup(att_values[i], short_locale_end - parse_data->cur_locale);
- }
- }
- }
- /* if the element has no attribute then it's a default non-localized value */
- if (i == 0)
- return xstrdup("");
- /* if the element is in different language than the current locale */
- return NULL;
-}
-
-static int cmp_event_option_name_with_string(gconstpointer a, gconstpointer b)
-{
- const event_option_t *evopt = a;
- /* "When it is not a match?" */
- return !evopt->eo_name || strcmp(evopt->eo_name, (char *)b) != 0;
-}
-
-static void consume_cur_option(struct my_parse_data *parse_data)
-{
- event_option_t *opt = parse_data->cur_option;
- if (!opt)
- return;
- parse_data->cur_option = NULL;
-
- event_config_t *event_config = parse_data->event_config;
-
- /* Example of "nameless" option: <option type="hint-html">
- * The remaining code does not like "nameless" options
- * (strcmp would segfault, etc), so provide invented name:
- */
- if (!opt->eo_name)
- opt->eo_name = xasprintf("%u", (unsigned)g_list_length(event_config->options));
-
- GList *elem = g_list_find_custom(event_config->options, opt->eo_name, cmp_event_option_name_with_string);
- if (elem)
- {
- /* we already have option with such name */
- event_option_t *old_opt = elem->data;
- if (old_opt->eo_value)
- {
- /* ...and it already has a value, which
- * overrides xml-defined default one:
- */
- free(opt->eo_value);
- opt->eo_value = old_opt->eo_value;
- old_opt->eo_value = NULL;
- }
- //log("xml: replacing '%s' value:'%s'->'%s'", opt->eo_name, old_opt->eo_value, opt->eo_value);
- free_event_option(old_opt);
- elem->data = opt;
- }
- else
- {
- //log("xml: new value %s='%s'", opt->eo_name, opt->eo_value);
- event_config->options = g_list_append(event_config->options, opt);
- }
-}
-
-// Called for opening tags <foo bar="baz">
-static void start_element(GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error)
-{
- //log("start: %s", element_name);
-
- struct my_parse_data *parse_data = user_data;
-
- if (strcmp(element_name, OPTION_ELEMENT) == 0)
- {
- if (parse_data->cur_option)
- {
- error_msg("error, option nested in option");
- return;
- }
-
- event_option_t *opt = parse_data->cur_option = new_event_option();
- int i;
-
- for (i = 0; attribute_names[i] != NULL; ++i)
- {
- VERB2 log("attr: %s:%s", attribute_names[i], attribute_values[i]);
- if (strcmp(attribute_names[i], "name") == 0)
- {
- free(opt->eo_name);
- opt->eo_name = xstrdup(attribute_values[i]);
- }
- else if (strcmp(attribute_names[i], "type") == 0)
- {
- option_type_t type;
- for (type = OPTION_TYPE_TEXT; type < OPTION_TYPE_INVALID; ++type)
- {
- if (strcmp(option_types[type], attribute_values[i]) == 0)
- opt->eo_type = type;
- }
- }
- }
- }
- else
- if (strcmp(element_name, LABEL_ELEMENT) == 0
- || strcmp(element_name, DESCRIPTION_ELEMENT) == 0
- || strcmp(element_name, LONG_DESCR_ELEMENT) == 0
- || strcmp(element_name, NAME_ELEMENT) == 0
- || strcmp(element_name, NOTE_HTML_ELEMENT) == 0
- ) {
- free(parse_data->attribute_lang);
- parse_data->attribute_lang = get_element_lang(parse_data, attribute_names, attribute_values);
- }
-}
-
-// Called for close tags </foo>
-static void end_element(GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
-{
- struct my_parse_data *parse_data = user_data;
-
- free(parse_data->attribute_lang);
- parse_data->attribute_lang = NULL;
-
- if (strcmp(element_name, OPTION_ELEMENT) == 0)
- {
- consume_cur_option(parse_data);
- }
- if (strcmp(element_name, EVENT_ELEMENT) == 0)
- {
- consume_cur_option(parse_data);
- }
-}
-
-// Called for character data
-// text is not nul-terminated
-static void text(GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error)
-{
- struct my_parse_data *parse_data = user_data;
- event_config_t *ui = parse_data->event_config;
-
- const gchar *inner_element = g_markup_parse_context_get_element(context);
- char *text_copy = xstrndup(text, text_len);
- event_option_t *opt = parse_data->cur_option;
- if (opt)
- {
- if (strcmp(inner_element, LABEL_ELEMENT) == 0)
- {
- if (parse_data->attribute_lang != NULL) /* if it isn't for other locale */
- {
- /* set the value only if we found a value for the current locale
- * OR the label is still not set and we found the default value
- */
- if (parse_data->attribute_lang[0] != '\0'
- || !opt->eo_label /* && parse_data->attribute_lang is "" - always true */
- ) {
- VERB2 log("new label:'%s'", text_copy);
- free(opt->eo_label);
- opt->eo_label = text_copy;
- }
- }
- return;
- }
- /*
- * we can add a separate field for the default value
- * in that case we can implement features like "reset to default value"
- * but for now using "value" should be enough and clients doesn't
- * have to know about the "defaul-value"
- */
- if (strcmp(inner_element, DEFAULT_VALUE_ELEMENT) == 0)
- {
- VERB2 log("default value:'%s'", text_copy);
- free(opt->eo_value);
- opt->eo_value = text_copy;
- return;
- }
-
- if (strcmp(inner_element, NOTE_HTML_ELEMENT) == 0)
- {
- if (parse_data->attribute_lang != NULL) /* if it isn't for other locale */
- {
- /* set the value only if we found a value for the current locale
- * OR the label is still not set and we found the default value
- */
- if (parse_data->attribute_lang[0] != '\0'
- || !opt->eo_note_html /* && parse_data->attribute_lang is "" - always true */
- ) {
- VERB2 log("html note:'%s'", text_copy);
- free(opt->eo_note_html);
- opt->eo_note_html = text_copy;
- }
- }
- return;
- }
-
- if (strcmp(inner_element, ALLOW_EMPTY_ELEMENT) == 0)
- {
- VERB2 log("allow-empty:'%s'", text_copy);
- opt->eo_allow_empty = string_to_bool(text_copy);
- return;
- }
- /*
- if (strcmp(inner_element, DESCRIPTION_ELEMENT) == 0)
- {
- VERB2 log("tooltip:'%s'", text_copy);
- free(opt->eo_description);
- opt->eo_description = text_copy;
- return;
- }
- */
- }
- else
- {
- /* we're not in option, so the description is for the event */
- /*
- if (strcmp(inner_element, ACTION_ELEMENT) == 0)
- {
- VERB2 log("action description:'%s'", text_copy);
- free(ui->action);
- ui->action = text_copy;
- return;
- }
- */
- if (strcmp(inner_element, CREATES_ELEMENT) == 0)
- {
- VERB2 log("ec_creates_items:'%s'", text_copy);
- free(ui->ec_creates_items);
- ui->ec_creates_items = text_copy;
- return;
- }
- if (strcmp(inner_element, NAME_ELEMENT) == 0)
- {
- if (parse_data->attribute_lang != NULL) /* if it isn't for other locale */
- {
- /* set the value only if we found a value for the current locale
- * OR the label is still not set and we found the default value
- */
- if (parse_data->attribute_lang[0] != '\0'
- || !ui->screen_name /* && parse_data->attribute_lang is "" - always true */
- ) {
- VERB2 log("event name:'%s'", text_copy);
- free(ui->screen_name);
- ui->screen_name = text_copy;
- }
- }
- return;
- }
- if (strcmp(inner_element, DESCRIPTION_ELEMENT) == 0)
- {
- VERB3 log("event description:'%s'", text_copy);
-
- if (parse_data->attribute_lang != NULL) /* if it isn't for other locale */
- {
- /* set the value only if we found a value for the current locale
- * OR the description is still not set and we found the default value
- */
- if (parse_data->attribute_lang[0] != '\0'
- || !ui->description /* && parse_data->attribute_lang is "" - always true */
- ) {
- free(ui->description);
- ui->description = text_copy;
- }
- }
- return;
- }
- if (strcmp(inner_element, LONG_DESCR_ELEMENT) == 0)
- {
- VERB3 log("event long description:'%s'", text_copy);
-
- if (parse_data->attribute_lang != NULL) /* if it isn't for other locale */
- {
- /* set the value only if we found a value for the current locale
- * OR the description is still not set and we found the default value
- */
- if (parse_data->attribute_lang[0] != '\0'
- || !ui->long_descr /* && parse_data->attribute_lang is "" - always true */
- ) {
- free(ui->long_descr);
- ui->long_descr = text_copy;
- }
- }
- return;
- }
- if (strcmp(inner_element, REQUIRES_ELEMENT) == 0)
- {
- free(ui->ec_requires_items);
- ui->ec_requires_items = text_copy;
- return;
- }
- if (strcmp(inner_element, EXCL_BY_DEFAULT_ELEMENT) == 0)
- {
- free(ui->ec_exclude_items_by_default);
- ui->ec_exclude_items_by_default = text_copy;
- return;
- }
- if (strcmp(inner_element, INCL_BY_DEFAULT_ELEMENT) == 0)
- {
- free(ui->ec_include_items_by_default);
- ui->ec_include_items_by_default = text_copy;
- return;
- }
- if (strcmp(inner_element, EXCL_ALWAYS_ELEMENT) == 0)
- {
- free(ui->ec_exclude_items_always);
- ui->ec_exclude_items_always = text_copy;
- return;
- }
- if (strcmp(inner_element, EXCL_BINARY_ELEMENT) == 0)
- {
- ui->ec_exclude_binary_items = string_to_bool(text_copy);
- free(text_copy);
- return;
- }
- }
- free(text_copy);
-}
-
- // Called for strings that should be re-saved verbatim in this same
- // position, but are not otherwise interpretable. At the moment
- // this includes comments and processing instructions.
- // text is not nul-terminated
-static void passthrough(GMarkupParseContext *context,
- const gchar *passthrough_text,
- gsize text_len,
- gpointer user_data,
- GError **error)
-{
- VERB3 log("passthrough");
-}
-
-// Called on error, including one set by other
-// methods in the vtable. The GError should not be freed.
-static void error(GMarkupParseContext *context,
- GError *error,
- gpointer user_data)
-{
- error_msg("error in XML parsing");
-}
-
-/* this function takes 2 parameters
- * ui -> pointer to event_config_t
- * filename -> filename to read
- * event_config_t contains list of options, which is malloced by hits function
- * and must be freed by the caller
- */
-
-void load_event_description_from_file(event_config_t *event_config, const char* filename)
-{
- struct my_parse_data parse_data = { event_config, NULL, NULL , NULL };
- parse_data.cur_locale = setlocale(LC_ALL, NULL);
-
- GMarkupParser parser;
- memset(&parser, 0, sizeof(parser)); /* just in case */
- parser.start_element = &start_element;
- parser.end_element = &end_element;
- parser.text = &text;
- parser.passthrough = &passthrough;
- parser.error = &error;
-
- GMarkupParseContext *context = g_markup_parse_context_new(
- &parser, G_MARKUP_TREAT_CDATA_AS_TEXT,
- &parse_data, /*GDestroyNotify:*/ NULL);
-
- FILE* fin = fopen(filename, "r");
- if (fin != NULL)
- {
- size_t read_bytes = 0;
- char buff[1024];
- while ((read_bytes = fread(buff, 1, 1024, fin)) != 0)
- {
- g_markup_parse_context_parse(context, buff, read_bytes, NULL);
- }
- fclose(fin);
- }
-
- g_markup_parse_context_free(context);
-
- consume_cur_option(&parse_data); /* just in case */
- free(parse_data.attribute_lang); /* just in case */
-}
diff --git a/libreport/src/lib/get_cmdline.c b/libreport/src/lib/get_cmdline.c
deleted file mode 100644
index 04254660..00000000
--- a/libreport/src/lib/get_cmdline.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-/* If s is a string with only printable ASCII chars
- * and has no spaces, ", ', and \, copy it verbatim.
- * Else, encapsulate it in single quotes, and
- * encode ', " and \ with \c escapes.
- * Control chars are encoded as \r, \n, \t, or \xNN.
- * In all cases, terminating NUL is added
- * and the pointer to it is returned.
- */
-static char *append_escaped(char *start, const char *s)
-{
- char *dst = start;
- const unsigned char *p = (unsigned char *)s;
-
- while (1)
- {
- const unsigned char *old_p = p;
- while (*p > ' ' && *p <= 0x7e && *p != '\"' && *p != '\'' && *p != '\\')
- p++;
- if (dst == start)
- {
- if (p != (unsigned char *)s && *p == '\0')
- {
- /* entire word does not need escaping and quoting */
- strcpy(dst, s);
- dst += strlen(s);
- return dst;
- }
- *dst++ = '\'';
- }
-
- strncpy(dst, (char *)old_p, (p - old_p));
- dst += (p - old_p);
-
- if (*p == '\0')
- {
- *dst++ = '\'';
- *dst = '\0';
- return dst;
- }
-
- char hex_char_buf[5];
- const char *a;
- switch (*p)
- {
- case '\r': a = "\\r"; break;
- case '\n': a = "\\n"; break;
- case '\t': a = "\\t"; break;
- case '\'': a = "\\\'"; break;
- case '\"': a = "\\\""; break;
- case '\\': a = "\\\\"; break;
- case ' ': a = " "; break;
- default:
- /* Build \xNN string */
- hex_char_buf[0] = '\\';
- hex_char_buf[1] = 'x';
- hex_char_buf[2] = "0123456789abcdef"[*p >> 4];
- hex_char_buf[3] = "0123456789abcdef"[*p & 0xf];
- hex_char_buf[4] = '\0';
- a = hex_char_buf;
- }
- strcpy(dst, a);
- dst += strlen(a);
- p++;
- }
-}
-
-static char* get_escaped(const char *path, char separator)
-{
- char *escaped = NULL;
-
- int fd = open(path, O_RDONLY);
- if (fd >= 0)
- {
- char *dst = NULL;
- unsigned total_esc_len = 0;
- while (total_esc_len < 1024 * 1024) /* paranoia check */
- {
- /* read and escape one block */
- char buffer[4 * 1024 + 1];
- int len = read(fd, buffer, sizeof(buffer) - 1);
- if (len <= 0)
- break;
- buffer[len] = '\0';
-
- /* string CC can expand into '\xNN\xNN' and thus needs len*4 + 3 bytes,
- * including terminating NUL.
- * We add +1 for possible \n added at the very end.
- */
- escaped = xrealloc(escaped, total_esc_len + len*4 + 4);
- char *src = buffer;
- dst = escaped + total_esc_len;
- while (1)
- {
- /* escape till next NUL char */
- char *d = append_escaped(dst, src);
- total_esc_len += (d - dst);
- dst = d;
- src += strlen(src) + 1;
- if ((src - buffer) >= len)
- break;
- *dst++ = separator;
- }
-
- }
-
- if (dst)
- {
- if (separator == '\n')
- *dst++ = separator;
- *dst = '\0';
- }
-
- close(fd);
- }
-
- return escaped;
-}
-
-char* get_cmdline(pid_t pid)
-{
- char path[sizeof("/proc/%lu/cmdline") + sizeof(long)*3];
- sprintf(path, "/proc/%lu/cmdline", (long)pid);
- return get_escaped(path, ' ');
-}
-
-char* get_environ(pid_t pid)
-{
- char path[sizeof("/proc/%lu/environ") + sizeof(long)*3];
- sprintf(path, "/proc/%lu/environ", (long)pid);
- return get_escaped(path, '\n');
-}
diff --git a/libreport/src/lib/glib_support.c b/libreport/src/lib/glib_support.c
deleted file mode 100644
index b59b37c0..00000000
--- a/libreport/src/lib/glib_support.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Copyright (C) 2011 ABRT team
- Copyright (C) 2011 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-void list_free_with_free(GList *list)
-{
- GList *li;
- for (li = list; li; li = g_list_next(li))
- free(li->data);
- g_list_free(list);
-}
diff --git a/libreport/src/lib/hash_sha1.c b/libreport/src/lib/hash_sha1.c
deleted file mode 100644
index ad4ea531..00000000
--- a/libreport/src/lib/hash_sha1.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Based on shasum from http://www.netsw.org/crypto/hash/
- * Majorly hacked up to use Dr Brian Gladman's sha1 code
- *
- * Copyright (C) 2002 Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
- * Copyright (C) 2003 Glenn L. McGrath
- * Copyright (C) 2003 Erik Andersen
- *
- * Copyright (C) 2010 ABRT team
- * Copyright (C) 2010 RedHat Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * ---------------------------------------------------------------------------
- * Issue Date: 10/11/2002
- *
- * This is a byte oriented version of SHA1 that operates on arrays of bytes
- * stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor
- *
- * ---------------------------------------------------------------------------
- */
-#include "libreport.h"
-#include <byteswap.h>
-
-#if defined(__BIG_ENDIAN__) && __BIG_ENDIAN__
-# define SHA1_BIG_ENDIAN 1
-# define SHA1_LITTLE_ENDIAN 0
-#elif __BYTE_ORDER == __BIG_ENDIAN
-# define SHA1_BIG_ENDIAN 1
-# define SHA1_LITTLE_ENDIAN 0
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
-# define SHA1_BIG_ENDIAN 0
-# define SHA1_LITTLE_ENDIAN 1
-#else
-# error "Can't determine endianness"
-#endif
-
-#define rotl32(x,n) (((x) << (n)) | ((x) >> (32 - (n))))
-/* for sha256: */
-#define rotr32(x,n) (((x) >> (n)) | ((x) << (32 - (n))))
-/* for sha512: */
-#define rotr64(x,n) (((x) >> (n)) | ((x) << (64 - (n))))
-
-
-/* Generic 64-byte helpers for 64-byte block hashes */
-static void common64_hash(sha1_ctx_t *ctx, const void *buffer, size_t len);
-static void common64_end(sha1_ctx_t *ctx, int swap_needed);
-
-
-/* sha1 specific code */
-
-static void sha1_process_block64(sha1_ctx_t *ctx)
-{
- static const uint32_t rconsts[] = {
- 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
- };
- int i, j;
- int cnt;
- uint32_t W[16+16];
- uint32_t a, b, c, d, e;
-
- /* On-stack work buffer frees up one register in the main loop
- * which otherwise will be needed to hold ctx pointer */
- for (i = 0; i < 16; i++)
- if (SHA1_BIG_ENDIAN)
- W[i] = W[i+16] = ((uint32_t*)ctx->wbuffer)[i];
- else
- W[i] = W[i+16] = bswap_32(((uint32_t*)ctx->wbuffer)[i]);
-
- a = ctx->hash[0];
- b = ctx->hash[1];
- c = ctx->hash[2];
- d = ctx->hash[3];
- e = ctx->hash[4];
-
- /* 4 rounds of 20 operations each */
- cnt = 0;
- for (i = 0; i < 4; i++) {
- j = 19;
- do {
- uint32_t work;
-
- work = c ^ d;
- if (i == 0) {
- work = (work & b) ^ d;
- if (j <= 3)
- goto ge16;
- /* Used to do bswap_32 here, but this
- * requires ctx (see comment above) */
- work += W[cnt];
- } else {
- if (i == 2)
- work = ((b | c) & d) | (b & c);
- else /* i = 1 or 3 */
- work ^= b;
- ge16:
- W[cnt] = W[cnt+16] = rotl32(W[cnt+13] ^ W[cnt+8] ^ W[cnt+2] ^ W[cnt], 1);
- work += W[cnt];
- }
- work += e + rotl32(a, 5) + rconsts[i];
-
- /* Rotate by one for next time */
- e = d;
- d = c;
- c = /* b = */ rotl32(b, 30);
- b = a;
- a = work;
- cnt = (cnt + 1) & 15;
- } while (--j >= 0);
- }
-
- ctx->hash[0] += a;
- ctx->hash[1] += b;
- ctx->hash[2] += c;
- ctx->hash[3] += d;
- ctx->hash[4] += e;
-}
-
-void sha1_begin(sha1_ctx_t *ctx)
-{
- ctx->hash[0] = 0x67452301;
- ctx->hash[1] = 0xefcdab89;
- ctx->hash[2] = 0x98badcfe;
- ctx->hash[3] = 0x10325476;
- ctx->hash[4] = 0xc3d2e1f0;
- ctx->total64 = 0;
- /* for sha256: ctx->process_block = sha1_process_block64; */
-}
-
-void sha1_hash(sha1_ctx_t *ctx, const void *buffer, size_t len)
-{
- common64_hash(ctx, buffer, len);
-}
-
-/* May be used also for sha256 */
-void sha1_end(sha1_ctx_t *ctx, void *resbuf)
-{
- unsigned hash_size;
-
- /* SHA stores total in BE, need to swap on LE arches: */
- common64_end(ctx, /*swap_needed:*/ SHA1_LITTLE_ENDIAN);
-
- hash_size = 5; /* (ctx->process_block == sha1_process_block64) ? 5 : 8; */
- /* This way we do not impose alignment constraints on resbuf: */
- if (SHA1_LITTLE_ENDIAN) {
- unsigned i;
- for (i = 0; i < hash_size; ++i)
- ctx->hash[i] = bswap_32(ctx->hash[i]);
- }
- memcpy(resbuf, ctx->hash, sizeof(ctx->hash[0]) * hash_size);
-}
-
-
-/* Generic 64-byte helpers for 64-byte block hashes */
-
-/*#define PROCESS_BLOCK(ctx) ctx->process_block(ctx)*/
-#define PROCESS_BLOCK(ctx) sha1_process_block64(ctx)
-
-/* Feed data through a temporary buffer.
- * The internal buffer remembers previous data until it has 64
- * bytes worth to pass on.
- */
-static void common64_hash(sha1_ctx_t *ctx, const void *buffer, size_t len)
-{
- unsigned bufpos = ctx->total64 & 63;
-
- ctx->total64 += len;
-
- while (1) {
- unsigned remaining = 64 - bufpos;
- if (remaining > len)
- remaining = len;
- /* Copy data into aligned buffer */
- memcpy(ctx->wbuffer + bufpos, buffer, remaining);
- len -= remaining;
- buffer = (const char *)buffer + remaining;
- bufpos += remaining;
- /* clever way to do "if (bufpos != 64) break; ... ; bufpos = 0;" */
- bufpos -= 64;
- if (bufpos != 0)
- break;
- /* Buffer is filled up, process it */
- PROCESS_BLOCK(ctx);
- /*bufpos = 0; - already is */
- }
-}
-
-/* Process the remaining bytes in the buffer */
-static void common64_end(sha1_ctx_t *ctx, int swap_needed)
-{
- unsigned bufpos = ctx->total64 & 63;
- /* Pad the buffer to the next 64-byte boundary with 0x80,0,0,0... */
- ctx->wbuffer[bufpos++] = 0x80;
-
- /* This loop iterates either once or twice, no more, no less */
- while (1) {
- unsigned remaining = 64 - bufpos;
- memset(ctx->wbuffer + bufpos, 0, remaining);
- /* Do we have enough space for the length count? */
- if (remaining >= 8) {
- /* Store the 64-bit counter of bits in the buffer */
- uint64_t t = ctx->total64 << 3;
- if (swap_needed)
- t = bswap_64(t);
- /* wbuffer is suitably aligned for this */
- *(uint64_t *) (&ctx->wbuffer[64 - 8]) = t;
- }
- PROCESS_BLOCK(ctx);
- if (remaining >= 8)
- break;
- bufpos = 0;
- }
-}
diff --git a/libreport/src/lib/is_in_string_list.c b/libreport/src/lib/is_in_string_list.c
deleted file mode 100644
index 2d7bb61b..00000000
--- a/libreport/src/lib/is_in_string_list.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Copyright (C) 2011 ABRT team
- Copyright (C) 2011 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-bool is_in_string_list(const char *name, char **v)
-{
- while (*v)
- {
- if (strcmp(*v, name) == 0)
- return true;
- v++;
- }
- return false;
-}
diff --git a/libreport/src/lib/iso_date_string.c b/libreport/src/lib/iso_date_string.c
deleted file mode 100644
index 475f7863..00000000
--- a/libreport/src/lib/iso_date_string.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright (C) 2011 ABRT team
- Copyright (C) 2011 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "libreport.h"
-
-char *iso_date_string(time_t *pt)
-{
- static char buf[sizeof("YYYY-MM-DD-HH:MM:SS") + 4];
-
- time_t t;
- struct tm *ptm = localtime(pt ? pt : (time(&t), &t));
- strftime(buf, sizeof(buf), "%Y-%m-%d-%H:%M:%S", ptm);
-
- return buf;
-}
diff --git a/libreport/src/lib/kernel-tainted.c b/libreport/src/lib/kernel-tainted.c
deleted file mode 100644
index ace7c29e..00000000
--- a/libreport/src/lib/kernel-tainted.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- Copyright (C) 2011 ABRT team
- Copyright (C) 2011 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "libreport.h"
-
-/* From RHEL6 kernel/panic.c: */
-static const int tnts_short[] = {
- 'P' ,
- 'F' ,
- 'S' ,
- 'R' ,
- 'M' ,
- 'B' ,
- 'U' ,
- 'D' ,
- 'A' ,
- 'W' ,
- 'C' ,
- 'I' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- '-' ,
- 'H' ,
- 'T' ,
-};
-
-/**
- * print_tainted - return a string to represent the kernel taint state.
- *
- * 'P' - Proprietary module has been loaded.
- * 'F' - Module has been forcibly loaded.
- * 'S' - SMP with CPUs not designed for SMP.
- * 'R' - User forced a module unload.
- * 'M' - System experienced a machine check exception.
- * 'B' - System has hit bad_page.
- * 'U' - Userspace-defined naughtiness.
- * 'D' - Kernel has oopsed before
- * 'A' - ACPI table overridden.
- * 'W' - Taint on warning.
- * 'C' - modules from drivers/staging are loaded.
- * 'I' - Working around severe firmware bug.
- * 'H' - Hardware is unsupported.
- * T - Tech_preview
- */
-
-
-static const char *const tnts_long[] = {
- "Proprietary module has been loaded.",
- "Module has been forcibly loaded.",
- "SMP with CPUs not designed for SMP.",
- "User forced a module unload.",
- "System experienced a machine check exception.",
- "System has hit bad_page.",
- "Userspace-defined naughtiness.",
- "Kernel has oopsed before.",
- "ACPI table overridden.",
- "Taint on warning.",
- "Modules from drivers/staging are loaded.",
- "Working around severe firmware bug.",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- "Hardware is unsupported.",
- "Tech_preview",
-};
-
-char *kernel_tainted_short(unsigned tainted)
-{
- char *tnt = xzalloc(ARRAY_SIZE(tnts_short) + 1);
- int i = 0;
- while (tainted)
- {
- if (0x1 & tainted)
- tnt[i] = tnts_short[i];
- else
- tnt[i] = '-';
-
- ++i;
- tainted >>= 1;
- }
-
- return tnt;
-}
-
-GList *kernel_tainted_long(unsigned tainted)
-{
- int i = 0;
- GList *tnt = NULL;
-
- while (tainted)
- {
- if (0x1 & tainted && tnts_long[i])
- tnt = g_list_append(tnt, xstrdup(tnts_long[i]));
-
- ++i;
- tainted >>= 1;
- }
-
- return tnt;
-}
diff --git a/libreport/src/lib/load_plugin_settings.c b/libreport/src/lib/load_plugin_settings.c
deleted file mode 100644
index e07ea7d4..00000000
--- a/libreport/src/lib/load_plugin_settings.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-/* Returns false if open failed.
- * Returns empty hash if conf file is empty.
- * TODO: better error detection?
- */
-bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue)
-{
- FILE *fp = stdin;
- if (strcmp(pPath, "-") != 0)
- {
- fp = fopen(pPath, "r");
- if (!fp)
- return false;
- }
-
- char *line;
- while ((line = xmalloc_fgetline(fp)) != NULL)
- {
- bool in_quote = false;
- /* We are reusing line buffer to form temporary
- * "key\0value\0..." in its beginning
- */
- char *value = NULL;
- char *src;
- char *dst;
- for (src = dst = line; *src; src++)
- {
- char c = *src;
- if (c == '"')
- {
- in_quote = !in_quote;
- }
- if (!in_quote)
- {
- if (isspace(c))
- {
- continue;
- }
- if (c == '#' && dst == line)
- {
- break;
- }
- if (c == '=')
- {
- *dst++ = '\0'; /* terminate key */
- value = dst; /* remember where value starts */
- continue;
- }
- }
- *dst++ = c; /* store next key or value char */
- }
- *dst = '\0'; /* terminate value */
-
- /* Skip broken or empty lines. */
- if (!value)
- goto free_line;
-
- /* Skip lines with empty key. */
- if (line[0] == '\0')
- goto free_line;
-
- if (skipKeysWithoutValue && value[0] == '\0')
- goto free_line;
-
- /* Skip lines with unclosed quotes. */
- if (in_quote)
- goto free_line;
-
- g_hash_table_replace(settings, xstrdup(line), xstrdup(value));
- free_line:
- free(line);
- }
-
- if (fp != stdin)
- fclose(fp);
-
- return true;
-}
diff --git a/libreport/src/lib/logging.c b/libreport/src/lib/logging.c
deleted file mode 100644
index 72aa2423..00000000
--- a/libreport/src/lib/logging.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-/*
- * Utility routines.
- *
- */
-#include "libreport.h"
-
-void (*g_custom_logger)(const char*);
-const char *msg_prefix = "";
-const char *msg_eol = "\n";
-int logmode = LOGMODE_STDIO;
-int xfunc_error_retval = EXIT_FAILURE;
-int g_verbose;
-
-void xfunc_die(void)
-{
- exit(xfunc_error_retval);
-}
-
-static void verror_msg_helper(const char *s,
- va_list p,
- const char* strerr,
- int flags)
-{
- char *msg;
- int prefix_len, strerr_len, msgeol_len, used;
-
- if (!logmode)
- return;
-
- used = vasprintf(&msg, s, p);
- if (used < 0)
- return;
-
- /* This is ugly and costs +60 bytes compared to multiple
- * fprintf's, but is guaranteed to do a single write.
- * This is needed for e.g. when multiple children
- * can produce log messages simultaneously. */
-
- prefix_len = msg_prefix[0] ? strlen(msg_prefix) + 2 : 0;
- strerr_len = strerr ? strlen(strerr) : 0;
- msgeol_len = strlen(msg_eol);
- /* +3 is for ": " before strerr and for terminating NUL */
- msg = (char*) xrealloc(msg, prefix_len + used + strerr_len + msgeol_len + 3);
- /* TODO: maybe use writev instead of memmoving? Need full_writev? */
- if (prefix_len) {
- char *p;
- memmove(msg + prefix_len, msg, used);
- used += prefix_len;
- p = stpcpy(msg, msg_prefix);
- p[0] = ':';
- p[1] = ' ';
- }
- if (strerr) {
- if (s[0]) {
- msg[used++] = ':';
- msg[used++] = ' ';
- }
- strcpy(&msg[used], strerr);
- used += strerr_len;
- }
- strcpy(&msg[used], msg_eol);
-
- if (flags & LOGMODE_STDIO) {
- fflush(stdout);
- full_write(STDERR_FILENO, msg, used + msgeol_len);
- }
- msg[used] = '\0'; /* remove msg_eol (usually "\n") */
- if (flags & LOGMODE_SYSLOG) {
- syslog(LOG_ERR, "%s", msg + prefix_len);
- }
- if ((flags & LOGMODE_CUSTOM) && g_custom_logger) {
- g_custom_logger(msg + prefix_len);
- }
- free(msg);
-}
-
-void log_msg(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- verror_msg_helper(s, p, NULL, logmode);
- va_end(p);
-}
-
-void error_msg(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- verror_msg_helper(s, p, NULL, (logmode | LOGMODE_CUSTOM));
- va_end(p);
-}
-
-void error_msg_and_die(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- verror_msg_helper(s, p, NULL, (logmode | LOGMODE_CUSTOM));
- va_end(p);
- xfunc_die();
-}
-
-void perror_msg(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- /* Guard against "<error message>: Success" */
- verror_msg_helper(s, p, errno ? strerror(errno) : NULL, (logmode | LOGMODE_CUSTOM));
- va_end(p);
-}
-
-void perror_msg_and_die(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- /* Guard against "<error message>: Success" */
- verror_msg_helper(s, p, errno ? strerror(errno) : NULL, (logmode | LOGMODE_CUSTOM));
- va_end(p);
- xfunc_die();
-}
-
-void die_out_of_memory(void)
-{
- error_msg_and_die("Out of memory, exiting");
-}
diff --git a/libreport/src/lib/make_descr.c b/libreport/src/lib/make_descr.c
deleted file mode 100644
index adee54af..00000000
--- a/libreport/src/lib/make_descr.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-
-char *make_description(problem_data_t *problem_data, char **names_to_skip, unsigned max_text_size, unsigned desc_flags)
-{
- struct strbuf *buf_dsc = strbuf_new();
-
- GList *list = g_hash_table_get_keys(problem_data);
- list = g_list_sort(list, (GCompareFunc)strcmp);
- GList *l;
-
- /* Print one-liners. Format:
- * NAME1: <maybe more spaces>VALUE1
- * NAME2: <maybe more spaces>VALUE2
- */
- bool empty = true;
- l = list;
- while (l)
- {
- const char *key = l->data;
- l = l->next;
-
- /* Skip items we are not interested in */
-//TODO: optimize by doing this once, not 3 times:
- if (names_to_skip && is_in_string_list(key, names_to_skip))
- continue;
-
- struct problem_item *item = g_hash_table_lookup(problem_data, key);
- if (!item)
- continue;
-
- if ((desc_flags & MAKEDESC_SHOW_ONLY_LIST) && !(item->flags & CD_FLAG_LIST))
- continue;
-
- if ((item->flags & CD_FLAG_TXT)
- && strlen(item->content) <= max_text_size
- ) {
- char *formatted = format_problem_item(item);
- char *output = formatted ? formatted : item->content;
- char *eol = strchr(output, '\n');
- if (!eol)
- {
- int pad = 16 - (strlen(key) + 2);
- if (pad < 0) pad = 0;
- strbuf_append_strf(buf_dsc, "%s: %*s%s\n", key, pad, "", output);
- empty = false;
- }
- free(formatted);
- }
- }
-
- bool append_empty_line = !empty;
- if (desc_flags & MAKEDESC_SHOW_FILES)
- {
- /* Print file info. Format:
- * <empty line if needed>
- * NAME1: <maybe more spaces>Binary file, NNN bytes
- * NAME2: <maybe more spaces>Text file, NNN bytes
- *
- * In many cases, it is useful to know how big binary files are
- * (for example, helps with diagnosing bug upload problems)
- */
- l = list;
- while (l)
- {
- const char *key = l->data;
- l = l->next;
-
- /* Skip items we are not interested in */
- if (names_to_skip && is_in_string_list(key, names_to_skip))
- continue;
-
- struct problem_item *item = g_hash_table_lookup(problem_data, key);
- if (!item)
- continue;
-
- if ((desc_flags & MAKEDESC_SHOW_ONLY_LIST) && !(item->flags & CD_FLAG_LIST))
- continue;
-
- if ((item->flags & CD_FLAG_BIN)
- || ((item->flags & CD_FLAG_TXT) && strlen(item->content) > max_text_size)
- ) {
- if (append_empty_line)
- strbuf_append_char(buf_dsc, '\n');
- append_empty_line = false;
-
- struct stat statbuf;
- int stat_err = 0;
- if (item->flags & CD_FLAG_BIN)
- stat_err = stat(item->content, &statbuf);
- else
- statbuf.st_size = strlen(item->content);
-
- /* We don't print item->content for CD_FLAG_BIN, as it is
- * always "/path/to/dump/dir/KEY" - not informative.
- */
- int pad = 16 - (strlen(key) + 2);
- if (pad < 0) pad = 0;
- strbuf_append_strf(buf_dsc,
- (!stat_err ? "%s: %*s%s file, %llu bytes\n" : "%s: %*s%s file\n"),
- key,
- pad, "",
- ((item->flags & CD_FLAG_BIN) ? "Binary" : "Text"),
- (long long)statbuf.st_size
- );
- empty = false;
- }
- }
- }
-
- if (desc_flags & MAKEDESC_SHOW_MULTILINE)
- {
- /* Print multi-liners. Format:
- * <empty line if needed>
- * NAME:
- * :LINE1
- * :LINE2
- * :LINE3
- */
- l = list;
- while (l)
- {
- const char *key = l->data;
- l = l->next;
-
- /* Skip items we are not interested in */
- if (names_to_skip && is_in_string_list(key, names_to_skip))
- continue;
-
- struct problem_item *item = g_hash_table_lookup(problem_data, key);
- if (!item)
- continue;
-
- if ((desc_flags & MAKEDESC_SHOW_ONLY_LIST) && !(item->flags & CD_FLAG_LIST))
- continue;
-
- if ((item->flags & CD_FLAG_TXT)
- && strlen(item->content) <= max_text_size
- ) {
- char *formatted = format_problem_item(item);
- char *output = formatted ? formatted : item->content;
- char *eol = strchr(output, '\n');
- if (eol)
- {
- if (!empty)
- strbuf_append_char(buf_dsc, '\n');
- strbuf_append_str(buf_dsc, key);
- strbuf_append_str(buf_dsc, ":\n");
- for (;;)
- {
- eol = strchrnul(output, '\n');
- strbuf_append_strf(buf_dsc, ":%.*s\n", (int)(eol - output), output);
- if (*eol == '\0' || eol[1] == '\0')
- break;
- output = eol + 1;
- }
- empty = false;
- }
- free(formatted);
- }
- }
- }
-
- g_list_free(list);
-
- return strbuf_free_nobuf(buf_dsc);
-}
-
-char* make_description_mailx(problem_data_t *problem_data)
-{
- struct strbuf *buf_dsc = strbuf_new();
- struct strbuf *buf_additional_files = strbuf_new();
- struct strbuf *buf_duphash_file = strbuf_new();
- struct strbuf *buf_common_files = strbuf_new();
-
- GHashTableIter iter;
- char *name;
- struct problem_item *value;
- g_hash_table_iter_init(&iter, problem_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- if (value->flags & CD_FLAG_TXT)
- {
- if ((strcmp(name, FILENAME_DUPHASH) != 0)
- && (strcmp(name, FILENAME_ARCHITECTURE) != 0)
- && (strcmp(name, FILENAME_KERNEL) != 0)
- && (strcmp(name, FILENAME_PACKAGE) != 0)
- ) {
- strbuf_append_strf(buf_additional_files, "%s\n-----\n%s\n\n", name, value->content);
- }
- else if (strcmp(name, FILENAME_DUPHASH) == 0)
- strbuf_append_strf(buf_duphash_file, "%s\n-----\n%s\n\n", name, value->content);
- else
- strbuf_append_strf(buf_common_files, "%s\n-----\n%s\n\n", name, value->content);
- }
- }
-
- char *common_files = strbuf_free_nobuf(buf_common_files);
- char *duphash_file = strbuf_free_nobuf(buf_duphash_file);
- char *additional_files = strbuf_free_nobuf(buf_additional_files);
-
- strbuf_append_strf(buf_dsc, "Duplicate check\n=====\n%s\n\n", duphash_file);
- strbuf_append_strf(buf_dsc, "Common information\n=====\n%s\n\n", common_files);
- strbuf_append_strf(buf_dsc, "Additional information\n=====\n%s\n", additional_files);
-
- free(common_files);
- free(duphash_file);
- free(additional_files);
-
- return strbuf_free_nobuf(buf_dsc);
-}
-
-/* Items we don't want to include to bz / logger */
-static const char *const blacklisted_items[] = {
- CD_DUMPDIR ,
- FILENAME_ANALYZER ,
- FILENAME_COREDUMP ,
- FILENAME_HOSTNAME ,
- FILENAME_DUPHASH ,
- FILENAME_UUID ,
- FILENAME_COUNT ,
- FILENAME_TAINTED_SHORT,
- NULL
-};
-
-char* make_description_bz(problem_data_t *problem_data)
-{
- return make_description(
- problem_data,
- (char**)blacklisted_items,
- /*max_text_size:*/ CD_TEXT_ATT_SIZE,
- MAKEDESC_SHOW_FILES | MAKEDESC_SHOW_MULTILINE
- );
-}
-
-char* make_description_logger(problem_data_t *problem_data)
-{
- return make_description(
- problem_data,
- (char**)blacklisted_items,
- /*max_text_size:*/ CD_TEXT_ATT_SIZE,
- MAKEDESC_SHOW_FILES | MAKEDESC_SHOW_MULTILINE
- );
-}
diff --git a/libreport/src/lib/overlapping_strcpy.c b/libreport/src/lib/overlapping_strcpy.c
deleted file mode 100644
index 824d7bd6..00000000
--- a/libreport/src/lib/overlapping_strcpy.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * Copyright (C) 2010 ABRT team
- * Copyright (C) 2010 RedHat Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "libreport.h"
-
-/* Like strcpy but can copy overlapping strings. */
-void overlapping_strcpy(char *dst, const char *src)
-{
- /* Cheap optimization for dst == src case -
- * better to have it here than in many callers.
- */
- if (dst != src)
- {
- while ((*dst = *src) != '\0')
- {
- dst++;
- src++;
- }
- }
-}
diff --git a/libreport/src/lib/parse_options.c b/libreport/src/lib/parse_options.c
deleted file mode 100644
index f2f876b3..00000000
--- a/libreport/src/lib/parse_options.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include <getopt.h>
-#include "libreport.h"
-#include "parse_options.h"
-
-#define USAGE_OPTS_WIDTH 30
-#define USAGE_GAP 2
-
-const char *g_progname;
-
-const char *abrt_init(char **argv)
-{
- char *env_verbose = getenv("ABRT_VERBOSE");
- if (env_verbose)
- g_verbose = atoi(env_verbose);
-
- g_progname = strrchr(argv[0], '/');
- if (g_progname)
- g_progname++;
- else
- g_progname = argv[0];
-
- char *pfx = getenv("ABRT_PROG_PREFIX");
- if (pfx && string_to_bool(pfx))
- msg_prefix = g_progname;
-
- return g_progname;
-}
-
-void export_abrt_envvars(int pfx)
-{
- putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
- if (pfx)
- {
- putenv((char*)"ABRT_PROG_PREFIX=1");
- msg_prefix = g_progname;
- }
-}
-
-void show_usage_and_die(const char *usage, const struct options *opt)
-{
- fputs(_("Usage: "), stderr);
- while (*usage)
- {
- int len = strchrnul(usage, '\b') - usage;
- if (len > 0)
- {
- fprintf(stderr, "%.*s", len, usage);
- usage += len;
- }
- if (*usage == '\b')
- {
- fputs(g_progname, stderr);
- usage++;
- }
- }
- fputs("\n\n", stderr);
-
- for (; opt->type != OPTION_END; opt++)
- {
- size_t pos;
- int pad;
-
- if (opt->type == OPTION_GROUP)
- {
- fputc('\n', stderr);
- if (*opt->help)
- fprintf(stderr, "%s\n", opt->help);
- continue;
- }
-
- pos = fprintf(stderr, " ");
- if (opt->short_name)
- pos += fprintf(stderr, "-%c", opt->short_name);
-
- if (opt->short_name && opt->long_name)
- pos += fprintf(stderr, ", ");
-
- if (opt->long_name)
- pos += fprintf(stderr, "--%s", opt->long_name);
-
- if (opt->argh)
- {
- const char *fmt = " %s";
- if (opt->type == OPTION_OPTSTRING)
- fmt = "[%s]";
- pos += fprintf(stderr, fmt, opt->argh);
- }
-
- if (pos <= USAGE_OPTS_WIDTH)
- pad = USAGE_OPTS_WIDTH - pos;
- else
- {
- fputc('\n', stderr);
- pad = USAGE_OPTS_WIDTH;
- }
- fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opt->help);
- }
- fputc('\n', stderr);
- exit(1);
-}
-
-static int parse_opt_size(const struct options *opt)
-{
- unsigned size = 0;
- for (; opt->type != OPTION_END; opt++)
- size++;
-
- return size;
-}
-
-unsigned parse_opts(int argc, char **argv, const struct options *opt,
- const char *usage)
-{
- int help = 0;
- int size = parse_opt_size(opt);
- const int LONGOPT_OFFSET = 256;
-
- struct strbuf *shortopts = strbuf_new();
-
- struct option *longopts = xzalloc(sizeof(longopts[0]) * (size+2));
- struct option *curopt = longopts;
- int ii;
- for (ii = 0; ii < size; ++ii)
- {
- curopt->name = opt[ii].long_name;
- /*curopt->flag = 0; - xzalloc did it */
- if (opt[ii].short_name)
- curopt->val = opt[ii].short_name;
- else
- curopt->val = LONGOPT_OFFSET + ii;
-
- switch (opt[ii].type)
- {
- case OPTION_BOOL:
- curopt->has_arg = no_argument;
- if (opt[ii].short_name)
- strbuf_append_char(shortopts, opt[ii].short_name);
- break;
- case OPTION_INTEGER:
- case OPTION_STRING:
- case OPTION_LIST:
- curopt->has_arg = required_argument;
- if (opt[ii].short_name)
- strbuf_append_strf(shortopts, "%c:", opt[ii].short_name);
- break;
- case OPTION_OPTSTRING:
- curopt->has_arg = optional_argument;
- if (opt[ii].short_name)
- strbuf_append_strf(shortopts, "%c::", opt[ii].short_name);
- break;
- case OPTION_GROUP:
- case OPTION_END:
- break;
- }
- //log("curopt[%d].name:'%s' .has_arg:%d .flag:%p .val:%d", (int)(curopt-longopts),
- // curopt->name, curopt->has_arg, curopt->flag, curopt->val);
- /*
- * getopt_long() thinks that NULL name marks the end of longopts.
- * Example:
- * [0] name:'verbose' val:'v'
- * [1] name:NULL val:'c'
- * [2] name:'force' val:'f'
- * ... ... ...
- * In this case, --force won't be accepted!
- * Therefore we can only advance if name is not NULL.
- */
- if (curopt->name)
- curopt++;
- }
- curopt->name = "help";
- curopt->has_arg = no_argument;
- curopt->flag = &help;
- curopt->val = 1;
- /* xzalloc did it already:
- curopt++;
- curopt->name = NULL;
- curopt->has_arg = 0;
- curopt->flag = NULL;
- curopt->val = 0;
- */
-
- unsigned retval = 0;
- while (1)
- {
- int c = getopt_long(argc, argv, shortopts->buf, longopts, NULL);
-
- if (c == -1)
- break;
-
- if (c == '?' || help)
- {
- free(longopts);
- strbuf_free(shortopts);
- show_usage_and_die(usage, opt);
- }
-
- for (ii = 0; ii < size; ++ii)
- {
- if (opt[ii].short_name == c || LONGOPT_OFFSET + ii == c)
- {
- if (ii < sizeof(retval)*8)
- retval |= (1 << ii);
-
- if (opt[ii].value != NULL) switch (opt[ii].type)
- {
- case OPTION_BOOL:
- *(int*)(opt[ii].value) += 1;
- break;
- case OPTION_INTEGER:
- *(int*)(opt[ii].value) = xatoi(optarg);
- break;
- case OPTION_STRING:
- case OPTION_OPTSTRING:
- if (optarg)
- *(char**)(opt[ii].value) = (char*)optarg;
- break;
- case OPTION_LIST:
- *(GList**)(opt[ii].value) = g_list_append(*(GList**)(opt[ii].value), optarg);
- break;
- case OPTION_GROUP:
- case OPTION_END:
- break;
- }
- }
- }
- }
-
- free(longopts);
- strbuf_free(shortopts);
-
- return retval;
-}
diff --git a/libreport/src/lib/parse_release.c b/libreport/src/lib/parse_release.c
deleted file mode 100644
index 0071cfe3..00000000
--- a/libreport/src/lib/parse_release.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-// caller is reposible for freeing *product* and *version*
-static void parse_release(const char *release, char** product, char** version, bool append_rhel_version)
-{
- if (strstr(release, "Rawhide"))
- {
- *product = xstrdup("Fedora");
- *version = xstrdup("rawhide");
- VERB3 log("%s: version:'%s' product:'%s'", __func__, *version, *product);
- return;
- }
-
- struct strbuf *buf_product = strbuf_new();
- if (strstr(release, "Fedora"))
- strbuf_append_str(buf_product, "Fedora");
- else if (strstr(release, "Red Hat Enterprise Linux"))
- strbuf_append_str(buf_product, "Red Hat Enterprise Linux");
- else
- {
- /* TODO: add logic for parsing other distros' names here */
- strbuf_append_str(buf_product, release);
- }
-
- const char *r = strstr(release, "release");
- const char *space = r ? strchr(r, ' ') : NULL;
-
- struct strbuf *buf_version = strbuf_new();
- if (space)
- {
- space++;
- while (*space != '\0' && *space != ' ')
- {
- /* Eat string like "5.2" */
- strbuf_append_char(buf_version, *space);
- if (append_rhel_version
- && strcmp(buf_product->buf, "Red Hat Enterprise Linux") == 0
- ) {
- strbuf_append_char(buf_product, ' ');
- strbuf_append_char(buf_product, *space);
- }
- append_rhel_version = false;
- space++;
- }
- }
-
- *version = strbuf_free_nobuf(buf_version);
- *product = strbuf_free_nobuf(buf_product);
-
- VERB3 log("%s: version:'%s' product:'%s'", __func__, *version, *product);
-}
-
-void parse_release_for_bz(const char *release, char** product, char** version)
-{
- /* Fedora/RH bugzilla uses "Red Hat Enterprise Linux N" product RHEL */
- parse_release(release, product, version, /*append_rhel_version:*/ true);
-}
-
-void parse_release_for_rhts(const char *release, char** product, char** version)
-{
- /* RHTS uses "Red Hat Enterprise Linux" product for RHEL */
- parse_release(release, product, version, /*append_rhel_version:*/ false);
-}
diff --git a/libreport/src/lib/problem_data.c b/libreport/src/lib/problem_data.c
deleted file mode 100644
index ed88f9d8..00000000
--- a/libreport/src/lib/problem_data.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- Copyright (C) 2010 Denys Vlasenko (dvlasenk@redhat.com)
- Copyright (C) 2010 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-static void free_problem_item(void *ptr)
-{
- if (ptr)
- {
- struct problem_item *item = (struct problem_item *)ptr;
- free(item->content);
- free(item);
- }
-}
-
-char *format_problem_item(struct problem_item *item)
-{
- if (!item)
- return xstrdup("(nullitem)");
-
- if (item->flags & CD_FLAG_UNIXTIME)
- {
- errno = 0;
- char *end;
- time_t time = strtol(item->content, &end, 10);
- if (!errno && !*end && end != item->content)
- {
- char timeloc[256];
- int success = strftime(timeloc, sizeof(timeloc), "%c", localtime(&time));
- if (success)
- return xstrdup(timeloc);
- }
- }
- return NULL;
-}
-
-/* problem_data["name"] = { "content", CD_FLAG_foo_bits } */
-
-problem_data_t *new_problem_data(void)
-{
- return g_hash_table_new_full(g_str_hash, g_str_equal,
- free, free_problem_item);
-}
-
-void add_basics_to_problem_data(problem_data_t *pd)
-{
- const char *analyzer = get_problem_item_content_or_NULL(pd, FILENAME_ANALYZER);
- if (analyzer == NULL)
- add_to_problem_data(pd, "analyzer", "libreport");
-
- /* If application didn't provide dupe hash, we generate it
- * from all components, so we at least eliminate the exact same
- * reports
- */
- if (get_problem_item_content_or_NULL(pd, FILENAME_DUPHASH) == NULL)
- {
- /* start hash */
- sha1_ctx_t sha1ctx;
- sha1_begin(&sha1ctx);
-
- /*
- * To avoid spurious hash differences, sort keys so that elements are
- * always processed in the same order:
- */
- GList *list = g_hash_table_get_keys(pd);
- list = g_list_sort(list, (GCompareFunc)strcmp);
- GList *l = list;
- while (l)
- {
- const char *key = l->data;
- l = l->next;
- struct problem_item *item = g_hash_table_lookup(pd, key);
- /* do not hash items which are binary (item->flags & CD_FLAG_BIN).
- * Their ->content is full file name, with path. Path is always
- * different and will make hash differ even if files are the same.
- */
- if (item->flags & CD_FLAG_BIN)
- continue;
- sha1_hash(&sha1ctx, item->content, strlen(item->content));
- }
- g_list_free(list);
-
- /* end hash */
- char hash_bytes[SHA1_RESULT_LEN];
- sha1_end(&sha1ctx, hash_bytes);
- char hash_str[SHA1_RESULT_LEN*2 + 1];
- bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
-
- add_to_problem_data(pd, FILENAME_DUPHASH, hash_str);
- }
-
- pid_t pid = getpid();
- if (pid > 0)
- {
- char buf[PATH_MAX+1];
- char *exe = xasprintf("/proc/%u/exe", pid);
- ssize_t read = readlink(exe, buf, PATH_MAX);
- if (read > 0)
- {
- buf[read] = 0;
- VERB2 log("reporting initiated from: %s", buf);
- add_to_problem_data(pd, FILENAME_EXECUTABLE, buf);
- }
- free(exe);
-
-//#ifdef WITH_RPM
- /* FIXME: component should be taken from rpm using librpm
- * which means we need to link against it :(
- * or run rpm -qf executable ??
- */
- /* Fedora/RHEL rpm specific piece of code */
- const char *component = get_problem_item_content_or_NULL(pd, FILENAME_COMPONENT);
- //FIXME: this REALLY needs to go away, or every report will be assigned to abrt
- if (component == NULL) // application didn't specify component
- add_to_problem_data(pd, FILENAME_COMPONENT, "abrt");
-//#endif
- }
-}
-
-void add_to_problem_data_ext(problem_data_t *problem_data,
- const char *name,
- const char *content,
- unsigned flags)
-{
- if (!(flags & CD_FLAG_BIN))
- flags |= CD_FLAG_TXT;
- if (!(flags & CD_FLAG_ISEDITABLE))
- flags |= CD_FLAG_ISNOTEDITABLE;
-
- struct problem_item *item = (struct problem_item *)xzalloc(sizeof(*item));
- item->content = xstrdup(content);
- item->flags = flags;
- g_hash_table_replace(problem_data, xstrdup(name), item);
-}
-
-void add_to_problem_data(problem_data_t *problem_data,
- const char *name,
- const char *content)
-{
- add_to_problem_data_ext(problem_data, name, content, CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE);
-}
-
-const char *get_problem_item_content_or_die(problem_data_t *problem_data, const char *key)
-{
- struct problem_item *item = get_problem_data_item_or_NULL(problem_data, key);
- if (!item)
- error_msg_and_die("Error accessing problem data: no ['%s']", key);
- return item->content;
-}
-
-const char *get_problem_item_content_or_NULL(problem_data_t *problem_data, const char *key)
-{
- struct problem_item *item = get_problem_data_item_or_NULL(problem_data, key);
- if (!item)
- return NULL;
- return item->content;
-}
-
-
-/* Miscellaneous helpers */
-
-static const char *const editable_files[] = {
- FILENAME_COMMENT ,
- FILENAME_BACKTRACE,
- NULL
-};
-static bool is_editable_file(const char *file_name)
-{
- return is_in_string_list(file_name, (char**)editable_files);
-}
-
-static const char *const always_text_files[] = {
- FILENAME_CMDLINE ,
- FILENAME_BACKTRACE,
- NULL
-};
-static char* is_text_file(const char *name, ssize_t *sz)
-{
- /* We were using magic.h API to check for file being text, but it thinks
- * that file containing just "0" is not text (!!)
- * So, we do it ourself.
- */
-
- int fd = open(name, O_RDONLY);
- if (fd < 0)
- return NULL; /* it's not text (because it does not exist! :) */
-
- /* Maybe 64k limit is small. But _some_ limit is necessary:
- * fields declared "text" may end up in editing fields and such.
- * We don't want to accidentally end up with 100meg text in a textbox!
- * So, don't remove this. If you really need to, raise the limit.
- *
- * Bumped up to 200k: saw 124740 byte /proc/PID/smaps file
- */
- off_t size = lseek(fd, 0, SEEK_END);
- if (size < 0 || size > 200*1024)
- {
- close(fd);
- return NULL; /* it's not a SMALL text */
- }
- lseek(fd, 0, SEEK_SET);
-
- char *buf = (char*)xmalloc(*sz);
- ssize_t r = full_read(fd, buf, *sz);
- close(fd);
- if (r < 0)
- {
- free(buf);
- return NULL; /* it's not text (because we can't read it) */
- }
- if (r < *sz)
- buf[r] = '\0';
- *sz = r;
-
- /* Some files in our dump directories are known to always be textual */
- const char *base = strrchr(name, '/');
- if (base)
- {
- base++;
- if (is_in_string_list(base, (char**)always_text_files))
- return buf;
- }
-
- /* Every once in a while, even a text file contains a few garbled
- * or unexpected non-ASCII chars. We should not declare it "binary".
- */
- const unsigned RATIO = 50;
- unsigned total_chars = r + RATIO;
- unsigned bad_chars = 1; /* 1 prevents division by 0 later */
- while (--r >= 0)
- {
- if (buf[r] >= 0x7f
- /* among control chars, only '\t','\n' etc are allowed */
- || (buf[r] < ' ' && !isspace(buf[r]))
- ) {
- if (buf[r] == '\0')
- {
- /* We don't like NULs very much. Not text for sure! */
- free(buf);
- return NULL;
- }
- bad_chars++;
- }
- }
-
- if ((total_chars / bad_chars) >= RATIO)
- return buf; /* looks like text to me */
-
- free(buf);
- return NULL; /* it's binary */
-}
-
-void load_problem_data_from_dump_dir(problem_data_t *problem_data, struct dump_dir *dd, char **excluding)
-{
- char *short_name;
- char *full_name;
-
- dd_init_next_file(dd);
- while (dd_get_next_file(dd, &short_name, &full_name))
- {
- if (excluding && is_in_string_list(short_name, excluding))
- {
- //log("Excluded:'%s'", short_name);
- goto next;
- }
-
- ssize_t sz = 4*1024;
- char *text = NULL;
- bool editable = is_editable_file(short_name);
-
- if (!editable)
- {
- text = is_text_file(full_name, &sz);
- if (!text)
- {
- add_to_problem_data_ext(problem_data,
- short_name,
- full_name,
- CD_FLAG_BIN + CD_FLAG_ISNOTEDITABLE
- );
- goto next;
- }
- }
-
- char *content;
- if (sz < 4*1024) /* did is_text_file read entire file? */
- {
- /* yes */
- content = text;
- }
- else
- {
- /* no, need to read it all */
- free(text);
- content = dd_load_text(dd, short_name);
- }
- /* Strip '\n' from one-line elements: */
- char *nl = strchr(content, '\n');
- if (nl && nl[1] == '\0')
- *nl = '\0';
-
- int flags = 0;
-
- if (editable)
- flags |= CD_FLAG_TXT | CD_FLAG_ISEDITABLE;
- else
- flags |= CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE;
-
- static const char *const list_files[] = {
- FILENAME_UID ,
- FILENAME_PACKAGE ,
- FILENAME_EXECUTABLE,
- FILENAME_TIME ,
- FILENAME_COUNT ,
- NULL
- };
- if (is_in_string_list(short_name, (char**)list_files))
- flags |= CD_FLAG_LIST;
-
- if (strcmp(short_name, FILENAME_TIME) == 0)
- flags |= CD_FLAG_UNIXTIME;
-
- add_to_problem_data_ext(problem_data,
- short_name,
- content,
- flags
- );
- free(content);
- next:
- free(short_name);
- free(full_name);
- }
-}
-
-problem_data_t *create_problem_data_from_dump_dir(struct dump_dir *dd)
-{
- problem_data_t *problem_data = new_problem_data();
- load_problem_data_from_dump_dir(problem_data, dd, NULL);
- return problem_data;
-}
-
-/*
- * Returns NULL-terminated char *vector[]. Result itself must be freed,
- * but do no free list elements. IOW: do free(result), but never free(result[i])!
- * If comma_separated_list is NULL or "", returns NULL.
- */
-static char **build_exclude_vector(const char *comma_separated_list)
-{
- char **exclude_items = NULL;
- if (comma_separated_list && comma_separated_list[0])
- {
- /* even w/o commas, we'll need two elements:
- * exclude_items[0] = "name"
- * exclude_items[1] = NULL
- */
- unsigned cnt = 2;
-
- const char *cp = comma_separated_list;
- while (*cp)
- if (*cp++ == ',')
- cnt++;
-
- /* We place the string directly after the char *vector[cnt]: */
- exclude_items = xzalloc(cnt * sizeof(exclude_items[0]) + (cp - comma_separated_list) + 1);
- char *p = strcpy((char*)&exclude_items[cnt], comma_separated_list);
-
- char **pp = exclude_items;
- *pp++ = p;
- while (*p)
- {
- if (*p++ == ',')
- {
- p[-1] = '\0';
- *pp++ = p;
- }
- }
- }
-
- return exclude_items;
-}
-
-problem_data_t *create_problem_data_for_reporting(const char *dump_dir_name)
-{
- char **exclude_items = build_exclude_vector(getenv("EXCLUDE_FROM_REPORT"));
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (!dd)
- return NULL; /* dd_opendir already emitted error msg */
- problem_data_t *problem_data = new_problem_data();
- load_problem_data_from_dump_dir(problem_data, dd, exclude_items);
- dd_close(dd);
- free(exclude_items);
- return problem_data;
-}
-
-void log_problem_data(problem_data_t *problem_data, const char *pfx)
-{
- GHashTableIter iter;
- char *name;
- struct problem_item *value;
- g_hash_table_iter_init(&iter, problem_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- log("%s[%s]:'%s' 0x%x",
- pfx, name,
- value->content,
- value->flags
- );
- }
-}
diff --git a/libreport/src/lib/read_write.c b/libreport/src/lib/read_write.c
deleted file mode 100644
index 86d8a2c4..00000000
--- a/libreport/src/lib/read_write.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Utility routines.
- *
- * Copyright (C) 2010 ABRT team
- * Copyright (C) 2010 RedHat Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#include "libreport.h"
-
-/* Die with an error message if we can't read the entire buffer. */
-void xread(int fd, void *buf, size_t count)
-{
- if (count)
- {
- ssize_t size = full_read(fd, buf, count);
- if ((size_t)size != count)
- error_msg_and_die("short read");
- }
-}
-
-ssize_t safe_read(int fd, void *buf, size_t count)
-{
- ssize_t n;
-
- do {
- n = read(fd, buf, count);
- } while (n < 0 && errno == EINTR);
-
- return n;
-}
-
-ssize_t safe_write(int fd, const void *buf, size_t count)
-{
- ssize_t n;
-
- do {
- n = write(fd, buf, count);
- } while (n < 0 && errno == EINTR);
-
- return n;
-}
-
-ssize_t full_read(int fd, void *buf, size_t len)
-{
- ssize_t cc;
- ssize_t total;
-
- total = 0;
-
- while (len)
- {
- cc = safe_read(fd, buf, len);
-
- if (cc < 0)
- {
- if (total)
- {
- /* we already have some! */
- /* user can do another read to know the error code */
- return total;
- }
- return cc; /* read() returns -1 on failure. */
- }
- if (cc == 0)
- break;
- buf = ((char *)buf) + cc;
- total += cc;
- len -= cc;
- }
-
- return total;
-}
-
-ssize_t full_write(int fd, const void *buf, size_t len)
-{
- ssize_t cc;
- ssize_t total;
-
- total = 0;
-
- while (len)
- {
- cc = safe_write(fd, buf, len);
-
- if (cc < 0)
- {
- if (total)
- {
- /* we already wrote some! */
- /* user can do another write to know the error code */
- return total;
- }
- return cc; /* write() returns -1 on failure. */
- }
-
- total += cc;
- buf = ((const char *)buf) + cc;
- len -= cc;
- }
-
- return total;
-}
-
-ssize_t full_write_str(int fd, const char *buf)
-{
- return full_write(fd, buf, strlen(buf));
-}
diff --git a/libreport/src/lib/report.c b/libreport/src/lib/report.c
deleted file mode 100644
index 9b5df02d..00000000
--- a/libreport/src/lib/report.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "libreport.h"
-#include "report.h"
-
-int report_problem_in_dir(const char *dirname, int flags)
-{
- const char *path;
- /*
- if is isatty
- -> run cli reporter
- path = "cli"
- */
-
- char *args[5], **pp;
- pp = args;
- *pp++ = (char *)"bug-reporting-wizard";
- if (!(flags & LIBREPORT_ANALYZE))
- *pp++ = (char *)"--report-only";
- *pp++ = (char *)"--";
- *pp++ = (char *)dirname;
- *pp++ = NULL;
-
- pid_t pid = vfork();
- if (pid < 0) /* error */
- {
- perror_msg("vfork");
- return -1;
- }
-
- if (pid == 0) /* child */
- {
- /* Some callers set SIGCHLD to SIG_IGN.
- * However, reporting spawns child processes.
- * Suppressing child death notification terribly confuses some of them.
- * Just in case, undo it.
- * Note that we do it in the child, so the parent is never affected.
- */
- signal(SIGCHLD, SIG_DFL);
- path = BIN_DIR"/bug-reporting-wizard";
- VERB1 log("Executing: %s", path);
- execv(path, args);
- /* Did not find the desired executable in the installation directory.
- * Trying to find it in PATH
- */
- path = "bug-reporting-wizard";
- execvp(path, args);
- perror_msg_and_die("Can't execute %s", path);
- }
-
- /* parent */
- if (flags & LIBREPORT_WAIT)
- {
- int status;
- pid_t p = waitpid(pid, &status, 0);
- if (p <= 0)
- {
- perror_msg("can't waitpid");
- return -1;
- }
- if (WIFEXITED(status))
- {
- VERB2 log("reporting finished with exitcode %d", WEXITSTATUS(status));
- return WEXITSTATUS(status);
- }
- /* child died from a signal: WIFSIGNALED(status) should be true */
- VERB2 log("reporting killed by signal %d", WTERMSIG(status));
- return WTERMSIG(status) + 128;
- }
-
- return 0;
-}
-
-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);
-
-// TODO: if !LIBREPORT_WAIT pass LIBREPORT_DEL_DIR, and teach bug-reporting-wizard
-// an option to delete directory after reporting?
-// It will make !LIBREPORT_WAIT reporting possible
- result = report_problem_in_dir(dir_name, flags);
-
- /* If we wait for reporter to finish, we should clean the tmp dir.
- * 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)
- load_problem_data_from_dump_dir(pd, dd, NULL);
- dd_delete(dd);
- }
- }
-
- free(dir_name);
- return result;
-}
-
-int report_problem(problem_data_t *pd)
-{
- return report_problem_in_memory(pd, LIBREPORT_WAIT);
-}
diff --git a/libreport/src/lib/report_event.conf b/libreport/src/lib/report_event.conf
deleted file mode 100644
index a99ce8ab..00000000
--- a/libreport/src/lib/report_event.conf
+++ /dev/null
@@ -1,47 +0,0 @@
-# This configuration file specifies which programs should be run
-# when the specified event occurs in dump directory lifetime.
-#
-# It consists of directives and rules.
-#
-# Directives start with a reserved word. Currently, there is only one
-# directive, "include". Its format is "include FILE".
-# It causes files which match FILE to be read and
-# parsed as if they are inserted textually where this directive
-# occurs. FILE can use shell pattern metacharacters (*,?,etc) to
-# specify multiple files. Relative paths are interpreted relative
-# to current file.
-#
-# Rule starts with a line with non-space leading character.
-# All subsequent lines which start with space or tab form one rule.
-# Note that separating newline is *retained*. Example:
-# EVENT=post-create date >/tmp/dt # semicolon is not needed here!
-# echo $HOSTNAME `uname -r`
-#
-# Rules may be commented out with #. One # is sufficient to comment out
-# even a multi-line rule (no need to comment out every line).
-#
-# Rules specify which programs to run on the dump directory.
-# Each rule may have conditions to be checked before the program is run.
-#
-# Conditions have form VAR=VAL or VAL~=REGEX, where VAR is either
-# word "EVENT" or a name of dump directory element to be checked
-# (for example, "executable", "package", hostname" etc).
-#
-# If all conditions match, the remaining part of the rule
-# (the "program" part) is run in the shell.
-# All shell language constructs are valid.
-# All stdout and stderr output is captured and passed to abrt
-# and possibly to abrt's frontends and shown to the user.
-#
-# If the program terminates with nonzero exit code,
-# the event processing is considered unsuccessful and is stopped.
-# Last captured output line, if any, is considered to be
-# the error message indicating the reason of the failure,
-# and may be used by abrt as such.
-#
-# If the program terminates successfully, next rule is read
-# and processed. This process is repeated until the end of this file.
-
-include events.d/*.conf
-
-EVENT=report_Dummy analyzer=libreport echo "Hello world" >> /tmp/libreport.log
diff --git a/libreport/src/lib/run_event.c b/libreport/src/lib/run_event.c
deleted file mode 100644
index 0457364a..00000000
--- a/libreport/src/lib/run_event.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <glob.h>
-#include <regex.h>
-#include "libreport.h"
-
-struct run_event_state *new_run_event_state()
-{
- return xzalloc(sizeof(struct run_event_state));
-}
-
-void free_run_event_state(struct run_event_state *state)
-{
- if (state)
- {
- free_commands(state);
- free(state);
- }
-}
-
-
-/* Asynchronous command execution */
-
-/* It is not yet clear whether we need to re-parse event config file
- * and re-check the elements in dump dir after each command.
- *
- * Consider this config file:
- *
- * EVENT=e cmd1
- * EVENT=e foo=bar cmd2
- * EVENT=e foo=baz cmd3
- *
- * Imagine that element foo existed and was equal to bar at the beginning.
- * After cmd1, should we execute cmd2 if element foo disappeared?
- * After cmd1/2, should we execute cmd3 if element foo changed value to baz?
- *
- * We used to read entire config file and select a list of commands to execute,
- * checking all conditions in the beginning. It is a bit more simple to code up.
- *
- * This proved to be bad for use cases where, for example, post-create rule
- * for a specified package needs to run:
- *
- * EVENT=post-create
- * abrt-action-save-package-data
- * EVENT=post-create component=mypkg
- * my_handling
- *
- * Problem here is that "component" element is created by
- * abrt-action-save-package-data! Pre-selecting rules excludes second rule.
- *
- * Now we read entire config but do NOT select commands to execute,
- * we check conditions of every next rule *directly before its execution*.
- *
- * It's possible we'd want to switch to an algorightm which makes in unnecessary
- * to properly order rules in config files(s). Now these two rules must not
- * be reordered, or else second one won't work:
- * EVENT=post-create echo foo >bar
- * EVENT=post-create foo=bar do_something
- * but this might be not so easy to ensure when include files are involved...
- *
- * Anyway, list of commands machinery is encapsulated in struct run_event_state,
- * and public async API:
- * prepare_commands(state, dir, event);
- * spawn_next_command(state, dir, event);
- * free_commands(state);
- * does not expose the way we select rules to execute.
- */
-struct rule {
- GList *conditions;
- char *command; /* never NULL */
-};
-
-static void free_rule_list(GList *rule_list)
-{
- while (rule_list)
- {
- struct rule *cur_rule = rule_list->data;
- list_free_with_free(cur_rule->conditions);
- free(cur_rule->command);
- free(cur_rule);
-
- GList *next = rule_list->next;
- g_list_free_1(rule_list);
- rule_list = next;
- }
-}
-
-/* Stop-gap measure against infinite recursion */
-#define MAX_recursion_depth 32
-
-static GList *load_rule_list(GList *rule_list,
- const char *conf_file_name,
- unsigned recursion_depth
-) {
- FILE *conffile = fopen(conf_file_name, "r");
- if (!conffile)
- {
- error_msg("Can't open '%s'", conf_file_name);
- return rule_list;
- }
-
- /* Read and remember rules */
- char *next_line = xmalloc_fgetline(conffile);
- while (next_line)
- {
- /* Read and concatenate all lines in a rule */
- char *line = next_line;
- while (1)
- {
- next_line = xmalloc_fgetline(conffile);
- if (!next_line || !isblank(next_line[0]))
- break;
- char *old_line = line;
- line = xasprintf("%s\n%s", line, next_line);
- free(old_line);
- free(next_line);
- }
-
- char *p = skip_whitespace(line);
- if (*p == '\0' || *p == '#')
- goto next_line; /* empty or comment line, skip */
-
- //VERB3 log("%s: line '%s'", __func__, p);
-
- /* Handle "include" directive */
- if (recursion_depth < MAX_recursion_depth
- && strncmp(p, "include", strlen("include")) == 0
- && isblank(p[strlen("include")])
- ) {
- /* "include GLOB_PATTERN" */
- p = skip_whitespace(p + strlen("include"));
-
- const char *last_slash;
- char *name_to_glob;
- if (*p != '/'
- && (last_slash = strrchr(conf_file_name, '/')) != NULL
- )
- /* GLOB_PATTERN is relative, and this include is in path/to/file.conf
- * Construct path/to/GLOB_PATTERN:
- */
- name_to_glob = xasprintf("%.*s%s", (int)(last_slash - conf_file_name + 1), conf_file_name, p);
- else
- /* Either GLOB_PATTERN is absolute, or this include is in file.conf
- * (no slashes in its name). Use unchanged GLOB_PATTERN:
- */
- name_to_glob = xstrdup(p);
-
- glob_t globbuf;
- memset(&globbuf, 0, sizeof(globbuf));
- //VERB3 log("%s: globbing '%s'", __func__, name_to_glob);
- glob(name_to_glob, 0, NULL, &globbuf);
- free(name_to_glob);
- char **name = globbuf.gl_pathv;
- if (name) while (*name)
- {
- //VERB3 log("%s: recursing into '%s'", __func__, *name);
- rule_list = load_rule_list(rule_list, *name, recursion_depth + 1);
- //VERB3 log("%s: returned from '%s'", __func__, *name);
- name++;
- }
- globfree(&globbuf);
- goto next_line;
- }
-
- /* Rule has form: [VAR=VAL]... PROG [ARGS] */
- struct rule *cur_rule = xzalloc(sizeof(*cur_rule));
-
- while (1) /* word loop */
- {
- char *end_word = skip_non_whitespace(p);
-
- /* If there is no '=' in this word... */
- char *line_val = strchr(p, '=');
- if (!line_val || line_val >= end_word)
- break; /* ...we found the start of a command */
-
- cur_rule->conditions = g_list_append(cur_rule->conditions, xstrndup(p, end_word - p));
-
- /* Go to next word */
- p = skip_whitespace(end_word);
- } /* end of word loop */
-
- VERB1 log("Adding '%s'", p);
- cur_rule->command = xstrdup(p);
-
- rule_list = g_list_append(rule_list, cur_rule);
-
- next_line:
- free(line);
- } /* end of line loop */
-
- fclose(conffile);
-
- return rule_list;
-}
-
-static int regcmp_lines(char *val, const char *regex)
-{
- regex_t rx;
- int r = regcomp(&rx, regex, REG_NOSUB); //TODO: and REG_EXTENDED?
- //log("REGEX:'%s':%d", regex, r);
- if (r)
- {
- //char errbuf[256];
- //size_t needsz = regerror(r, &rx, errbuf, sizeof(errbuf));
- error_msg("Bad regexp '%s'", regex); // TODO: use errbuf?
- return r;
- }
-
- /* Check every line */
- while (1)
- {
- char *eol = strchr(val, '\n');
- if (eol)
- *eol = '\0';
- r = regexec(&rx, val, 0, NULL, /*eflags:*/ 0);
- //log("REGCMP:'%s':%d", val, r);
- if (eol)
- *eol = '\n';
- if (r == 0 || !eol)
- break;
- val = eol + 1;
- }
- /* Here, r == 0 if match was found */
- regfree(&rx);
- return r;
-}
-
-/* Deletes rules in *pp_rule_list, starting from first (remaining) rule,
- * until it finds a rule with all conditions satisfied.
- * In this case, it deletes this rule and returns this rule's cmd.
- * Else (if it didn't find such rule), it deletes all rules and returns NULL.
- * In case of error (dump_dir can't be opened), deletes all rules and returns NULL.
- *
- * Intended usage:
- * list = load_rule_list(...);
- * while ((cmd = pop_next_command(&list, ...)) != NULL)
- * run(cmd);
- */
-static char* pop_next_command(GList **pp_rule_list,
- char **pp_event_name, /* reports EVENT value thru this, if not NULL on entry */
- struct dump_dir **pp_dd, /* use *pp_dd for access to dump dir, if non-NULL */
- const char *dump_dir_name,
- const char *pfx,
- unsigned pfx_len
-)
-{
- char *command = NULL;
- struct dump_dir *dd = pp_dd ? *pp_dd : NULL;
-
- GList *rule_list = *pp_rule_list;
- while (rule_list)
- {
- struct rule *cur_rule = rule_list->data;
-
- GList *condition = cur_rule->conditions;
- while (condition)
- {
- const char *cond_str = condition->data;
- const char *eq_sign = strchr(cond_str, '=');
-
- /* Is it "EVENT=foo"? */
- if (strncmp(cond_str, "EVENT=", 6) == 0)
- {
- if (strncmp(eq_sign + 1, pfx, pfx_len) != 0)
- goto next_rule; /* prefix doesn't match */
- if (pp_event_name)
- {
- free(*pp_event_name);
- *pp_event_name = xstrdup(eq_sign + 1);
- }
- }
- else
- {
- /* Read from dump dir and compare */
- if (!dd)
- {
- /* Without dir to match, we assume match for all conditions */
- if (!dump_dir_name)
- goto next_cond;
- dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (!dd)
- {
- free_rule_list(rule_list);
- *pp_rule_list = NULL;
- goto ret; /* error (note: dd_opendir logged error msg) */
- }
- }
- /* Is it "VAR~=REGEX"? */
- int regex = (eq_sign > cond_str && eq_sign[-1] == '~');
- char *var_name = xstrndup(cond_str, eq_sign - cond_str - regex);
- char *real_val = dd_load_text_ext(dd, var_name, DD_FAIL_QUIETLY_ENOENT);
- free(var_name);
- int vals_differ = regex ? regcmp_lines(real_val, eq_sign + 1) : strcmp(real_val, eq_sign + 1);
- free(real_val);
-
- /* Do values match? */
- if (vals_differ) /* no */
- {
- //VERB3 log("var '%s': '%.*s'!='%s', skipping line",
- // p,
- // (int)(strchrnul(real_val, '\n') - real_val), real_val,
- // eq_sign);
- goto next_rule;
- }
- }
- next_cond:
- /* We are here if current condition is satisfied */
-
- condition = condition->next;
- }
- /* We are here if all conditions are satisfied */
-
- command = cur_rule->command;
-
- next_rule:
- *pp_rule_list = rule_list->next;
- g_list_free_1(rule_list);
-
- list_free_with_free(cur_rule->conditions);
- /*free(cur_rule->command); - WRONG! we might be returning it! */
- if (command)
- {
- /* We found rule to run, return it */
- free(cur_rule);
- break;
- }
- free(cur_rule->command); /* _now_ it is ok */
- free(cur_rule);
-
- rule_list = *pp_rule_list;
- } /* while (rule_list) */
-
- ret:
- if (pp_dd)
- *pp_dd = dd;
- else
- dd_close(dd);
- return command;
-}
-
-void free_commands(struct run_event_state *state)
-{
- free_rule_list(state->rule_list);
- state->rule_list = NULL;
- state->command_out_fd = -1;
- state->command_pid = 0;
-}
-
-int prepare_commands(struct run_event_state *state,
- const char *dump_dir_name,
- const char *event
-) {
- free_commands(state);
-
- state->children_count = 0;
-
- GList *rule_list = load_rule_list(NULL, CONF_DIR"/report_event.conf", /*recursion_depth:*/ 0);
- state->rule_list = rule_list;
- return rule_list != NULL;
-}
-
-int spawn_next_command(struct run_event_state *state,
- const char *dump_dir_name,
- const char *event
-) {
- char *cmd = pop_next_command(&state->rule_list,
- NULL, /* don't return event_name */
- NULL, /* NULL &dd: we match by... */
- dump_dir_name, /* ...dirname */
- event, strlen(event)+1 /* for this event name exactly (not prefix) */
- );
- if (!cmd)
- return -1;
-
- /* We count it even if fork fails. The counter isn't meant
- * to count *successful* forks, it is meant to let caller know
- * whether the event we run has *any* handlers configured, or not.
- */
- state->children_count++;
-
- VERB1 log("Executing '%s'", cmd);
-
- /* Export some useful environment variables for children */
- char *env_vec[3];
- /* Just exporting dump_dir_name isn't always ok: it can be "."
- * and some children want to cd to other directory but still
- * be able to find dump directory by using $DUMP_DIR...
- */
- char *full_name = realpath(dump_dir_name, NULL);
- env_vec[0] = xasprintf("DUMP_DIR=%s", (full_name ? full_name : dump_dir_name));
- free(full_name);
- env_vec[1] = xasprintf("EVENT=%s", event);
- env_vec[2] = NULL;
-
- char *argv[4];
- argv[0] = (char*)"/bin/sh"; // TODO: honor $SHELL?
- argv[1] = (char*)"-c";
- argv[2] = cmd;
- argv[3] = NULL;
-
- int pipefds[2];
- state->command_pid = fork_execv_on_steroids(
- EXECFLG_INPUT_NUL + EXECFLG_OUTPUT + EXECFLG_ERR2OUT,
- argv,
- pipefds,
- /* env_vec: */ env_vec,
- /* dir: */ dump_dir_name,
- /* uid(unused): */ 0
- );
- state->command_out_fd = pipefds[0];
-
- free(env_vec[0]);
- free(env_vec[1]);
- free(cmd);
-
- return 0;
-}
-
-
-/* Synchronous command execution:
- */
-int run_event_on_dir_name(struct run_event_state *state,
- const char *dump_dir_name,
- const char *event
-) {
- prepare_commands(state, dump_dir_name, event);
-
- /* Execute every command in shell */
-
- int retval = 0;
- while (spawn_next_command(state, dump_dir_name, event) >= 0)
- {
- /* Consume log from stdout */
- FILE *fp = fdopen(state->command_out_fd, "r");
- if (!fp)
- die_out_of_memory();
- char *buf;
- while ((buf = xmalloc_fgetline(fp)) != NULL)
- {
- if (state->logging_callback)
- buf = state->logging_callback(buf, state->logging_param);
- free(buf);
- }
- fclose(fp); /* Got EOF, close. This also closes state->command_out_fd */
-
- /* Wait for child to actually exit, collect status */
- int status;
- waitpid(state->command_pid, &status, 0);
-
- retval = WEXITSTATUS(status);
- if (WIFSIGNALED(status))
- retval = WTERMSIG(status) + 128;
- if (retval != 0)
- break;
-
- if (state->post_run_callback)
- {
- retval = state->post_run_callback(dump_dir_name, state->post_run_param);
- if (retval != 0)
- break;
- }
- }
-
- free_commands(state);
-
- return retval;
-}
-
-int run_event_on_problem_data(struct run_event_state *state, problem_data_t *data, const char *event)
-{
- state->children_count = 0;
-
- struct dump_dir *dd = create_dump_dir_from_problem_data(data, NULL);
- if (!dd)
- return -1;
- char *dir_name = xstrdup(dd->dd_dirname);
- dd_close(dd);
-
- int r = run_event_on_dir_name(state, dir_name, event);
-
- g_hash_table_remove_all(data);
- dd = dd_opendir(dir_name, /*flags:*/ 0);
- free(dir_name);
- if (dd)
- {
- load_problem_data_from_dump_dir(data, dd, NULL);
- dd_delete(dd);
- }
-
- return r;
-}
-
-char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx)
-{
- struct strbuf *result = strbuf_new();
-
- GList *rule_list = load_rule_list(NULL, CONF_DIR"/report_event.conf", /*recursion_depth:*/ 0);
-
- unsigned pfx_len = strlen(pfx);
- for (;;)
- {
- /* Retrieve each cmd, and fetch its EVENT=foo value */
- char *event_name = NULL;
- char *cmd = pop_next_command(&rule_list,
- &event_name, /* return event_name */
- (dd ? &dd : NULL), /* match this dd... */
- dump_dir_name, /* ...or if NULL, this dirname */
- pfx, pfx_len /* for events with this prefix */
- );
- if (!cmd)
- break;
- free(cmd);
-
- if (event_name)
- {
- /* Append "EVENT\n" - only if it is not there yet */
- unsigned e_len = strlen(event_name);
- char *p = result->buf;
- while (p && *p)
- {
- if (strncmp(p, event_name, e_len) == 0 && p[e_len] == '\n')
- goto skip; /* This event is already in the result */
- p = strchr(p, '\n');
- if (p)
- p++;
- }
- strbuf_append_strf(result, "%s\n", event_name);
- skip:
- free(event_name);
- }
- }
-
- return strbuf_free_nobuf(result);
-}
diff --git a/libreport/src/lib/skip_whitespace.c b/libreport/src/lib/skip_whitespace.c
deleted file mode 100644
index 57ef2910..00000000
--- a/libreport/src/lib/skip_whitespace.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#include "libreport.h"
-
-char* skip_whitespace(const char *s)
-{
- /* NB: isspace('\0') returns 0 */
- while (isspace(*s)) ++s;
-
- return (char *) s;
-}
-
-char* skip_non_whitespace(const char *s)
-{
- while (*s && !isspace(*s)) ++s;
-
- return (char *) s;
-}
diff --git a/libreport/src/lib/spawn.c b/libreport/src/lib/spawn.c
deleted file mode 100644
index 07997307..00000000
--- a/libreport/src/lib/spawn.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Utility routines.
- *
- * Copyright (C) 2010 ABRT team
- * Copyright (C) 2010 RedHat Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#include "libreport.h"
-
-static char *concat_str_vector(char **strings)
-{
- if (!strings[0])
- return xzalloc(1); // returns ""
-
- unsigned len = 0;
- char **spp = strings;
- while (*spp)
- len += strlen(*spp++) + 1;
-
- char *result = xmalloc(len);
-
- char *r = result;
- spp = strings;
- while (*spp) {
- r = stpcpy(r, *spp++);
- *r++ = ' ';
- }
- *--r = '\0';
-
- return result;
-}
-
-/* Returns pid */
-pid_t fork_execv_on_steroids(int flags,
- char **argv,
- int *pipefds,
- char **env_vec,
- const char *dir,
- uid_t uid)
-{
- pid_t child;
- /* Reminder: [0] is read end, [1] is write end */
- int pipe_to_child[2];
- int pipe_fm_child[2];
-
- /* Sanitize flags */
- if (!pipefds)
- flags &= ~(EXECFLG_INPUT | EXECFLG_OUTPUT);
-
- if (flags & EXECFLG_INPUT)
- xpipe(pipe_to_child);
- if (flags & EXECFLG_OUTPUT)
- xpipe(pipe_fm_child);
-
- fflush(NULL);
- child = fork();
- if (child == -1) {
- perror_msg_and_die("fork");
- }
- if (child == 0) {
- /* Child */
-
- if (dir)
- xchdir(dir);
-
- if (flags & EXECFLG_SETGUID) {
- struct passwd* pw = getpwuid(uid);
- gid_t gid = pw ? pw->pw_gid : uid;
- setgroups(1, &gid);
- xsetregid(gid, gid);
- xsetreuid(uid, uid);
- }
-
- if (env_vec) {
- /* Note: we use the glibc extension that putenv("var")
- * *unsets* $var if "var" string has no '=' */
- while (*env_vec)
- putenv(*env_vec++);
- }
-
- /* Play with stdio descriptors */
- if (flags & EXECFLG_INPUT) {
- xmove_fd(pipe_to_child[0], STDIN_FILENO);
- close(pipe_to_child[1]);
- } else if (flags & EXECFLG_INPUT_NUL) {
- xmove_fd(xopen("/dev/null", O_RDWR), STDIN_FILENO);
- }
- if (flags & EXECFLG_OUTPUT) {
- xmove_fd(pipe_fm_child[1], STDOUT_FILENO);
- close(pipe_fm_child[0]);
- } else if (flags & EXECFLG_OUTPUT_NUL) {
- xmove_fd(xopen("/dev/null", O_RDWR), STDOUT_FILENO);
- }
-
- /* This should be done BEFORE stderr redirect */
- VERB1 {
- char *r = concat_str_vector(argv);
- log("Executing: %s", r);
- free(r);
- }
-
- if (flags & EXECFLG_ERR2OUT) {
- /* Want parent to see errors in the same stream */
- xdup2(STDOUT_FILENO, STDERR_FILENO);
- } else if (flags & EXECFLG_ERR_NUL) {
- xmove_fd(xopen("/dev/null", O_RDWR), STDERR_FILENO);
- }
-
- if (flags & EXECFLG_SETSID)
- setsid();
-
- execvp(argv[0], argv);
- if (!(flags & EXECFLG_QUIET))
- perror_msg("Can't execute '%s'", argv[0]);
- exit(127); /* shell uses this exit code in this case */
- }
-
- if (flags & EXECFLG_INPUT) {
- close(pipe_to_child[0]);
- pipefds[1] = pipe_to_child[1];
- }
- if (flags & EXECFLG_OUTPUT) {
- close(pipe_fm_child[1]);
- pipefds[0] = pipe_fm_child[0];
- }
-
- return child;
-}
-
-char *run_in_shell_and_save_output(int flags,
- const char *cmd,
- const char *dir,
- size_t *size_p)
-{
- flags |= EXECFLG_OUTPUT;
- flags &= ~EXECFLG_INPUT;
-
- const char *argv[] = { "/bin/sh", "-c", cmd, NULL };
- int pipeout[2];
- pid_t child = fork_execv_on_steroids(flags, (char **)argv, pipeout,
- /*env_vec:*/ NULL, dir, /*uid (unused):*/ 0);
-
- size_t pos = 0;
- char *result = NULL;
- while (1) {
- result = (char*) xrealloc(result, pos + 4*1024 + 1);
- size_t sz = safe_read(pipeout[0], result + pos, 4*1024);
- if (sz <= 0) {
- break;
- }
- pos += sz;
- }
- result[pos] = '\0';
- if (size_p)
- *size_p = pos;
- close(pipeout[0]);
- waitpid(child, NULL, 0);
-
- return result;
-}
diff --git a/libreport/src/lib/stdio_helpers.c b/libreport/src/lib/stdio_helpers.c
deleted file mode 100644
index b2b9238c..00000000
--- a/libreport/src/lib/stdio_helpers.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Utility routines.
- *
- * Copyright (C) 2001 Matt Krai
- * Copyright (C) 2004 Erik Andersen <andersen@codepoet.org>
- * Copyright (C) 2005, 2006 Rob Landley <rob@landley.net>
- * Copyright (C) 2010 ABRT Team
- *
- * Copyright (C) 2010 ABRT team
- * Copyright (C) 2010 RedHat Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#include "libreport.h"
-
-//TODO: add sanitizing upper limit (e.g 64K, 1M, or configurable).
-//This is why we don't use GNU's getline: it doesn't have
-//any upper sanity bound on line size.
-
-static char *xmalloc_fgets_internal(FILE *file, int *sizep)
-{
- unsigned idx = 0;
- char *linebuf = NULL;
-
- while (1) {
- char *r;
-
- linebuf = xrealloc(linebuf, idx + 0x100);
- r = fgets(&linebuf[idx], 0x100, file);
- if (!r) {
- /* need to terminate the line */
- linebuf[idx] = '\0';
- break;
- }
-
- /* stupid. fgets knows the len, it should report it somehow */
- unsigned len = strlen(&linebuf[idx]);
-
- idx += len;
- if (len < 0xff || linebuf[idx - 1] == '\n')
- break; /* we found \n or EOF */
- }
-
- *sizep = idx;
-
- if (!idx) {
- /* The very first fgets returned NULL. It's EOF (or error) */
- free(linebuf);
- linebuf = NULL;
- }
- return linebuf;
-}
-
-char *xmalloc_fgets(FILE *file)
-{
- int sz;
- char *r = xmalloc_fgets_internal(file, &sz);
- if (!r)
- return r;
- return xrealloc(r, sz + 1);
-}
-
-char *xmalloc_fgetline(FILE *file)
-{
- int sz;
- char *r = xmalloc_fgets_internal(file, &sz);
- if (!r)
- return r;
- if (r[sz - 1] == '\n')
- r[--sz] = '\0';
- return xrealloc(r, sz + 1);
-}
diff --git a/libreport/src/lib/steal_directory.c b/libreport/src/lib/steal_directory.c
deleted file mode 100644
index 4bcd192e..00000000
--- a/libreport/src/lib/steal_directory.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright (C) 2011 ABRT Team
- Copyright (C) 2011 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name)
-{
- const char *base_name = strrchr(dump_dir_name, '/');
- if (base_name)
- base_name++;
- else
- base_name = dump_dir_name;
-
- struct dump_dir *dd_dst;
- unsigned count = 100;
- char *dst_dir_name = concat_path_file(base_dir, base_name);
- while (1)
- {
- dd_dst = dd_create(dst_dir_name, (uid_t)-1, 0640);
- free(dst_dir_name);
- if (dd_dst)
- break;
- if (--count == 0)
- {
- error_msg("Can't create new dump dir in '%s'", base_dir);
- return NULL;
- }
- struct timeval tv;
- gettimeofday(&tv, NULL);
- dst_dir_name = xasprintf("%s/%s.%u", base_dir, base_name, (int)tv.tv_usec);
- }
-
- VERB1 log("Creating copy in '%s'", dd_dst->dd_dirname);
- if (copy_file_recursive(dump_dir_name, dd_dst->dd_dirname) < 0)
- {
- /* error. copy_file_recursive already emitted error message */
- /* Don't leave half-copied dir lying around */
- dd_delete(dd_dst);
- return NULL;
- }
-
- return dd_dst;
-}
diff --git a/libreport/src/lib/strbuf.c b/libreport/src/lib/strbuf.c
deleted file mode 100644
index f2adeda7..00000000
--- a/libreport/src/lib/strbuf.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- String buffer implementation
-
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "libreport.h"
-
-int prefixcmp(const char *str, const char *prefix)
-{
- for (; ; str++, prefix++)
- if (!*prefix)
- return 0;
- else if (*str != *prefix)
- return (unsigned char)*prefix - (unsigned char)*str;
-}
-
-int suffixcmp(const char *str, const char *suffix)
-{
- int len_minus_suflen = strlen(str) - strlen(suffix);
- if (len_minus_suflen < 0)
- return len_minus_suflen;
- else
- return strcmp(str + len_minus_suflen, suffix);
-}
-
-/*
- * Trims whitespace characters both from left and right side of a string.
- * Modifies the string in-place. Returns the trimmed string.
- */
-char *strtrim(char *str)
-{
- if (!str)
- return NULL;
-
- // Remove leading spaces.
- overlapping_strcpy(str, skip_whitespace(str));
-
- // Remove trailing spaces.
- int i = strlen(str);
- while (--i >= 0)
- {
- if (!isspace(str[i]))
- break;
- }
- str[++i] = '\0';
- return str;
-}
-
-struct strbuf *strbuf_new(void)
-{
- struct strbuf *buf = xzalloc(sizeof(*buf));
- /*buf->len = 0; - done by xzalloc */
- buf->alloc = 8;
- buf->buf = xzalloc(8);
- return buf;
-}
-
-void strbuf_free(struct strbuf *strbuf)
-{
- if (!strbuf)
- return;
- free(strbuf->buf);
- free(strbuf);
-}
-
-char *strbuf_free_nobuf(struct strbuf *strbuf)
-{
- char *ret = strbuf->buf;
- free(strbuf);
- return ret;
-}
-
-
-void strbuf_clear(struct strbuf *strbuf)
-{
- assert(strbuf->alloc > 0);
- strbuf->len = 0;
- strbuf->buf[0] = '\0';
-}
-
-/* Ensures that the buffer can be extended by N+1 characters
- * without touching malloc/realloc.
- * Returns pointer where appended chars can be stored by the caller;
- * increments ->len by N (therefore callers don't need to do it).
- */
-static char *strbuf_grow(struct strbuf *strbuf, unsigned increment)
-{
- unsigned len = strbuf->len;
- unsigned need = strbuf->len = len + increment;
- unsigned cur_size = strbuf->alloc;
- if (cur_size <= need)
- {
- while (cur_size <= need)
- cur_size += 64 + cur_size / 8;
- strbuf->alloc = cur_size;
- strbuf->buf = xrealloc(strbuf->buf, cur_size);
- }
- char *p = strbuf->buf + len;
- return p;
-}
-
-struct strbuf *strbuf_append_char(struct strbuf *strbuf, char c)
-{
- char *p = strbuf_grow(strbuf, 1);
- *p++ = c;
- *p = '\0';
- return strbuf;
-}
-
-struct strbuf *strbuf_append_str(struct strbuf *strbuf, const char *str)
-{
- unsigned len = strlen(str);
- char *p = strbuf_grow(strbuf, len);
- assert(strbuf->len < strbuf->alloc);
- strcpy(p, str);
- return strbuf;
-}
-
-struct strbuf *strbuf_prepend_str(struct strbuf *strbuf, const char *str)
-{
- unsigned cur_len = strbuf->len;
- unsigned inc_len = strlen(str);
- strbuf_grow(strbuf, inc_len);
- assert(strbuf->len < strbuf->alloc);
- memmove(strbuf->buf + inc_len, strbuf->buf, cur_len);
- memcpy(strbuf->buf, str, inc_len);
- return strbuf;
-}
-
-struct strbuf *strbuf_append_strf(struct strbuf *strbuf, const char *format, ...)
-{
- va_list p;
- char *string_ptr;
-
- va_start(p, format);
- string_ptr = xvasprintf(format, p);
- va_end(p);
-
- strbuf_append_str(strbuf, string_ptr);
- free(string_ptr);
- return strbuf;
-}
-
-struct strbuf *strbuf_prepend_strf(struct strbuf *strbuf, const char *format, ...)
-{
- va_list p;
- char *string_ptr;
-
- va_start(p, format);
- string_ptr = xvasprintf(format, p);
- va_end(p);
-
- strbuf_prepend_str(strbuf, string_ptr);
- free(string_ptr);
- return strbuf;
-}
diff --git a/libreport/src/lib/xatonum.c b/libreport/src/lib/xatonum.c
deleted file mode 100644
index a6a4ddfd..00000000
--- a/libreport/src/lib/xatonum.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Utility routines.
- *
- * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
- *
- * Copyright (C) 2010 ABRT team
- * Copyright (C) 2010 RedHat Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#include "libreport.h"
-
-unsigned xatou(const char *numstr)
-{
- unsigned long r;
- int old_errno;
- char *e;
-
- if (*numstr < '0' || *numstr > '9')
- goto inval;
-
- old_errno = errno;
- errno = 0;
- r = strtoul(numstr, &e, 10);
- if (errno || numstr == e || *e != '\0' || r > UINT_MAX)
- goto inval; /* error / no digits / illegal trailing chars */
- errno = old_errno; /* Ok. So restore errno. */
- return r;
-
-inval:
- error_msg_and_die("invalid number '%s'", numstr);
-}
-
-int xatoi_positive(const char *numstr)
-{
- unsigned r = xatou(numstr);
- if (r > (unsigned)INT_MAX)
- error_msg_and_die("invalid number '%s'", numstr);
- return r;
-}
-
-int xatoi(const char *numstr)
-{
- unsigned r;
-
- if (*numstr != '-')
- return xatoi_positive(numstr);
-
- r = xatou(numstr + 1);
- if (r > (unsigned)INT_MAX + 1)
- error_msg_and_die("invalid number '%s'", numstr);
- return - (int)r;
-}
diff --git a/libreport/src/lib/xfuncs.c b/libreport/src/lib/xfuncs.c
deleted file mode 100644
index 67b61d40..00000000
--- a/libreport/src/lib/xfuncs.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-/*
- * Utility routines.
- *
- */
-#include "libreport.h"
-
-/* Turn on nonblocking I/O on a fd */
-int ndelay_on(int fd)
-{
- int flags = fcntl(fd, F_GETFL);
- if (flags & O_NONBLOCK)
- return 0;
- return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-}
-
-int ndelay_off(int fd)
-{
- int flags = fcntl(fd, F_GETFL);
- if (!(flags & O_NONBLOCK))
- return 0;
- return fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
-}
-
-int close_on_exec_on(int fd)
-{
- return fcntl(fd, F_SETFD, FD_CLOEXEC);
-}
-
-// Die if we can't allocate size bytes of memory.
-void* xmalloc(size_t size)
-{
- void *ptr = malloc(size);
- if (ptr == NULL && size != 0)
- die_out_of_memory();
- return ptr;
-}
-
-// Die if we can't resize previously allocated memory. (This returns a pointer
-// to the new memory, which may or may not be the same as the old memory.
-// It'll copy the contents to a new chunk and free the old one if necessary.)
-void* xrealloc(void *ptr, size_t size)
-{
- ptr = realloc(ptr, size);
- if (ptr == NULL && size != 0)
- die_out_of_memory();
- return ptr;
-}
-
-// Die if we can't allocate and zero size bytes of memory.
-void* xzalloc(size_t size)
-{
- void *ptr = xmalloc(size);
- memset(ptr, 0, size);
- return ptr;
-}
-
-// Die if we can't copy a string to freshly allocated memory.
-char* xstrdup(const char *s)
-{
- char *t;
- if (s == NULL)
- return NULL;
-
- t = strdup(s);
-
- if (t == NULL)
- die_out_of_memory();
-
- return t;
-}
-
-// Die if we can't allocate n+1 bytes (space for the null terminator) and copy
-// the (possibly truncated to length n) string into it.
-char* xstrndup(const char *s, int n)
-{
- int m;
- char *t;
-
- /* We can just xmalloc(n+1) and strncpy into it, */
- /* but think about xstrndup("abc", 10000) wastage! */
- m = n;
- t = (char*) s;
- while (m)
- {
- if (!*t) break;
- m--;
- t++;
- }
- n -= m;
- t = (char*) xmalloc(n + 1);
- t[n] = '\0';
-
- return (char*) memcpy(t, s, n);
-}
-
-void xpipe(int filedes[2])
-{
- if (pipe(filedes))
- perror_msg_and_die("can't create pipe");
-}
-
-void xdup(int from)
-{
- if (dup(from) < 0)
- perror_msg_and_die("can't duplicate file descriptor");
-}
-
-void xdup2(int from, int to)
-{
- if (dup2(from, to) != to)
- perror_msg_and_die("can't duplicate file descriptor");
-}
-
-// "Renumber" opened fd
-void xmove_fd(int from, int to)
-{
- if (from == to)
- return;
- xdup2(from, to);
- close(from);
-}
-
-// Die with an error message if we can't write the entire buffer.
-void xwrite(int fd, const void *buf, size_t count)
-{
- if (count == 0)
- return;
- ssize_t size = full_write(fd, buf, count);
- if ((size_t)size != count)
- error_msg_and_die("short write");
-}
-
-void xwrite_str(int fd, const char *str)
-{
- xwrite(fd, str, strlen(str));
-}
-
-// Die with an error message if we can't lseek to the right spot.
-off_t xlseek(int fd, off_t offset, int whence)
-{
- off_t off = lseek(fd, offset, whence);
- if (off == (off_t)-1) {
- if (whence == SEEK_SET)
- perror_msg_and_die("lseek(%llu)", (long long)offset);
- perror_msg_and_die("lseek");
- }
- return off;
-}
-
-void xchdir(const char *path)
-{
- if (chdir(path))
- perror_msg_and_die("chdir(%s)", path);
-}
-
-char* xvasprintf(const char *format, va_list p)
-{
- int r;
- char *string_ptr;
-
-#if 1
- // GNU extension
- r = vasprintf(&string_ptr, format, p);
-#else
- // Bloat for systems that haven't got the GNU extension.
- va_list p2;
- va_copy(p2, p);
- r = vsnprintf(NULL, 0, format, p);
- string_ptr = xmalloc(r+1);
- r = vsnprintf(string_ptr, r+1, format, p2);
- va_end(p2);
-#endif
-
- if (r < 0)
- die_out_of_memory();
- return string_ptr;
-}
-
-// Die with an error message if we can't malloc() enough space and do an
-// sprintf() into that space.
-char* xasprintf(const char *format, ...)
-{
- va_list p;
- char *string_ptr;
-
- va_start(p, format);
- string_ptr = xvasprintf(format, p);
- va_end(p);
-
- return string_ptr;
-}
-
-void xsetenv(const char *key, const char *value)
-{
- if (setenv(key, value, 1))
- die_out_of_memory();
-}
-
-void safe_unsetenv(const char *var_val)
-{
- //char *name = xstrndup(var_val, strchrnul(var_val, '=') - var_val);
- //unsetenv(name);
- //free(name);
-
- /* Avoid malloc/free (name is usually very short) */
- unsigned len = strchrnul(var_val, '=') - var_val;
- char name[len + 1];
- memcpy(name, var_val, len);
- name[len] = '\0';
- unsetenv(name);
-}
-
-// Die with an error message if we can't open a new socket.
-int xsocket(int domain, int type, int protocol)
-{
- int r = socket(domain, type, protocol);
- if (r < 0)
- {
- const char *s = "INET";
- if (domain == AF_PACKET) s = "PACKET";
- if (domain == AF_NETLINK) s = "NETLINK";
- if (domain == AF_INET6) s = "INET6";
- perror_msg_and_die("socket(AF_%s)", s);
- }
-
- return r;
-}
-
-// Die with an error message if we can't bind a socket to an address.
-void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
-{
- if (bind(sockfd, my_addr, addrlen))
- perror_msg_and_die("bind");
-}
-
-// Die with an error message if we can't listen for connections on a socket.
-void xlisten(int s, int backlog)
-{
- if (listen(s, backlog))
- perror_msg_and_die("listen");
-}
-
-// Die with an error message if sendto failed.
-// Return bytes sent otherwise
-ssize_t xsendto(int s, const void *buf, size_t len,
- const struct sockaddr *to,
- socklen_t tolen)
-{
- ssize_t ret = sendto(s, buf, len, 0, to, tolen);
- if (ret < 0)
- {
- close(s);
- perror_msg_and_die("sendto");
- }
- return ret;
-}
-
-// xstat() - a stat() which dies on failure with meaningful error message
-void xstat(const char *name, struct stat *stat_buf)
-{
- if (stat(name, stat_buf))
- perror_msg_and_die("can't stat '%s'", name);
-}
-
-// Die if we can't open a file and return a fd
-int xopen3(const char *pathname, int flags, int mode)
-{
- int ret;
- ret = open(pathname, flags, mode);
- if (ret < 0)
- perror_msg_and_die("can't open '%s'", pathname);
- return ret;
-}
-
-// Die if we can't open an existing file and return a fd
-int xopen(const char *pathname, int flags)
-{
- return xopen3(pathname, flags, 0666);
-}
-
-void xunlink(const char *pathname)
-{
- if (unlink(pathname))
- perror_msg_and_die("Can't remove file '%s'", pathname);
-}
-
-#if 0 //UNUSED
-// Warn if we can't open a file and return a fd.
-int open3_or_warn(const char *pathname, int flags, int mode)
-{
- int ret;
- ret = open(pathname, flags, mode);
- if (ret < 0)
- perror_msg("can't open '%s'", pathname);
- return ret;
-}
-
-// Warn if we can't open a file and return a fd.
-int open_or_warn(const char *pathname, int flags)
-{
- return open3_or_warn(pathname, flags, 0666);
-}
-#endif
-
-/* Just testing dent->d_type == DT_REG is wrong: some filesystems
- * do not report the type, they report DT_UNKNOWN for every dirent
- * (and this is not a bug in filesystem, this is allowed by standards).
- */
-int is_regular_file(struct dirent *dent, const char *dirname)
-{
- if (dent->d_type == DT_REG)
- return 1;
- if (dent->d_type != DT_UNKNOWN)
- return 0;
-
- char *fullname = xasprintf("%s/%s", dirname, dent->d_name);
- struct stat statbuf;
- int r = lstat(fullname, &statbuf);
- free(fullname);
-
- return r == 0 && S_ISREG(statbuf.st_mode);
-}
-
-/* Is it "." or ".."? */
-/* abrtlib candidate */
-bool dot_or_dotdot(const char *filename)
-{
- if (filename[0] != '.') return false;
- if (filename[1] == '\0') return true;
- if (filename[1] != '.') return false;
- if (filename[2] == '\0') return true;
- return false;
-}
-
-/* Find out if the last character of a string matches the one given.
- * Don't underrun the buffer if the string length is 0.
- */
-char *last_char_is(const char *s, int c)
-{
- if (s && *s)
- {
- s += strlen(s) - 1;
- if ((unsigned char)*s == c)
- return (char*)s;
- }
- return NULL;
-}
-
-bool string_to_bool(const char *s)
-{
- if (s[0] == '1' && s[1] == '\0')
- return true;
- if (strcasecmp(s, "on") == 0)
- return true;
- if (strcasecmp(s, "yes") == 0)
- return true;
- if (strcasecmp(s, "true") == 0)
- return true;
- return false;
-}
-
-void xseteuid(uid_t euid)
-{
- if (seteuid(euid) != 0)
- perror_msg_and_die("can't set %cid %lu", 'u', (long)euid);
-}
-
-void xsetegid(gid_t egid)
-{
- if (setegid(egid) != 0)
- perror_msg_and_die("can't set %cid %lu", 'g', (long)egid);
-}
-
-void xsetreuid(uid_t ruid, uid_t euid)
-{
- if (setreuid(ruid, euid) != 0)
- perror_msg_and_die("can't set %cid %lu", 'u', (long)ruid);
-}
-
-void xsetregid(gid_t rgid, gid_t egid)
-{
- if (setregid(rgid, egid) != 0)
- perror_msg_and_die("can't set %cid %lu", 'g', (long)rgid);
-}
-
-const char *get_home_dir(uid_t uid)
-{
- struct passwd* pw = getpwuid(uid);
- // TODO: handle errno
- return pw ? pw->pw_dir : NULL;
-}
diff --git a/libreport/src/report-python/Makefile.am b/libreport/src/report-python/Makefile.am
deleted file mode 100644
index c1b37596..00000000
--- a/libreport/src/report-python/Makefile.am
+++ /dev/null
@@ -1,43 +0,0 @@
-pyreportexecdir = $(pyexecdir)/report
-
-pyreportexec_PYTHON = \
- __init__.py \
- accountmanager.py
-
-pyreportexec_LTLIBRARIES = _pyreport.la
-
-_pyreport_la_SOURCES = \
- reportmodule.c \
- problem_data.c \
- dump_dir.c \
- run_event.c \
- report.c \
- common.h
-_pyreport_la_CPPFLAGS = \
- -I$(srcdir)/../include/report -I$(srcdir)/../include \
- -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
- -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
- -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
- -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DCONF_DIR=\"$(CONF_DIR)\" \
- -DVAR_RUN=\"$(VAR_RUN)\" \
- $(GLIB_CFLAGS) \
- $(PYTHON_CFLAGS) \
- -D_GNU_SOURCE \
- -Wall -Wwrite-strings -Werror
-_pyreport_la_LDFLAGS = \
- -module \
- -avoid-version \
- -export-symbols-regex init_pyreport
-_pyreport_la_LIBADD = \
- ../lib/libreport.la
-
-# report compat:
-
-pyreportioexecdir = $(pyexecdir)/report/io
-
-pyreportioexec_PYTHON = \
- io/__init__.py \
- io/GTKIO.py \
- io/NewtIO.py \
- io/TextIO.py
diff --git a/libreport/src/report-python/README b/libreport/src/report-python/README
deleted file mode 100644
index 1c9c3a27..00000000
--- a/libreport/src/report-python/README
+++ /dev/null
@@ -1,44 +0,0 @@
-Currently (2011-05), include/report/*.h are:
-
-dump_dir.h
-event_config.h
-problem_data.h
-report.h
-run_event.h
-
-and we wrap all of them except event_config.h.
-
-Python wrappers for C types and functions declared in include/report/FOO.h
-should be implemented in corresponding FOO.c file in this directory.
-
-Their (C-level) declarations should go to common.h.
-
-Note that methods don't have to be declared in common.h:
-they can be static functions inside FOO.c, and exposed to the rest
-of the world via PyTypeObject instance. In FOO.c:
-
-static PyObject *p_method_name(PyObject *pself, PyObject *args)
-...
-static PyMethodDef p_FOO_methods[] = {
-{ "method_name", p_method_name, METH_VARARGS, NULL }
-...
-};
-PyTypeObject p_FOO_type = {
- .tp_methods = p_FOO_methods,
-...
-};
-
-and only p_FOO_type needs to be declared in common.h.
-
-Similarly, (de)allocators, attr getters/setters also can be static functions
-and be hooked into p_FOO_type.
-
-However, non-method functions can't be static.
-
-
-File reportmodule.c contains the initialization function which should
-initialize types (p_FOO_type objects) and hook up finctions from every
-FOO.c so that they are usable from python code.
-
-Python wrappers for C constants (enums, defines) are created directly
-by reportmodule.c.
diff --git a/libreport/src/report-python/__init__.py b/libreport/src/report-python/__init__.py
deleted file mode 100644
index 796d469b..00000000
--- a/libreport/src/report-python/__init__.py
+++ /dev/null
@@ -1,161 +0,0 @@
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-from _pyreport import *
-
-
-#Compatibility with report package:
-
-import os
-
-SYSTEM_RELEASE_PATHS = ["/etc/system-release","/etc/redhat-release"]
-####SYSTEM_RELEASE_DEPS = ["system-release", "redhat-release"]
-
-_hardcoded_default_product = ""
-_hardcoded_default_version = ""
-
-####def getProduct_fromPRODUCT():
-#### try:
-#### import product
-#### return product.productName
-#### except:
-#### return ""
-
-####def getVersion_fromPRODUCT():
-#### try:
-#### import product
-#### return product.productVersion
-#### except:
-#### return ""
-
-####def getProduct_fromRPM():
-#### try:
-#### import rpm
-#### ts = rpm.TransactionSet()
-#### for each_dep in SYSTEM_RELEASE_DEPS:
-#### mi = ts.dbMatch('provides', each_dep)
-#### for h in mi:
-#### if h['name']:
-#### return h['name'].split("-")[0].capitalize()
-####
-#### return ""
-#### except:
-#### return ""
-
-####def getVersion_fromRPM():
-#### try:
-#### import rpm
-#### ts = rpm.TransactionSet()
-#### for each_dep in SYSTEM_RELEASE_DEPS:
-#### mi = ts.dbMatch('provides', each_dep)
-#### for h in mi:
-#### if h['version']:
-#### return str(h['version'])
-#### return ""
-#### except:
-#### return ""
-
-def getProduct_fromFILE():
- for each_path in SYSTEM_RELEASE_PATHS:
- try:
- file = open(each_path, "r")
- content = file.read()
- if content.startswith("Red Hat Enterprise Linux"):
- return "Red Hat Enterprise Linux"
- if content.startswith("Fedora"):
- return "Fedora"
- i = content.find(" release")
- if i > -1:
- return content[0:i]
- except:
- pass
- return ""
-
-def getVersion_fromFILE():
- for each_path in SYSTEM_RELEASE_PATHS:
- try:
- file = open(each_path, "r")
- content = file.read()
- if content.find("Rawhide") > -1:
- return "rawhide"
- clist = content.split(" ")
- i = clist.index("release")
- return clist[i+1]
- except:
- pass
- return ""
-
-def getProduct():
- ####product = getProduct_fromPRODUCT()
- ####if product:
- #### return product
- product = getProduct_fromFILE()
- if product:
- return product
- ####product = getProduct_fromRPM()
- ####if product:
- #### return product
- return _hardcoded_default_product
-
-def getVersion():
- ####version = getVersion_fromPRODUCT()
- ####if version:
- #### return version
- version = getVersion_fromFILE()
- if version:
- return version
- ####version = getVersion_fromRPM()
- ####if version:
- #### return version
- return _hardcoded_default_version
-
-def createAlertSignature(component, hashmarkername, hashvalue, summary, alertSignature):
- pd = problem_data()
- pd.add("component", component)
- pd.add("hashmarkername", hashmarkername)
- pd.add("duphash", hashvalue)
- pd.add("reason", summary)
- pd.add("description", alertSignature)
- pd.add_basics()
-
- return pd
-
-# used in anaconda / python-meh
-def createPythonUnhandledExceptionSignature(component, hashmarkername, hashvalue, summary, description, exnFileName):
- pd = problem_data()
- pd.add("component", component)
- pd.add("hashmarkername", hashmarkername)
- #cd.add("localhash", hashvalue)
- pd.add("duphash", hashvalue)
- pd.add("reason", summary)
- pd.add("description", description)
- #pd.add("product", getProduct())
- #pd.add("version", getVersion())
- pd.add_basics() # adds product and version + some other required field
- # FIXME: how to handle files out of dump dir??
- #1 = flag BIN
- pd.add("pythonUnhandledException", exnFileName, 1)
-
- return pd
-
-"""
-def report(cd, io_unused):
- state = run_event_state()
- #state.logging_callback = logfunc
- r = state.run_event_on_problem_data(cd, "report")
- return r
-"""
-
-def report(pd, io_unused):
- result = report_problem(pd)
diff --git a/libreport/src/report-python/accountmanager.py b/libreport/src/report-python/accountmanager.py
deleted file mode 100644
index 878be20e..00000000
--- a/libreport/src/report-python/accountmanager.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-
-"""
- Compatibility with report package
-"""
-
-class AccountManager:
- pass
diff --git a/libreport/src/report-python/common.h b/libreport/src/report-python/common.h
deleted file mode 100644
index 713aa2f2..00000000
--- a/libreport/src/report-python/common.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright (C) 2009 Abrt team.
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <Python.h>
-
-#include "dump_dir.h"
-#include "problem_data.h"
-#include "run_event.h"
-#include "report.h"
-
-/* exception object */
-extern PyObject *ReportError;
-
-/* type objects */
-extern PyTypeObject p_problem_data_type;
-extern PyTypeObject p_dump_dir_type;
-extern PyTypeObject p_run_event_state_type;
-
-/* python objects' struct defs */
-typedef struct {
- PyObject_HEAD
- struct dump_dir *dd;
-} p_dump_dir;
-
-typedef struct {
- PyObject_HEAD
- problem_data_t *cd;
-} p_problem_data;
-
-/* module-level functions */
-/* for include/report/dump_dir.h */
-PyObject *p_dd_opendir(PyObject *module, PyObject *args);
-PyObject *p_dd_create(PyObject *module, PyObject *args);
-PyObject *p_delete_dump_dir(PyObject *pself, PyObject *args);
-/* for include/report/report.h */
-PyObject *p_report_problem_in_dir(PyObject *pself, PyObject *args);
-PyObject *p_report_problem_in_memory(PyObject *pself, PyObject *args);
-PyObject *p_report_problem(PyObject *pself, PyObject *args);
diff --git a/libreport/src/report-python/dump_dir.c b/libreport/src/report-python/dump_dir.c
deleted file mode 100644
index e14e68d2..00000000
--- a/libreport/src/report-python/dump_dir.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- On-disk storage of problem data
-
- Copyright (C) 2010 Abrt team
- Copyright (C) 2010 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <Python.h>
-#include <structmember.h>
-
-#include <errno.h>
-#include "common.h"
-
-/*** init/cleanup ***/
-
-static PyObject *
-p_dump_dir_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- p_dump_dir *self = (p_dump_dir *)type->tp_alloc(type, 0);
- if (self)
- self->dd = NULL;
- return (PyObject *)self;
-}
-
-static void
-p_dump_dir_dealloc(PyObject *pself)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
- dd_close(self->dd);
- self->dd = NULL;
- self->ob_type->tp_free(pself);
-}
-
-//static int
-//p_dump_dir_init(PyObject *pself, PyObject *args, PyObject *kwds)
-//{
-// return 0;
-//}
-
-
-/*** methods ***/
-
-/* void dd_close(struct dump_dir *dd); */
-static PyObject *p_dd_close(PyObject *pself, PyObject *args)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
- dd_close(self->dd);
- self->dd = NULL;
- Py_RETURN_NONE;
-}
-
-/* void dd_delete(struct dump_dir *dd); */
-static PyObject *p_dd_delete(PyObject *pself, PyObject *args)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
-//Do we want to disallow delete() on non-opened dd?
-// if (!self->dd)
-// {
-// PyErr_SetString(ReportError, "dump dir is not open");
-// return NULL;
-// }
- dd_delete(self->dd);
- self->dd = NULL;
- Py_RETURN_NONE;
-}
-
-/* int dd_exist(struct dump_dir *dd, const char *path); */
-static PyObject *p_dd_exist(PyObject *pself, PyObject *args)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
- if (!self->dd)
- {
- PyErr_SetString(ReportError, "dump dir is not open");
- return NULL;
- }
- const char *path;
- if (!PyArg_ParseTuple(args, "s", &path))
- {
- return NULL;
- }
- return Py_BuildValue("i", dd_exist(self->dd, path));
-}
-
-/* DIR *dd_init_next_file(struct dump_dir *dd); */
-//static PyObject *p_dd_init_next_file(PyObject *pself, PyObject *args);
-/* int dd_get_next_file(struct dump_dir *dd, char **short_name, char **full_name); */
-//static PyObject *p_dd_get_next_file(PyObject *pself, PyObject *args);
-
-/* char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned flags); */
-/* char* dd_load_text(const struct dump_dir *dd, const char *name); */
-static PyObject *p_dd_load_text(PyObject *pself, PyObject *args)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
- if (!self->dd)
- {
- PyErr_SetString(ReportError, "dump dir is not open");
- return NULL;
- }
- const char *name;
- int flags = 0;
- if (!PyArg_ParseTuple(args, "s|i", &name, &flags))
- {
- return NULL;
- }
- char *val = dd_load_text_ext(self->dd, name, flags);
- PyObject *obj = Py_BuildValue("s", val); /* NB: if val is NULL, obj is None */
- free(val);
- return obj;
-}
-
-/* void dd_save_text(struct dump_dir *dd, const char *name, const char *data); */
-static PyObject *p_dd_save_text(PyObject *pself, PyObject *args)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
- if (!self->dd)
- {
- PyErr_SetString(ReportError, "dump dir is not open");
- return NULL;
- }
- const char *name;
- const char *data;
- if (!PyArg_ParseTuple(args, "ss", &name, &data))
- {
- return NULL;
- }
- dd_save_text(self->dd, name, data);
- Py_RETURN_NONE;
-}
-
-/* void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size); */
-static PyObject *p_dd_save_binary(PyObject *pself, PyObject *args)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
- if (!self->dd)
- {
- PyErr_SetString(ReportError, "dump dir is not open");
- return NULL;
- }
- const char *name;
- const char *data;
- unsigned size;
- if (!PyArg_ParseTuple(args, "ssI", &name, &data, &size))
- {
- return NULL;
- }
- dd_save_binary(self->dd, name, data, size);
- Py_RETURN_NONE;
-}
-
-
-/*** attribute getters/setters ***/
-
-static PyObject *get_name(PyObject *pself, void *unused)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
- if (self->dd)
- return Py_BuildValue("s", self->dd->dd_dirname);
- Py_RETURN_NONE;
-}
-
-//static PyObject *set_name(PyObject *pself, void *unused)
-//{
-// PyErr_SetString(ReportError, "dump dir name is not settable");
-// Py_RETURN_NONE;
-//}
-
-
-/*** type object ***/
-
-static PyMethodDef p_dump_dir_methods[] = {
- /* method_name, func, flags, doc_string */
- { "close" , p_dd_close, METH_NOARGS, NULL },
- { "delete" , p_dd_delete, METH_NOARGS, NULL },
- { "exist" , p_dd_exist, METH_VARARGS, NULL },
- { "load_text" , p_dd_load_text, METH_VARARGS, NULL },
- { "save_text" , p_dd_save_text, METH_VARARGS, NULL },
- { "save_binary", p_dd_save_binary, METH_VARARGS, NULL },
- { NULL }
-};
-
-static PyGetSetDef p_dump_dir_getset[] = {
- /* attr_name, getter_func, setter_func, doc_string, void_param */
- { (char*) "name", get_name, NULL /*set_name*/ },
- { NULL }
-};
-
-/* Support for "dd = dd_opendir(...); if [not] dd: ..." */
-static int p_dd_is_non_null(PyObject *pself)
-{
- p_dump_dir *self = (p_dump_dir*)pself;
- return self->dd != NULL;
-}
-static PyNumberMethods p_dump_dir_number_methods = {
- .nb_nonzero = p_dd_is_non_null,
-};
-
-PyTypeObject p_dump_dir_type = {
- PyObject_HEAD_INIT(NULL)
- .tp_name = "report.dump_dir",
- .tp_basicsize = sizeof(p_dump_dir),
- /* Py_TPFLAGS_BASETYPE means "can be subtyped": */
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- .tp_new = p_dump_dir_new,
- .tp_dealloc = p_dump_dir_dealloc,
- //.tp_init = p_dump_dir_init,
- //.tp_members = p_dump_dir_members,
- .tp_methods = p_dump_dir_methods,
- .tp_as_number = &p_dump_dir_number_methods,
- .tp_getset = p_dump_dir_getset,
-};
-
-
-/*** module-level functions ***/
-
-/* struct dump_dir *dd_opendir(const char *dir, int flags); */
-PyObject *p_dd_opendir(PyObject *module, PyObject *args)
-{
- const char *dir;
- int flags = 0;
- if (!PyArg_ParseTuple(args, "s|i", &dir, &flags))
- return NULL;
- p_dump_dir *new_dd = PyObject_New(p_dump_dir, &p_dump_dir_type);
- if (!new_dd)
- return NULL;
- new_dd->dd = dd_opendir(dir, flags);
- return (PyObject*)new_dd;
-}
-
-/* struct dump_dir *dd_create(const char *dir, uid_t uid); */
-PyObject *p_dd_create(PyObject *module, PyObject *args)
-{
- const char *dir;
- int uid = -1;
- if (!PyArg_ParseTuple(args, "s|i", &dir, &uid))
- return NULL;
- p_dump_dir *new_dd = PyObject_New(p_dump_dir, &p_dump_dir_type);
- if (!new_dd)
- return NULL;
- new_dd->dd = dd_create(dir, uid, 0640);
- return (PyObject*)new_dd;
-}
-
-/* void delete_dump_dir(const char *dirname); */
-PyObject *p_delete_dump_dir(PyObject *pself, PyObject *args)
-{
- const char *dirname;
- if (!PyArg_ParseTuple(args, "s", &dirname))
- return NULL;
- delete_dump_dir(dirname);
- Py_RETURN_NONE;
-}
diff --git a/libreport/src/report-python/io/GTKIO.py b/libreport/src/report-python/io/GTKIO.py
deleted file mode 100644
index a3b3d438..00000000
--- a/libreport/src/report-python/io/GTKIO.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-"""
- Compatibility with report package
-"""
-
-class GTKIO:
- def __init__(self, loginManager = None):
- pass
-
-#class FailDialog():
-# def __init__(self, title, message):
-# pass
diff --git a/libreport/src/report-python/io/NewtIO.py b/libreport/src/report-python/io/NewtIO.py
deleted file mode 100644
index 6f9670dd..00000000
--- a/libreport/src/report-python/io/NewtIO.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-"""
- Compatibility with report package
-"""
-
-class NewtIO:
- def __init__(self, screen = None):
- pass
diff --git a/libreport/src/report-python/io/TextIO.py b/libreport/src/report-python/io/TextIO.py
deleted file mode 100644
index 5d386a61..00000000
--- a/libreport/src/report-python/io/TextIO.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-"""
- Compatibility with report package
-"""
-
-class TextIO:
- pass
diff --git a/libreport/src/report-python/io/__init__.py b/libreport/src/report-python/io/__init__.py
deleted file mode 100644
index fd16dc91..00000000
--- a/libreport/src/report-python/io/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-pass
diff --git a/libreport/src/report-python/libreport-meh-test.py b/libreport/src/report-python/libreport-meh-test.py
deleted file mode 100644
index 4ef24834..00000000
--- a/libreport/src/report-python/libreport-meh-test.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/env python
-
-from meh.dump import ReverseExceptionDump
-from meh.handler import *
-from meh.ui.gui import *
-
-class Config:
- def __init__(self):
- self.programName = "abrt"
- self.programVersion = "2.0"
- self.attrSkipList = []
- self.fileList = []
- self.config_value_one = 1
- self.config_value_two = 2
-
-
-
-#meh.makeRHHandler("crash-test-meh", "1.0", Config())
-config = Config()
-intf = GraphicalIntf(None)
-handler = ExceptionHandler(config, intf, ReverseExceptionDump)
-handler.install(None)
-
-
-print "handler set up, about to divide by zero"
-
-zero = 0
-print 1 / zero
-
-print "should have crashed"
-
diff --git a/libreport/src/report-python/problem_data.c b/libreport/src/report-python/problem_data.c
deleted file mode 100644
index 9067dead..00000000
--- a/libreport/src/report-python/problem_data.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- Copyright (C) 2010 Abrt team.
- Copyright (C) 2010 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <Python.h>
-#include <structmember.h>
-
-#include <errno.h>
-#include "common.h"
-
-static void
-p_problem_data_dealloc(PyObject *pself)
-{
- p_problem_data *self = (p_problem_data*)pself;
- free_problem_data(self->cd);
- self->cd = NULL;
- self->ob_type->tp_free(pself);
-}
-
-static PyObject *
-p_problem_data_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- p_problem_data *self = (p_problem_data *)type->tp_alloc(type, 0);
- if (self)
- self->cd = new_problem_data();
- return (PyObject *)self;
-}
-
-//static int
-//p_problem_data_init(PyObject *pself, PyObject *args, PyObject *kwds)
-//{
-// return 0;
-//}
-
-/*
-void add_to_problem_data_ext(problem_data_t *problem_data,
- const char *name,
- const char *content,
- unsigned flags);
-*/
-static PyObject *p_problem_data_add(PyObject *pself, PyObject *args)
-{
- p_problem_data *self = (p_problem_data*)pself;
-
- const char *name;
- const char *content;
- int flags = 0;
- if (!PyArg_ParseTuple(args, "ss|i", &name, &content, &flags))
- {
- /* PyArg_ParseTuple raises the exception saying why it fails
- * eg: TypeError: function takes exactly 2 arguments (1 given)
- */
- return NULL;
- }
- add_to_problem_data_ext(self->cd, name, content, flags);
-
- /* every function returns PyObject, to return void we need to do this */
- Py_RETURN_NONE;
-}
-
-/* struct problem_item *get_problem_data_item_or_NULL(problem_data_t *problem_data, const char *key); */
-static PyObject *p_get_problem_data_item(PyObject *pself, PyObject *args)
-{
- p_problem_data *self = (p_problem_data*)pself;
- const char *key;
- if (!PyArg_ParseTuple(args, "s", &key))
- {
- return NULL;
- }
- struct problem_item *ci = get_problem_data_item_or_NULL(self->cd, key);
- if (ci == NULL)
- {
- Py_RETURN_NONE;
- }
- return Py_BuildValue("sI", ci->content, ci->flags);
-}
-
-/* struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name); */
-static PyObject *p_create_dump_dir_from_problem_data(PyObject *pself, PyObject *args)
-{
- p_problem_data *self = (p_problem_data*)pself;
- const char *base_dir_name = NULL;
- if (!PyArg_ParseTuple(args, "|s", &base_dir_name))
- {
- return NULL;
- }
- p_dump_dir *new_dd = PyObject_New(p_dump_dir, &p_dump_dir_type);
- if (!new_dd)
- return NULL;
- struct dump_dir *dd = create_dump_dir_from_problem_data(self->cd, base_dir_name);
- if (!dd)
- {
- PyObject_Del((PyObject*)new_dd);
- PyErr_SetString(ReportError, "Can't create the dump dir");
- return NULL;
- }
- new_dd->dd = dd;
- return (PyObject*)new_dd;
-}
-
-static PyObject *p_add_basics_to_problem_data(PyObject *pself, PyObject *always_null)
-{
- p_problem_data *self = (p_problem_data*)pself;
- add_basics_to_problem_data(self->cd);
-
- Py_RETURN_NONE;
-}
-
-
-//static PyMemberDef p_problem_data_members[] = {
-// { NULL }
-//};
-
-static PyMethodDef p_problem_data_methods[] = {
- /* method_name, func, flags, doc_string */
- { "add" , p_problem_data_add , METH_VARARGS },
- { "get" , p_get_problem_data_item , METH_VARARGS },
- { "create_dump_dir", p_create_dump_dir_from_problem_data, METH_VARARGS },
- { "add_basics", p_add_basics_to_problem_data, METH_NOARGS },
- { NULL }
-};
-
-PyTypeObject p_problem_data_type = {
- PyObject_HEAD_INIT(NULL)
- .tp_name = "report.problem_data",
- .tp_basicsize = sizeof(p_problem_data),
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- .tp_new = p_problem_data_new,
- .tp_dealloc = p_problem_data_dealloc,
- //.tp_init = p_problem_data_init,
- //.tp_members = p_problem_data_members,
- .tp_methods = p_problem_data_methods,
-};
diff --git a/libreport/src/report-python/py_report_test.py b/libreport/src/report-python/py_report_test.py
deleted file mode 100644
index e15044f8..00000000
--- a/libreport/src/report-python/py_report_test.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import _pyreport
-
-pd = _pyreport.problem_data()
-pd.add("foo", "bar")
-pd.add("description", "python-libreport test bug")
-
-_pyreport.report(pd)
diff --git a/libreport/src/report-python/pyreport.c b/libreport/src/report-python/pyreport.c
deleted file mode 100644
index 0df47e78..00000000
--- a/libreport/src/report-python/pyreport.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- Copyright (C) 2009 Abrt team.
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "common.h"
-
-/* struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name); */
diff --git a/libreport/src/report-python/report.c b/libreport/src/report-python/report.c
deleted file mode 100644
index 0bdd4076..00000000
--- a/libreport/src/report-python/report.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- Copyright (C) 2010 Abrt team.
- Copyright (C) 2010 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <Python.h>
-
-#include "common.h"
-
-/* 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);
-}
-
-/* C: int report_problem_in_memory(problem_data_t *pd, int flags); */
-PyObject *p_report_problem_in_memory(PyObject *pself, PyObject *args)
-{
- p_problem_data *pd;
- int flags;
- if (!PyArg_ParseTuple(args, "O!i", &p_problem_data_type, &pd, &flags))
- {
- return NULL;
- }
- int r = report_problem_in_memory(pd->cd, flags);
- return Py_BuildValue("i", r);
-}
-
-/* C: int report_problem(problem_data_t *pd); */
-PyObject *p_report_problem(PyObject *pself, PyObject *args)
-{
- p_problem_data *pd;
- if (!PyArg_ParseTuple(args, "O!", &p_problem_data_type, &pd))
- {
- return NULL;
- }
- int r = report_problem(pd->cd);
- return Py_BuildValue("i", r);
-}
diff --git a/libreport/src/report-python/reportmodule.c b/libreport/src/report-python/reportmodule.c
deleted file mode 100644
index 539c66aa..00000000
--- a/libreport/src/report-python/reportmodule.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- Copyright (C) 2010 Abrt team.
- Copyright (C) 2010 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <Python.h>
-
-#include "common.h"
-
-PyObject *ReportError;
-
-static PyMethodDef module_methods[] = {
- /* method_name, func, flags, doc_string */
- /* for include/report/dump_dir.h */
- { "dd_opendir" , p_dd_opendir , METH_VARARGS },
- { "dd_create" , p_dd_create , METH_VARARGS },
- { "delete_dump_dir" , p_delete_dump_dir , METH_VARARGS },
- /* for include/report/report.h */
- { "report_problem_in_dir" , p_report_problem_in_dir , METH_VARARGS },
- { "report_problem_in_memory" , p_report_problem_in_memory, METH_VARARGS },
- { "report_problem" , p_report_problem , METH_VARARGS },
- { NULL }
-};
-
-#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
-#define PyMODINIT_FUNC void
-#endif
-PyMODINIT_FUNC
-init_pyreport(void)
-{
- if (PyType_Ready(&p_problem_data_type) < 0)
- {
- printf("PyType_Ready(&p_problem_data_type) < 0\n");
- return;
- }
- if (PyType_Ready(&p_dump_dir_type) < 0)
- {
- printf("PyType_Ready(&p_dump_dir_type) < 0\n");
- return;
- }
- if (PyType_Ready(&p_run_event_state_type) < 0)
- {
- printf("PyType_Ready(&p_run_event_state_type) < 0\n");
- return;
- }
-
- PyObject *m = Py_InitModule("_pyreport", module_methods);
- //m = Py_InitModule3("_pyreport", module_methods, "Python wrapper for libreport");
- if (!m)
- {
- printf("m == NULL\n");
- return;
- }
-
- /* init the exception object */
- ReportError = PyErr_NewException((char*) "_pyreport.error", NULL, NULL);
- Py_INCREF(ReportError);
- PyModule_AddObject(m, "error", ReportError);
-
- /* init type objects and constants */
- /* for include/report/problem_data.h */
- Py_INCREF(&p_problem_data_type);
- PyModule_AddObject(m, "problem_data", (PyObject *)&p_problem_data_type);
- PyModule_AddObject(m, "CD_FLAG_BIN" , Py_BuildValue("i", CD_FLAG_BIN ));
- PyModule_AddObject(m, "CD_FLAG_TXT" , Py_BuildValue("i", CD_FLAG_TXT ));
- PyModule_AddObject(m, "CD_FLAG_ISEDITABLE" , Py_BuildValue("i", CD_FLAG_ISEDITABLE ));
- PyModule_AddObject(m, "CD_FLAG_ISNOTEDITABLE", Py_BuildValue("i", CD_FLAG_ISNOTEDITABLE));
- /* for include/report/dump_dir.h */
- Py_INCREF(&p_dump_dir_type);
- PyModule_AddObject(m, "dump_dir", (PyObject *)&p_dump_dir_type);
- PyModule_AddObject(m, "DD_FAIL_QUIETLY_ENOENT" , Py_BuildValue("i", DD_FAIL_QUIETLY_ENOENT ));
- PyModule_AddObject(m, "DD_FAIL_QUIETLY_EACCES" , Py_BuildValue("i", DD_FAIL_QUIETLY_EACCES ));
- PyModule_AddObject(m, "DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE", Py_BuildValue("i", DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE));
- /* for include/report/run_event.h */
- Py_INCREF(&p_run_event_state_type);
- PyModule_AddObject(m, "run_event_state", (PyObject *)&p_run_event_state_type);
- /* for include/report/report.h */
- PyModule_AddObject(m, "LIBREPORT_NOWAIT" , Py_BuildValue("i", LIBREPORT_NOWAIT ));
- PyModule_AddObject(m, "LIBREPORT_WAIT" , Py_BuildValue("i", LIBREPORT_WAIT ));
- PyModule_AddObject(m, "LIBREPORT_ANALYZE" , Py_BuildValue("i", LIBREPORT_ANALYZE ));
- PyModule_AddObject(m, "LIBREPORT_RELOAD_DATA", Py_BuildValue("i", LIBREPORT_RELOAD_DATA));
-}
diff --git a/libreport/src/report-python/run_event.c b/libreport/src/report-python/run_event.c
deleted file mode 100644
index 50e3794e..00000000
--- a/libreport/src/report-python/run_event.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- Copyright (C) 2010 Abrt team.
- Copyright (C) 2010 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <Python.h>
-#include <structmember.h>
-
-#include <errno.h>
-#include "common.h"
-#include "problem_data.h"
-#include "run_event.h"
-
-typedef struct {
- PyObject_HEAD
- struct run_event_state *state;
- PyObject *post_run_callback;
- PyObject *logging_callback;
-} p_run_event_state;
-
-
-/*** init/cleanup ***/
-
-static int post_run_callback(const char *dump_dir_name, void *param);
-static char *logging_callback(char *log_line, void *param);
-
-static PyObject *p_run_event_state_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- p_run_event_state *self = (p_run_event_state *)type->tp_alloc(type, 0);
- if (self)
- {
- self->state = new_run_event_state();
- self->state->post_run_callback = post_run_callback;
- self->state->logging_callback = logging_callback;
- self->state->post_run_param = self;
- self->state->logging_param = self;
- }
- return (PyObject *)self;
-}
-
-static void p_run_event_state_dealloc(PyObject *pself)
-{
- p_run_event_state *self = (p_run_event_state*)pself;
- free_run_event_state(self->state);
- self->state = NULL;
- Py_XDECREF(self->post_run_callback);
- self->post_run_callback = NULL;
- Py_XDECREF(self->logging_callback);
- self->logging_callback = NULL;
- self->ob_type->tp_free(pself);
-}
-
-//static int
-//p_run_event_state_init(PyObject *pself, PyObject *args, PyObject *kwds)
-//{
-// return 0;
-//}
-
-
-/*** methods ***/
-
-/* First, C-level callback helpers for run_event_on_FOO(): */
-static int post_run_callback(const char *dump_dir_name, void *param)
-{
- PyObject *obj = (PyObject*)param;
- PyObject *ret = PyObject_CallMethod(obj, (char*) "post_run_callback", (char*) "(s)", dump_dir_name);
- int r = 0;
- if (ret)
- {
- r = PyInt_AsLong(ret);
- Py_DECREF(ret);
- }
- // TODO: handle exceptions: if (PyErr_Occurred()) ...
- return r;
-}
-static char *logging_callback(char *log_line, void *param)
-{
- PyObject *obj = (PyObject*)param;
- PyObject *ret = PyObject_CallMethod(obj, (char*) "logging_callback", (char*) "(s)", log_line);
- Py_XDECREF(ret);
- // TODO: handle exceptions: if (PyErr_Occurred()) ...
- return log_line; /* signaling to caller that we didnt consume the string */
-}
-
-/* int run_event_on_dir_name(struct run_event_state *state, const char *dump_dir_name, const char *event); */
-static PyObject *p_run_event_on_dir_name(PyObject *pself, PyObject *args)
-{
- p_run_event_state *self = (p_run_event_state*)pself;
- const char *dump_dir_name;
- const char *event;
- if (!PyArg_ParseTuple(args, "ss", &dump_dir_name, &event))
- {
- return NULL;
- }
- int r = run_event_on_dir_name(self->state, dump_dir_name, event);
- PyObject *obj = Py_BuildValue("i", r);
- return obj;
-}
-
-/* int run_event_on_problem_data(struct run_event_state *state, problem_data_t *data, const char *event); */
-static PyObject *p_run_event_on_problem_data(PyObject *pself, PyObject *args)
-{
- p_run_event_state *self = (p_run_event_state*)pself;
- p_problem_data *cd;
- const char *event;
- if (!PyArg_ParseTuple(args, "O!s", &p_problem_data_type, &cd, &event))
- {
- return NULL;
- }
- int r = run_event_on_problem_data(self->state, cd->cd, event);
- PyObject *obj = Py_BuildValue("i", r);
- return obj;
-}
-
-/* TODO: char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); */
-
-
-/*** attribute getters/setters ***/
-
-static PyObject *get_post_run_callback(PyObject *pself, void *unused)
-{
- p_run_event_state *self = (p_run_event_state*)pself;
- if (self->post_run_callback)
- {
- Py_INCREF(self->post_run_callback);
- return self->post_run_callback;
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *get_logging_callback(PyObject *pself, void *unused)
-{
- p_run_event_state *self = (p_run_event_state*)pself;
- if (self->logging_callback)
- {
- Py_INCREF(self->logging_callback);
- return self->logging_callback;
- }
- Py_RETURN_NONE;
-}
-
-static int set_post_run_callback(PyObject *pself, PyObject *callback, void *unused)
-{
- p_run_event_state *self = (p_run_event_state*)pself;
-//WRONG: we aren't a Python function, calling convention is different
-// PyObject *callback;
-// if (!PyArg_ParseTuple(args, "O", &callback))
-// return -1;
- if (!PyCallable_Check(callback))
- {
- PyErr_SetString(PyExc_TypeError, "parameter must be callable");
- return -1;
- }
- Py_INCREF(callback);
- Py_XDECREF(self->post_run_callback);
- self->post_run_callback = callback;
- return 0;
-}
-
-static int set_logging_callback(PyObject *pself, PyObject *callback, void *unused)
-{
- p_run_event_state *self = (p_run_event_state*)pself;
- if (!PyCallable_Check(callback))
- {
- PyErr_SetString(PyExc_TypeError, "parameter must be callable");
- return -1;
- }
- Py_INCREF(callback);
- Py_XDECREF(self->logging_callback);
- self->logging_callback = callback;
- return 0;
-}
-
-
-/*** type object ***/
-
-//static PyMemberDef p_run_event_state_members[] = {
-// { NULL }
-//};
-
-static PyMethodDef p_run_event_state_methods[] = {
- /* method_name, func, flags, doc_string */
- { "run_event_on_dir_name" , p_run_event_on_dir_name , METH_VARARGS },
- { "run_event_on_problem_data", p_run_event_on_problem_data, METH_VARARGS },
- { NULL }
-};
-
-static PyGetSetDef p_run_event_state_getset[] = {
- /* attr_name, getter_func, setter_func, doc_string, void_param */
- { (char*) "post_run_callback", get_post_run_callback, set_post_run_callback },
- { (char*) "logging_callback" , get_logging_callback , set_logging_callback },
- { NULL }
-};
-
-PyTypeObject p_run_event_state_type = {
- PyObject_HEAD_INIT(NULL)
- .tp_name = "report.run_event_state",
- .tp_basicsize = sizeof(p_run_event_state),
- /* Py_TPFLAGS_BASETYPE means "can be subtyped": */
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- .tp_new = p_run_event_state_new,
- .tp_dealloc = p_run_event_state_dealloc,
- //.tp_init = p_run_event_state_init,
- //.tp_members = p_run_event_state_members,
- .tp_methods = p_run_event_state_methods,
- .tp_getset = p_run_event_state_getset,
-};
diff --git a/libreport/src/report-python/test_dd_create b/libreport/src/report-python/test_dd_create
deleted file mode 100755
index 4da29b11..00000000
--- a/libreport/src/report-python/test_dd_create
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-
-from report import *
-
-dd = dd_create("testdir")
-print dd
-
-if dd:
- print "dd is nonzero"
-else:
- print "dd is zero"
-
-print "name:", dd.name
-print "closing"
-dd.close()
-
-if dd:
- print "dd is nonzero"
-else:
- print "dd is zero"
-
-# Should fail here
-dd.name = "qwe"
-
-print "Done"
diff --git a/libreport/src/report-python/test_full b/libreport/src/report-python/test_full
deleted file mode 100755
index 107c4857..00000000
--- a/libreport/src/report-python/test_full
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-
-import sys
-from report import *
-
-def run_event_on_problem_data(cd, event, log_function = None):
- dd = cd.create_dump_dir("/tmp")
- dir_name = dd.name
- print "Created dump_dir:", dir_name
- dd.close()
- run_state = run_event_state()
- if log_function: # maybe if callable(log_function)?
- run_state.logging_callback = log_function
- print "Running event:", event
- r = run_state.run_event_on_dir_name(dir_name, event)
- print "Deleting:", dir_name
- delete_dump_dir(dir_name)
- return r;
-
-def log_function(line):
- print "LOG:", line
-
-cd = problem_data()
-cd.add("foo", "bar")
-cd.add("analyzer", "baz", CD_FLAG_ISNOTEDITABLE)
-r = run_event_on_problem_data(cd, "post-create", log_function)
-print "Result:", r
diff --git a/libreport/src/report-python/test_full2 b/libreport/src/report-python/test_full2
deleted file mode 100755
index e6cfd4d9..00000000
--- a/libreport/src/report-python/test_full2
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/python
-
-import sys
-from report import *
-
-def log_function(line):
- print "LOG:", line
-
-cd = problem_data()
-cd.add("foo", "bar")
-cd.add("analyzer", "baz", CD_FLAG_ISNOTEDITABLE)
-
-st = run_event_state()
-st.logging_callback = log_function
-r = st.run_event_on_problem_data(cd, "post-create")
-
-print "Result:", r
diff --git a/libreport/src/report-python/test_problem_data b/libreport/src/report-python/test_problem_data
deleted file mode 100644
index 16f1f9ae..00000000
--- a/libreport/src/report-python/test_problem_data
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/python
-
-from report import *
-
-cd = problem_data()
-cd.add("foo", "bar")
-
-dd = cd.create_dump_dir()
-
-if dd:
- print "dd is nonzero"
-else:
- print "dd is zero"
-
-print "closing"
-dd.close()
-
-if dd:
- print "dd is nonzero"
-else:
- print "dd is zero"
diff --git a/libreport/src/report-python/test_problem_data2 b/libreport/src/report-python/test_problem_data2
deleted file mode 100644
index 3d3692b9..00000000
--- a/libreport/src/report-python/test_problem_data2
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/python
-
-from report import *
-
-cd = problem_data()
-cd.add("foo", "bar")
-
-print "foo:", cd.get("foo")
-print "nonexistent:", cd.get("nonexistent")
-print "done"
diff --git a/libreport/src/report-python/test_run_event_state b/libreport/src/report-python/test_run_event_state
deleted file mode 100755
index 3e391407..00000000
--- a/libreport/src/report-python/test_run_event_state
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/python
-
-from report import *
-
-def func():
- return 0
-
-res = run_event_state()
-print res
-print res.post_run_callback
-res.post_run_callback = func
-res.logging_callback = func
-print res.post_run_callback
diff --git a/libreport/src/report-python/test_run_event_state1 b/libreport/src/report-python/test_run_event_state1
deleted file mode 100755
index 6c3584fe..00000000
--- a/libreport/src/report-python/test_run_event_state1
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-
-import sys
-from report import *
-
-def post_run_callback(dump_dir_name):
- return 0
-
-def logging_callback(line):
- print "LOG:", line
- return
-
-res = run_event_state()
-res.post_run_callback = post_run_callback
-res.logging_callback = logging_callback
-
-dd = dd_create("testdir")
-if not dd:
- sys.exit(1)
-dd.save_text("analyzer", "foo")
-dd.close()
-
-res.run_event_on_dir_name("testdir", "post-create")
-
-dd = dd_opendir("testdir")
-dd.delete()
-dd.close()
diff --git a/libreport/src/report-python/test_setroubleshoot_example b/libreport/src/report-python/test_setroubleshoot_example
deleted file mode 100755
index 74428f16..00000000
--- a/libreport/src/report-python/test_setroubleshoot_example
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/python
-
-import report
-import report.io
-import report.io.GTKIO
-import report.accountmanager
-
-accounts = report.accountmanager.AccountManager()
-
-signature = report.createAlertSignature("selinux-policy",
- "setroubleshoot",
- "self.siginfo.get_hash()",
- "self.summary",
- "content")
-
-rc = report.report(signature, report.io.GTKIO.GTKIO(accounts))
-
-print "rc:", rc
diff --git a/libreport/src/report-python/test_setroubleshoot_example2 b/libreport/src/report-python/test_setroubleshoot_example2
deleted file mode 100755
index b712cda7..00000000
--- a/libreport/src/report-python/test_setroubleshoot_example2
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-
-import report
-import report.io
-import report.io.GTKIO
-import report.accountmanager
-
-accounts = report.accountmanager.AccountManager()
-
-signature = report.createAlertSignature("selinux-policy",
- "setroubleshoot",
- "self.siginfo.get_hash()",
- "self.summary",
- "content")
-
-# Won't send log anywhere:
-#rc = report.report(signature, report.io.GTKIO.GTKIO(accounts))
-
-# report.report() + logging:
-def logging_callback(line):
- print "LOG:", line
- return
-state = report.run_event_state()
-state.logging_callback = logging_callback
-rc = state.run_event_on_problem_data(signature, "report")
-
-print "rc:", rc