Blame SOURCES/0264-cli-introduce-unsafe-reporting-for-not-reporable-pro.patch

06486d
From b14396f9f86b6694471a9418024ffb39cf7abd47 Mon Sep 17 00:00:00 2001
06486d
From: Matej Habrnal <mhabrnal@redhat.com>
06486d
Date: Wed, 3 Aug 2016 12:43:51 +0200
06486d
Subject: [PATCH] cli: introduce unsafe reporting for not-reporable problems
06486d
06486d
Parameter unsafe ignores security checks and allows to report
06486d
not-reportable problems.
06486d
06486d
What makes the problem not reportable:
06486d
06486d
- A kernel problem occurred, but your kernel has been tainted
06486d
(flags:%s).
06486d
06486d
- A kernel problem occurred because of broken BIOS. Unfortunately, such
06486d
  problems are not fixable by kernel maintainers."
06486d
06486d
- The problem data are incomplete.
06486d
06486d
- Crashed application has locked memory regions
06486d
06486d
We have decided to call the new command line argument "unsafe" because
06486d
- either the reporter can leak some private data
06486d
- or the reporter could be facing anger from maintainers when they get
06486d
to the report
06486d
06486d
Related to #1257159
06486d
Related to abrt/abrt#1166
06486d
06486d
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
06486d
---
06486d
 doc/abrt-cli.txt      |  7 +++++--
06486d
 src/cli/builtin-cmd.h |  8 +++++++-
06486d
 src/cli/process.c     | 34 ++++++++++++++++++++++++----------
06486d
 src/cli/report.c      | 27 ++++++++++++++++++++-------
06486d
 4 files changed, 56 insertions(+), 20 deletions(-)
06486d
06486d
diff --git a/doc/abrt-cli.txt b/doc/abrt-cli.txt
06486d
index 0f18784..87a74ad 100644
06486d
--- a/doc/abrt-cli.txt
06486d
+++ b/doc/abrt-cli.txt
06486d
@@ -13,13 +13,13 @@ SYNOPSIS
06486d
 
06486d
 'abrt-cli' remove  [-v]  DIR...
06486d
 
06486d
-'abrt-cli' report  [-v]  [--delete]  DIR...
06486d
+'abrt-cli' report  [-v]  [--delete] [--unsafe] DIR...
06486d
 
06486d
 'abrt-cli' info    [-v]  [--detailed] [-s SIZE] DIR...
06486d
 
06486d
 'abrt-cli' status  [-vb] [--since NUM]
06486d
 
06486d
-'abrt-cli' process [-v]  [--since NUM] DIR...
06486d
+'abrt-cli' process [-v]  [--since NUM] [--unsafe] DIR...
06486d
 
06486d
 GLOBAL OPTIONS
06486d
 --------------
06486d
@@ -49,6 +49,9 @@ COMMAND OPTIONS
06486d
 --since NUM::
06486d
     Selects only problems detected after timestamp
06486d
 
06486d
+-u, --unsafe::
06486d
+   Ignore security checks to be able to report all problems
06486d
+
06486d
 --until NUM::
06486d
     Selects only the problems older than specified timestamp
06486d
 
06486d
diff --git a/src/cli/builtin-cmd.h b/src/cli/builtin-cmd.h
06486d
index c6cd691..9773f13 100644
06486d
--- a/src/cli/builtin-cmd.h
06486d
+++ b/src/cli/builtin-cmd.h
06486d
@@ -24,7 +24,13 @@ extern int cmd_list(int argc, const char **argv);
06486d
 extern int cmd_remove(int argc, const char **argv);
06486d
 extern int _cmd_remove(const char **dirs_strv);
06486d
 extern int cmd_report(int argc, const char **argv);
06486d
-extern int _cmd_report(const char **dirs_strv, int remove);
06486d
+enum {
06486d
+    /* Remove successfully reported */
06486d
+    CMD_REPORT_REMOVE = 1 << 0,
06486d
+    /* Ignore security checks - i.e not-repotable */
06486d
+    CMD_REPORT_UNSAFE = 1 << 1,
06486d
+};
06486d
+extern int _cmd_report(const char **dirs_strv, int flags);
06486d
 extern int cmd_info(int argc, const char **argv);
06486d
 extern int _cmd_info(problem_data_t *problem_data, int detailed, int text_size);
06486d
 extern int cmd_status(int argc, const char **argv);
06486d
diff --git a/src/cli/process.c b/src/cli/process.c
06486d
index 401ef60..9ccc271 100644
06486d
--- a/src/cli/process.c
06486d
+++ b/src/cli/process.c
06486d
@@ -32,7 +32,7 @@ enum {
06486d
     ACT_SKIP
06486d
 };
06486d
 
06486d
-static int process_one_crash(problem_data_t *problem_data)
06486d
+static int process_one_crash(problem_data_t *problem_data, int report_flags)
06486d
 {
06486d
     if (problem_data == NULL)
06486d
         return ACT_ERR;
06486d
@@ -60,10 +60,10 @@ static int process_one_crash(problem_data_t *problem_data)
06486d
         const char *not_reportable = problem_data_get_content_or_NULL(problem_data, FILENAME_NOT_REPORTABLE);
06486d
 
06486d
         /* if the problem is not-reportable then ask does not contain option report(e) */
06486d
-        if (not_reportable != NULL)
06486d
-            action = ask(_("Actions: remove(rm), info(i), skip(s):"));
06486d
-        else
06486d
+        if ((report_flags & CMD_REPORT_UNSAFE) || not_reportable == NULL)
06486d
             action = ask(_("Actions: remove(rm), report(e), info(i), skip(s):"));
06486d
+        else
06486d
+            action = ask(_("Actions: remove(rm), info(i), skip(s):"));
06486d
 
06486d
         if(strcmp(action, "rm") == 0 || strcmp(action, "remove") == 0 )
06486d
         {
06486d
@@ -73,11 +73,12 @@ static int process_one_crash(problem_data_t *problem_data)
06486d
 
06486d
             ret_val = ACT_REMOVE;
06486d
         }
06486d
-        else if (not_reportable == NULL && (strcmp(action, "e") == 0 || strcmp(action, "report") == 0))
06486d
+        else if (((report_flags & CMD_REPORT_UNSAFE) || not_reportable == NULL)
06486d
+             && (strcmp(action, "e") == 0 || strcmp(action, "report") == 0))
06486d
         {
06486d
             log(_("Reporting '%s'"), dir_name);
06486d
             const char *dirs_strv[] = {dir_name, NULL};
06486d
-            _cmd_report(dirs_strv, /*do not delete*/0);
06486d
+            _cmd_report(dirs_strv, report_flags);
06486d
 
06486d
             ret_val = ACT_REPORT;
06486d
         }
06486d
@@ -98,7 +99,7 @@ static int process_one_crash(problem_data_t *problem_data)
06486d
     return ret_val;
06486d
 }
06486d
 
06486d
-static void process_crashes(vector_of_problem_data_t *crash_list, long since)
06486d
+static void process_crashes(vector_of_problem_data_t *crash_list, long since, int report_flags)
06486d
 {
06486d
 
06486d
     for (unsigned i = 0; i < crash_list->len; ++i)
06486d
@@ -117,7 +118,7 @@ static void process_crashes(vector_of_problem_data_t *crash_list, long since)
06486d
         if(i != 0)
06486d
             printf("\n");
06486d
 
06486d
-        int action = process_one_crash(crash);
06486d
+        int action = process_one_crash(crash, report_flags);
06486d
 
06486d
         if (i != crash_list->len - 1)
06486d
         {
06486d
@@ -135,23 +136,36 @@ static void process_crashes(vector_of_problem_data_t *crash_list, long since)
06486d
 int cmd_process(int argc, const char **argv)
06486d
 {
06486d
     const char *program_usage_string = _(
06486d
+        "& process [options]\n"
06486d
+        "\n"
06486d
         "Without --since argument, iterates over all detected problems."
06486d
     );
06486d
 
06486d
+    enum {
06486d
+        OPT_v = 1 << 0,
06486d
+        OPT_s = 1 << 1,
06486d
+        OPT_u = 1 << 2,
06486d
+    };
06486d
+
06486d
     int opt_since = 0;
06486d
     struct options program_options[] = {
06486d
         OPT__VERBOSE(&g_verbose),
06486d
         OPT_INTEGER('s', "since" , &opt_since,  _("Selects only problems detected after timestamp")),
06486d
+        OPT_BOOL(   'u', "unsafe", NULL,        _("Ignore security checks to be able to "
06486d
+                                                  "report all problems")),
06486d
         OPT_END()
06486d
     };
06486d
 
06486d
-    parse_opts(argc, (char **)argv, program_options, program_usage_string);
06486d
+    unsigned opts = parse_opts(argc, (char **)argv, program_options, program_usage_string);
06486d
 
06486d
     vector_of_problem_data_t *ci = fetch_crash_infos();
06486d
 
06486d
     g_ptr_array_sort_with_data(ci, &cmp_problem_data, (char *) FILENAME_LAST_OCCURRENCE);
06486d
 
06486d
-    process_crashes(ci, opt_since);
06486d
+    int report_flags = 0;
06486d
+    if (opts & OPT_u)
06486d
+        report_flags |= CMD_REPORT_UNSAFE;
06486d
+    process_crashes(ci, opt_since, report_flags);
06486d
 
06486d
     free_vector_of_problem_data(ci);
06486d
 
06486d
diff --git a/src/cli/report.c b/src/cli/report.c
06486d
index cc4035e..1e9067b 100644
06486d
--- a/src/cli/report.c
06486d
+++ b/src/cli/report.c
06486d
@@ -22,7 +22,7 @@
06486d
 #include "abrt-cli-core.h"
06486d
 #include "builtin-cmd.h"
06486d
 
06486d
-int _cmd_report(const char **dirs_strv, int remove)
06486d
+int _cmd_report(const char **dirs_strv, int flags)
06486d
 {
06486d
     int ret = 0;
06486d
     while (*dirs_strv)
06486d
@@ -39,10 +39,14 @@ int _cmd_report(const char **dirs_strv, int remove)
06486d
         const int not_reportable = test_exist_over_dbus(real_problem_id, FILENAME_NOT_REPORTABLE);
06486d
         if (not_reportable != 0)
06486d
         {
06486d
-            error_msg(_("Problem '%s' cannot be reported"), real_problem_id);
06486d
-            free(real_problem_id);
06486d
-            ++ret;
06486d
-            continue;
06486d
+            if (!(flags & CMD_REPORT_UNSAFE))
06486d
+            {
06486d
+                error_msg(_("Problem '%s' cannot be reported"), real_problem_id);
06486d
+                free(real_problem_id);
06486d
+                ++ret;
06486d
+                continue;
06486d
+            }
06486d
+            log_info(_("Problem '%s' is labeled as 'not-reportable'?"), real_problem_id);
06486d
         }
06486d
 
06486d
         const int res = chown_dir_over_dbus(real_problem_id);
06486d
@@ -58,7 +62,7 @@ int _cmd_report(const char **dirs_strv, int remove)
06486d
                                            | LIBREPORT_RUN_CLI);
06486d
 
06486d
         /* the problem was successfully reported and option is -d */
06486d
-        if(remove && (status == 0 || status == EXIT_STOP_EVENT_RUN))
06486d
+        if((flags & CMD_REPORT_REMOVE) && (status == 0 || status == EXIT_STOP_EVENT_RUN))
06486d
         {
06486d
             log(_("Deleting '%s'"), real_problem_id);
06486d
             delete_dump_dir_possibly_using_abrtd(real_problem_id);
06486d
@@ -82,11 +86,14 @@ int cmd_report(int argc, const char **argv)
06486d
     enum {
06486d
         OPT_v = 1 << 0,
06486d
         OPT_d = 1 << 1,
06486d
+        OPT_u = 1 << 2,
06486d
     };
06486d
 
06486d
     struct options program_options[] = {
06486d
         OPT__VERBOSE(&g_verbose),
06486d
         OPT_BOOL('d', "delete", NULL, _("Remove PROBLEM_DIR after reporting")),
06486d
+        OPT_BOOL('u', "unsafe", NULL, _("Ignore security checks to be able to "
06486d
+                                        "report all problems")),
06486d
         OPT_END()
06486d
     };
06486d
 
06486d
@@ -101,5 +108,11 @@ int cmd_report(int argc, const char **argv)
06486d
     load_abrt_conf();
06486d
     free_abrt_conf_data();
06486d
 
06486d
-    return _cmd_report(argv, opts & OPT_d);
06486d
+    int report_flags = 0;
06486d
+    if (opts & OPT_d)
06486d
+        report_flags |= CMD_REPORT_REMOVE;
06486d
+    if (opts & OPT_u)
06486d
+        report_flags |= CMD_REPORT_UNSAFE;
06486d
+
06486d
+    return _cmd_report(argv, report_flags);
06486d
 }
06486d
-- 
06486d
1.8.3.1
06486d