doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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