[libreport/f15] refuse reporting when not reportable file exist
Nikola Pajkovsky
npajkovs at fedoraproject.org
Fri Oct 7 13:58:23 UTC 2011
commit 1fe8d9b33c384728ecb3b4c9dcaf2dbd00b7217a
Author: Nikola Pajkovsky <npajkovs at redhat.com>
Date: Fri Oct 7 15:58:51 2011 +0200
refuse reporting when not reportable file exist
Signed-off-by: Nikola Pajkovsky <npajkovs at redhat.com>
...-reporting-when-not-reportable-file-exist.patch | 190 ++++++++++++++++++++
libreport.spec | 7 +-
2 files changed, 196 insertions(+), 1 deletions(-)
---
diff --git a/0001-refuse-reporting-when-not-reportable-file-exist.patch b/0001-refuse-reporting-when-not-reportable-file-exist.patch
new file mode 100644
index 0000000..f7b7f92
--- /dev/null
+++ b/0001-refuse-reporting-when-not-reportable-file-exist.patch
@@ -0,0 +1,190 @@
+From 42953f66890978304f2b3645c378f5c87b8f2547 Mon Sep 17 00:00:00 2001
+Message-Id: <42953f66890978304f2b3645c378f5c87b8f2547.1317995685.git.npajkovs at redhat.com>
+From: Nikola Pajkovsky <npajkovs at redhat.com>
+Date: Fri, 7 Oct 2011 15:54:38 +0200
+Subject: [PATCH] refuse reporting when *not-reportable* file exist
+
+Signed-off-by: Nikola Pajkovsky <npajkovs at redhat.com>
+---
+ src/cli/cli-report.c | 20 ++++++++++++++++++++
+ src/gui-wizard-gtk/wizard.c | 38 +++++++++++++++++++++++++++++++-------
+ src/include/internal_libreport.h | 3 ++-
+ src/lib/kernel-tainted.c | 26 +++++++++++++-------------
+ 4 files changed, 66 insertions(+), 21 deletions(-)
+
+diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c
+index 49a0598..2aebc51 100644
+--- a/src/cli/cli-report.c
++++ b/src/cli/cli-report.c
+@@ -684,6 +684,26 @@ int report(const char *dump_dir_name, int flags)
+ if (!dd)
+ return -1;
+
++ char *not_reportable = dd_load_text_ext(dd, FILENAME_NOT_REPORTABLE, 0
++ | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE
++ | DD_FAIL_QUIETLY_ENOENT
++ | DD_FAIL_QUIETLY_EACCES);
++
++ if (not_reportable)
++ {
++ char *reason = dd_load_text_ext(dd, FILENAME_REASON, 0
++ | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
++ char *t = xasprintf("%s%s%s",
++ not_reportable ?: "",
++ not_reportable ? ": " : "",
++ reason ?: _("(no description)"));
++
++ dd_close(dd);
++ error_msg("%s", t);
++ free(t);
++ xfunc_die();
++ }
++
+ if (!(flags & CLI_REPORT_ONLY))
+ {
+ char *analyze_events_as_lines = list_possible_events(dd, NULL, "analyze");
+diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
+index 6048847..6ea0e30 100644
+--- a/src/gui-wizard-gtk/wizard.c
++++ b/src/gui-wizard-gtk/wizard.c
+@@ -719,7 +719,16 @@ 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)"));
++ const char *not_reportable = get_problem_item_content_or_NULL(g_cd,
++ FILENAME_NOT_REPORTABLE);
++
++ char *t = xasprintf("%s%s%s",
++ not_reportable ?: "",
++ not_reportable ? ": " : "",
++ reason ?: _("(no description)"));
++
++ gtk_label_set_text(g_lbl_cd_reason, t);
++ free(t);
+
+ gtk_list_store_clear(g_ls_details);
+ struct cd_stats stats = { 0 };
+@@ -1605,12 +1614,21 @@ static void add_pages()
+ error_msg_and_die("Can't load %s: %s", g_glade_file, error->message);
+ }
+
++ struct dump_dir *dd = dd_opendir(g_dump_dir_name, DD_OPEN_READONLY | DD_FAIL_QUIETLY_EACCES);
++ if (!dd)
++ return;
++ char *not_reportable = dd_load_text_ext(dd, FILENAME_NOT_REPORTABLE, 0
++ | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE
++ | DD_FAIL_QUIETLY_ENOENT
++ | DD_FAIL_QUIETLY_EACCES);
++ dd_close(dd);
++
+ int i;
+ int page_no = 0;
+ for (i = 0; page_names[i] != NULL; i++)
+ {
+ char *delim = strrchr(page_names[i], '_');
+- if (delim != NULL)
++ if (!not_reportable && delim)
+ {
+ if (g_report_only && (strncmp(delim + 1, "report", strlen("report"))) != 0)
+ {
+@@ -1632,7 +1650,10 @@ static void add_pages()
+ 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);
++ if (not_reportable && i == 0)
++ gtk_assistant_set_page_type(g_assistant, pages[i].page_widget, GTK_ASSISTANT_PAGE_SUMMARY);
++ else
++ gtk_assistant_set_page_type(g_assistant, page, pages[i].type);
+
+ VERB1 log("added page: %s", page_names[i]);
+ }
+@@ -1680,10 +1701,13 @@ static void add_pages()
+
+ /* 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);
++ if (!not_reportable)
++ {
++ 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);
+
+diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
+index c7811a5..16e50bd 100644
+--- a/src/include/internal_libreport.h
++++ b/src/include/internal_libreport.h
+@@ -575,7 +575,7 @@ int delete_dump_dir_possibly_using_abrtd(const char *dump_dir_name);
+ 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);
++char *kernel_tainted_short(const char *kernel_bt);
+ #define kernel_tainted_long libreport_kernel_tainted_long
+ GList *kernel_tainted_long(unsigned tainted);
+
+@@ -629,6 +629,7 @@ GList *kernel_tainted_long(unsigned tainted);
+ */
+ #define FILENAME_REPORTED_TO "reported_to"
+ #define FILENAME_EVENT_LOG "event_log"
++#define FILENAME_NOT_REPORTABLE "not-reportable"
+
+ // Not stored as files, added "on the fly":
+ #define CD_DUMPDIR "Directory"
+diff --git a/src/lib/kernel-tainted.c b/src/lib/kernel-tainted.c
+index 3595408..efca2c8 100644
+--- a/src/lib/kernel-tainted.c
++++ b/src/lib/kernel-tainted.c
+@@ -18,6 +18,12 @@
+ */
+ #include "internal_libreport.h"
+
++/* reading /proc/sys/kernel/tainted file after an oops is ALWAYS going
++ * to show it as tainted.
++ *
++ * https://bugzilla.redhat.com/show_bug.cgi?id=724838
++ */
++
+ /* From RHEL6 kernel/panic.c: */
+ static const int tnts_short[] = {
+ 'P' ,
+@@ -106,21 +112,15 @@ static const char *const tnts_long[] = {
+ "Tech_preview",
+ };
+
+-char *kernel_tainted_short(unsigned tainted)
++char *kernel_tainted_short(const char *kernel_bt)
+ {
+- 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;
+- }
++ /* example of flags: |G B | */
++ char *tainted = strstr(kernel_bt, "Tainted: ");
++ if (!tainted)
++ return NULL;
+
++ /* 12 == count of flags */
++ char *tnt = xstrndup(tainted + strlen("Tainted: "), 12);
+ return tnt;
+ }
+
+--
+1.7.7.rc0.70.g82660
+
diff --git a/libreport.spec b/libreport.spec
index d2d62c5..b9e93dd 100644
--- a/libreport.spec
+++ b/libreport.spec
@@ -5,12 +5,13 @@
Summary: Generic library for reporting various problems
Name: libreport
Version: 2.0.4
-Release: 3%{?dist}
+Release: 4%{?dist}
License: GPLv2+
Group: System Environment/Libraries
URL: https://fedorahosted.org/abrt/
Source: https://fedorahosted.org/released/abrt/%{name}-%{version}.tar.gz
Patch0: remove_pyreport.patch
+Patch1: 0001-refuse-reporting-when-not-reportable-file-exist.patch
BuildRequires: dbus-devel
BuildRequires: gtk2-devel
BuildRequires: curl-devel
@@ -78,6 +79,7 @@ Development libraries and headers for libreport-gtk
%prep
%setup -q
%patch0 -p1 -b remove_python
+%patch1 -p1
%build
autoconf
@@ -166,6 +168,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%{_libdir}/pkgconfig/libreport-gtk.pc
%changelog
+* Fri Oct 07 2011 Nikola Pajkovsky <npajkovs at redhat.com> 2.0.4-4
+- refuse reporting when not reportable file exist
+
* Mon Jul 11 2011 Jiri Moskovcak <jmoskovc at redhat.com> 2.0.4-3
- bump release
More information about the scm-commits
mailing list