[libreport/f16] more anaconda compat fixes rhbz#733448 #728479
Jiří Moskovčák
jmoskovc at fedoraproject.org
Mon Sep 5 11:15:58 UTC 2011
commit 578f7c758ed88db7402e2ecd7157566123bd872d
Author: Jiri Moskovcak <jmoskovc at redhat.com>
Date: Mon Sep 5 12:52:46 2011 +0200
more anaconda compat fixes rhbz#733448 #728479
...gzilla-fix-file-attaching-was-using-strle.patch | 102 +++++++++++++
...ort-shell-glob-patterns-in-.xml-item-sele.patch | 151 ++++++++++++++++++++
libreport-fallback-textedit.patch | 51 +++++++
libreport.spec | 13 ++
4 files changed, 317 insertions(+), 0 deletions(-)
---
diff --git a/0001-reporter-bugzilla-fix-file-attaching-was-using-strle.patch b/0001-reporter-bugzilla-fix-file-attaching-was-using-strle.patch
new file mode 100644
index 0000000..7b694a7
--- /dev/null
+++ b/0001-reporter-bugzilla-fix-file-attaching-was-using-strle.patch
@@ -0,0 +1,102 @@
+From 07e991785371cf119e47b7efe063decf38c96dc4 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <dvlasenk at redhat.com>
+Date: Tue, 30 Aug 2011 12:54:26 +0200
+Subject: [PATCH 1/2] reporter-bugzilla: fix file attaching (was using strlen
+ even on binary files)
+
+Signed-off-by: Denys Vlasenko <dvlasenk at redhat.com>
+---
+ src/plugins/reporter-bugzilla.c | 5 +++--
+ src/plugins/rhbz.c | 26 +++++++++++++++-----------
+ src/plugins/rhbz.h | 2 +-
+ 3 files changed, 19 insertions(+), 14 deletions(-)
+
+diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
+index 745ecbb..4bf8708 100644
+--- a/src/plugins/reporter-bugzilla.c
++++ b/src/plugins/reporter-bugzilla.c
+@@ -357,12 +357,13 @@ int main(int argc, char **argv)
+ off_t size = lseek(fd, 0, SEEK_END);
+ if (size < 0)
+ {
+- close(fd);
+ perror_msg("Can't lseek '%s'", filename);
++ close(fd);
+ continue;
+ }
+ lseek(fd, 0, SEEK_SET);
+
++ /* FIXME: what if the file is tens of gigabytes? */
+ char *data = xmalloc(size + 1);
+ ssize_t r = full_read(fd, data, size);
+ if (r < 0)
+@@ -374,7 +375,7 @@ int main(int argc, char **argv)
+ }
+ close(fd);
+
+- rhbz_attachment(client, filename, ticket_no, data, /*flags*/ 0);
++ rhbz_attachment(client, filename, ticket_no, data, r, /*flags*/ 0);
+ free(data);
+ }
+
+diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
+index 5b53465..e086042 100644
+--- a/src/plugins/rhbz.c
++++ b/src/plugins/rhbz.c
+@@ -381,9 +381,9 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
+
+ /* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
+ int rhbz_attachment(struct abrt_xmlrpc *ax, const char *filename,
+- const char *bug_id, const char *data, int flags)
++ const char *bug_id, const char *data, int data_len, int flags)
+ {
+- char *encoded64 = encode_base64(data, strlen(data));
++ char *encoded64 = encode_base64(data, data_len);
+ char *fn = xasprintf("File: %s", filename);
+ xmlrpc_value* result;
+ int nomail_notify = IS_NOMAIL_NOTIFY(flags);
+@@ -416,15 +416,19 @@ int rhbz_attachments(struct abrt_xmlrpc *ax, const char *bug_id,
+ g_hash_table_iter_init(&iter, problem_data);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+- const char *content = value->content;
+-
+- // We were special-casing FILENAME_BACKTRACE here, but karel says
+- // he can retrieve it in inlined form from comments too.
+- if ((value->flags & CD_FLAG_TXT)
+- && (strlen(content) > CD_TEXT_ATT_SIZE /*|| (strcmp(name, FILENAME_BACKTRACE) == 0)*/)
+- ) {
+- /* check if the attachment failed and try it once more */
+- rhbz_attachment(ax, name, bug_id, content, flags);
++ if (value->flags & CD_FLAG_TXT)
++ {
++ const char *content = value->content;
++ unsigned len = strlen(content);
++ // We were special-casing FILENAME_BACKTRACE here, but karel says
++ // he can retrieve it in inlined form from comments too.
++ if (len > CD_TEXT_ATT_SIZE /*|| (strcmp(name, FILENAME_BACKTRACE) == 0)*/)
++ {
++ /* This text item wasn't added in comments, it is too big
++ * for that. Attach it as a file.
++ */
++ rhbz_attachment(ax, name, bug_id, content, len, flags);
++ }
+ }
+ }
+
+diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
+index 6a12c68..29908b6 100644
+--- a/src/plugins/rhbz.h
++++ b/src/plugins/rhbz.h
+@@ -86,7 +86,7 @@ int rhbz_attachments(struct abrt_xmlrpc *ax, const char *bug_id,
+ problem_data_t *problem_data, int flags);
+
+ int rhbz_attachment(struct abrt_xmlrpc *ax, const char *filename,
+- const char *bug_id, const char *data, int flags);
++ const char *bug_id, const char *data, int data_len, int flags);
+
+ GList *rhbz_bug_cc(xmlrpc_value *result_xml);
+
+--
+1.7.6.1
+
diff --git a/0002-wizard-support-shell-glob-patterns-in-.xml-item-sele.patch b/0002-wizard-support-shell-glob-patterns-in-.xml-item-sele.patch
new file mode 100644
index 0000000..8f596e9
--- /dev/null
+++ b/0002-wizard-support-shell-glob-patterns-in-.xml-item-sele.patch
@@ -0,0 +1,151 @@
+From 625a3500d1292068ce5f8cfc56253c4d6d6defea Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <dvlasenk at redhat.com>
+Date: Tue, 30 Aug 2011 14:05:40 +0200
+Subject: [PATCH 2/2] wizard: support shell glob patterns in .xml item
+ selectors
+
+We used to support "*" only. Example:
+
+ <requires-items>backtrace</requires-items>
+ <exclude-items-by-default/>
+ <exclude-items-always>*</exclude-items-always>
+ <exclude-binary-items>yes</exclude-binary-items>
+ <include-items-by-default/>
+ <minimal-rating>0</minimal-rating>
+
+The patch below adds support for patterns like *.txt, abc*
+As a consequence, special-casing code is removed.
+
+Signed-off-by: Denys Vlasenko <dvlasenk at redhat.com>
+---
+ src/gui-wizard-gtk/wizard.c | 24 ++++++------------------
+ src/include/internal_libreport.h | 2 ++
+ src/lib/is_in_comma_separated_list.c | 20 ++++++++++++++++++++
+ src/lib/problem_data.c | 2 +-
+ 4 files changed, 29 insertions(+), 19 deletions(-)
+
+diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
+index a814278..c313bcb 100644
+--- a/src/gui-wizard-gtk/wizard.c
++++ b/src/gui-wizard-gtk/wizard.c
+@@ -1846,18 +1846,6 @@ static void on_page_prepare(GtkAssistant *assistant, GtkWidget *page, gpointer u
+ /* 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);
+- int allowed_by_reporter = 1;
+- int default_by_reporter = 1;
+- if (cfg)
+- {
+- /* Default settings are... */
+- if (cfg->ec_exclude_items_always && strcmp(cfg->ec_exclude_items_always, "*") == 0)
+- allowed_by_reporter = 0;
+- 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;
+@@ -1865,28 +1853,28 @@ static void on_page_prepare(GtkAssistant *assistant, GtkWidget *page, gpointer u
+ 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;
++ item->allowed_by_reporter = 1;
+ if (cfg)
+ {
+- if (is_in_comma_separated_list(name, cfg->ec_exclude_items_always))
++ if (is_in_comma_separated_list_of_glob_patterns(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;
++ item->default_by_reporter = item->allowed_by_reporter;
+ if (cfg)
+ {
+- if (is_in_comma_separated_list(name, cfg->ec_exclude_items_by_default))
++ if (is_in_comma_separated_list_of_glob_patterns(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))
++ if (is_in_comma_separated_list_of_glob_patterns(name, cfg->ec_include_items_by_default))
+ item->allowed_by_reporter = item->default_by_reporter = 1;
+ }
+
+ item->required_by_reporter = 0;
+ if (cfg)
+ {
+- if (is_in_comma_separated_list(name, cfg->ec_requires_items))
++ if (is_in_comma_separated_list_of_glob_patterns(name, cfg->ec_requires_items))
+ item->default_by_reporter = item->allowed_by_reporter = item->required_by_reporter = 1;
+ }
+
+diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
+index 1fee5a3..afaf911 100644
+--- a/src/include/internal_libreport.h
++++ b/src/include/internal_libreport.h
+@@ -236,6 +236,8 @@ bool is_in_string_list(const char *name, char **v);
+
+ #define is_in_comma_separated_list libreport_is_in_comma_separated_list
+ bool is_in_comma_separated_list(const char *value, const char *list);
++#define is_in_comma_separated_list_of_glob_patterns libreport_is_in_comma_separated_list_of_glob_patterns
++bool is_in_comma_separated_list_of_glob_patterns(const char *value, const char *list);
+
+ /* Frees every element'd data using free(),
+ * then frees list itself using g_list_free(list):
+diff --git a/src/lib/is_in_comma_separated_list.c b/src/lib/is_in_comma_separated_list.c
+index 0afaf7b..6bec243 100644
+--- a/src/lib/is_in_comma_separated_list.c
++++ b/src/lib/is_in_comma_separated_list.c
+@@ -16,6 +16,7 @@
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
++#include <fnmatch.h>
+ #include "internal_libreport.h"
+
+ bool is_in_comma_separated_list(const char *value, const char *list)
+@@ -34,3 +35,22 @@ bool is_in_comma_separated_list(const char *value, const char *list)
+ }
+ return false;
+ }
++
++bool is_in_comma_separated_list_of_glob_patterns(const char *value, const char *list)
++{
++ if (!list)
++ return false;
++ while (*list)
++ {
++ const char *comma = strchrnul(list, ',');
++ char *pattern = xstrndup(list, comma - list);
++ int match = !fnmatch(pattern, value, /*flags:*/ 0);
++ free(pattern);
++ if (match)
++ return true;
++ if (!*comma)
++ break;
++ list = comma + 1;
++ }
++ return false;
++}
+diff --git a/src/lib/problem_data.c b/src/lib/problem_data.c
+index 7ff1d59..33227ed 100644
+--- a/src/lib/problem_data.c
++++ b/src/lib/problem_data.c
+@@ -433,10 +433,10 @@ static char **build_exclude_vector(const char *comma_separated_list)
+
+ 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 */
++ char **exclude_items = build_exclude_vector(getenv("EXCLUDE_FROM_REPORT"));
+ problem_data_t *problem_data = new_problem_data();
+ load_problem_data_from_dump_dir(problem_data, dd, exclude_items);
+ dd_close(dd);
+--
+1.7.6.1
+
diff --git a/libreport-fallback-textedit.patch b/libreport-fallback-textedit.patch
new file mode 100644
index 0000000..310c23a
--- /dev/null
+++ b/libreport-fallback-textedit.patch
@@ -0,0 +1,51 @@
+diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
+index 4dcfd34..2199bf7 100644
+--- a/src/gui-wizard-gtk/wizard.c
++++ b/src/gui-wizard-gtk/wizard.c
+@@ -534,6 +534,7 @@ static void tv_details_row_activated(
+ if (!strchr(item->content, '\n')) /* one line? */
+ goto ret; /* yes */
+
++ gint exitcode;
+ gchar *arg[3];
+ arg[0] = (char *) "xdg-open";
+ arg[1] = concat_path_file(g_dump_dir_name, item_name);
+@@ -541,7 +542,37 @@ static void tv_details_row_activated(
+
+ g_spawn_sync(NULL, arg, NULL,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL,
+- NULL, NULL, NULL, NULL, NULL, NULL);
++ NULL, NULL, NULL, NULL, &exitcode, NULL);
++
++ if (exitcode != EXIT_SUCCESS)
++ {
++ GtkWidget *dialog = gtk_dialog_new_with_buttons(_("View/edit a text file"),
++ GTK_WINDOW(g_assistant),
++ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
++ NULL);
++ GtkWidget *vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
++ GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
++ GtkWidget *textview = gtk_text_view_new();
++
++ gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Save"), GTK_RESPONSE_OK);
++ gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Cancel"), GTK_RESPONSE_CANCEL);
++
++ gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
++ gtk_widget_set_size_request(scrolled, 640, 480);
++ gtk_widget_show(scrolled);
++
++ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), textview);
++ gtk_widget_show(textview);
++
++ load_text_to_text_view(GTK_TEXT_VIEW(textview), item_name);
++
++ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
++ save_text_from_text_view(GTK_TEXT_VIEW(textview), item_name);
++
++ gtk_widget_destroy(textview);
++ gtk_widget_destroy(scrolled);
++ gtk_widget_destroy(dialog);
++ }
+
+ free(arg[1]);
+ ret:
diff --git a/libreport.spec b/libreport.spec
index 61f2c3e..6f2c5f9 100644
--- a/libreport.spec
+++ b/libreport.spec
@@ -52,6 +52,9 @@ Patch52: 0048-fixed-reporting-from-anaconda-newtUI-rhbz-729537-rhb.patch
Patch54: 0050-report-expand-help-text-mention-.conf-files-in-it.patch
Patch55: 0051-fix-make-check.patch
Patch56: parse_release_bz.patch
+Patch57: libreport-fallback-textedit.patch
+Patch58: 0001-reporter-bugzilla-fix-file-attaching-was-using-strle.patch
+Patch59: 0002-wizard-support-shell-glob-patterns-in-.xml-item-sele.patch
BuildRequires: dbus-devel
BuildRequires: gtk2-devel
BuildRequires: curl-devel
@@ -265,6 +268,10 @@ Plugin to report bugs into anonymous FTP site associated with ticketing system.
%patch54 -p1
%patch55 -p1
%patch56 -p1
+%patch57 -p1
+%patch58 -p1
+%patch59 -p1
+
%build
mkdir -p m4
test -r m4/aclocal.m4 || touch m4/aclocal.m4
@@ -415,6 +422,12 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%config(noreplace) %{_sysconfdir}/libreport/events.d/uploader_event.conf
%changelog
+* Tue Aug 30 2011 Jiri Moskovcak <jmoskovc at redhat.com> 2.0.5-7
+- added glob support to event xml files
+- changed handling of long text files
+- added a simple editor as a fallback when no editor is installed (i.e in anaconda) rhbz#728479
+- Resolves: #733448 #728479
+
* Tue Aug 16 2011 Jiri Moskovcak <jmoskovc at redhat.com> 2.0.5-6
- improved release parsing rhbz#730887
- Resolves: #730887
More information about the scm-commits
mailing list