Blob Blame Raw
From 446bc2d3798d34a4b552deea2ada35589286b2da Mon Sep 17 00:00:00 2001
Message-Id: <446bc2d3798d34a4b552deea2ada35589286b2da.1317997521.git.npajkovs@redhat.com>
From: Nikola Pajkovsky <npajkovs@redhat.com>
Date: Fri, 7 Oct 2011 16:25:10 +0200
Subject: [PATCH] not send tainted kernel and broken bios

Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
---
 src/gui-gtk/main.c           |   12 +++++++-
 src/plugins/abrt-dump-oops.c |   57 ++++++++++++++++++++---------------------
 2 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c
index 2e45090..02a9cfc 100644
--- a/src/gui-gtk/main.c
+++ b/src/gui-gtk/main.c
@@ -73,13 +73,20 @@ static void add_directory_to_dirlist(const char *dirname)
     );
     const char *reported = (msg ? GTK_STOCK_YES : GTK_STOCK_NO);
     free(msg);
-    char *reason = dd_load_text(dd, FILENAME_REASON);
+
+    char *not_reportable_reason = dd_load_text_ext(dd, FILENAME_NOT_REPORTABLE, 0
+                                                   | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE
+                                                   | DD_FAIL_QUIETLY_ENOENT
+                                                   | DD_FAIL_QUIETLY_EACCES);
+    char *reason = NULL;
+    if (!not_reportable_reason)
+        reason = dd_load_text(dd, FILENAME_REASON);
 
     GtkTreeIter iter;
     gtk_list_store_append(s_dumps_list_store, &iter);
     gtk_list_store_set(s_dumps_list_store, &iter,
                           COLUMN_REPORTED, reported,
-                          COLUMN_REASON, reason,
+                          COLUMN_REASON, not_reportable_reason? :reason,
                           COLUMN_DIRNAME, dd->dd_dirname,
                           //OPTION: time format
                           COLUMN_LATEST_CRASH_STR, time_buf,
@@ -87,6 +94,7 @@ static void add_directory_to_dirlist(const char *dirname)
                           COLUMN_DUMP_DIR, dirname,
                           -1);
     free(reason);
+    free(not_reportable_reason);
 
     dd_close(dd);
     VERB1 log("added: %s", dirname);
diff --git a/src/plugins/abrt-dump-oops.c b/src/plugins/abrt-dump-oops.c
index b43d507..05c62b0 100644
--- a/src/plugins/abrt-dump-oops.c
+++ b/src/plugins/abrt-dump-oops.c
@@ -480,16 +480,6 @@ static unsigned save_oops_to_dump_dir(GList *oops_list, unsigned oops_cnt)
 
     VERB1 log("Saving %u oopses as dump dirs", idx >= countdown ? countdown-1 : idx);
 
-    char *tainted_str = NULL;
-    FILE *tainted_fp = fopen("/proc/sys/kernel/tainted", "r");
-    if (tainted_fp)
-    {
-        tainted_str = xmalloc_fgetline(tainted_fp);
-        fclose(tainted_fp);
-    }
-    else
-        perror_msg("Can't open '%s'", "/proc/sys/kernel/tainted");
-
     char *cmdline_str = NULL;
     FILE *cmdline_fp = fopen("/proc/cmdline", "r");
     if (cmdline_fp)
@@ -535,27 +525,29 @@ static unsigned save_oops_to_dump_dir(GList *oops_list, unsigned oops_cnt)
             if (cmdline_str)
                 dd_save_text(dd, FILENAME_CMDLINE, cmdline_str);
             dd_save_text(dd, FILENAME_BACKTRACE, second_line);
-// TODO: add "Kernel oops: " prefix, so that all oopses have recognizable FILENAME_REASON?
-// kernel oops 1st line may look quite puzzling otherwise...
-            strchrnul(second_line, '\n')[0] = '\0';
-            dd_save_text(dd, FILENAME_REASON, second_line);
-
-            if (tainted_str && tainted_str[0] != '0')
-            {
-                unsigned long tainted = xatoi_positive(tainted_str);
-                char *tainted_short = kernel_tainted_short(tainted);
-                GList *tainted_long = kernel_tainted_long(tainted);
 
-                struct strbuf *tnt_long = strbuf_new();
-                for (GList *li = tainted_long; li; li = li->next)
-                    strbuf_append_strf(tnt_long, "%s\n", (char*) li->data);
+           /* check if trace doesn't have line: 'Your BIOS is broken' */
+            char *broken_bios = strstr(second_line, "Your BIOS is broken");
+            if (broken_bios)
+                dd_save_text(dd, FILENAME_NOT_REPORTABLE, "Your BIOS is broken");
 
-                dd_save_text(dd, FILENAME_TAINTED, tainted_str);
+            char *tainted_short = kernel_tainted_short(second_line);
+            if (tainted_short)
+	    {
+                VERB1 log("Kernel is tainted '%s'", tainted_short);
                 dd_save_text(dd, FILENAME_TAINTED_SHORT, tainted_short);
-                dd_save_text(dd, FILENAME_TAINTED_LONG, tnt_long->buf);
-                strbuf_free(tnt_long);
-                list_free_with_free(tainted_long);
+                char *reason = xasprintf("Your kernel is tainted by flags '%s'. "
+                                         "Kernel maintainers are not interesting about "
+                                         "tainted kernel, because the trace might not be showing "
+                                         "the root problem."
+                                         , tainted_short);
+                dd_save_text(dd, FILENAME_NOT_REPORTABLE, reason);
+                free(reason);
             }
+// TODO: add "Kernel oops: " prefix, so that all oopses have recognizable FILENAME_REASON?
+// kernel oops 1st line may look quite puzzling otherwise...
+            strchrnul(second_line, '\n')[0] = '\0';
+            dd_save_text(dd, FILENAME_REASON, second_line);
 
             dd_close(dd);
         }
@@ -563,7 +555,6 @@ static unsigned save_oops_to_dump_dir(GList *oops_list, unsigned oops_cnt)
             errors++;
     }
 
-    free(tainted_str);
     free(cmdline_str);
 
     return errors;
@@ -711,7 +702,15 @@ int main(int argc, char **argv)
             {
                 int i = 0;
                 while (i < oops_cnt)
-                    printf("\nVersion: %s", (char*)g_list_nth_data(oops_list, i++));
+                {
+                    char *kernel_bt = (char*)g_list_nth_data(oops_list, i++);
+                    char *tainted_short = kernel_tainted_short(kernel_bt);
+                    if (tainted_short)
+                        log("Kernel is tainted '%s'", tainted_short);
+
+                    free(tainted_short);
+                    printf("\nVersion: %s", kernel_bt);
+                }
             }
             if (opts & OPT_d)
             {
-- 
1.7.7.rc0.70.g82660