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

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