Blame 0179-conf-introduce-DebugLevel.patch

69165ba
From 373f5d38e3c8fbc4bc466312c659974d31a68ac4 Mon Sep 17 00:00:00 2001
69165ba
From: Jakub Filak <jfilak@redhat.com>
69165ba
Date: Wed, 30 Sep 2015 12:17:47 +0200
69165ba
Subject: [PATCH] conf: introduce DebugLevel
69165ba
69165ba
ABRT should ignore problems caused by ABRT tools if DebugLevel == 0.
69165ba
DebugLevel is set to 0 by default.
69165ba
69165ba
Related to CVE-2015-5287
69165ba
Related: #1262252
69165ba
69165ba
Signed-off-by: Jakub Filak <jfilak@redhat.com>
69165ba
---
69165ba
 doc/abrt.conf.txt     |  8 ++++++++
69165ba
 src/daemon/abrt.conf  |  8 ++++++++
69165ba
 src/include/libabrt.h |  2 ++
69165ba
 src/lib/abrt_conf.c   | 14 ++++++++++++++
69165ba
 4 files changed, 32 insertions(+)
69165ba
69165ba
diff --git a/doc/abrt.conf.txt b/doc/abrt.conf.txt
69165ba
index d782e3d..7ef78f0 100644
69165ba
--- a/doc/abrt.conf.txt
69165ba
+++ b/doc/abrt.conf.txt
69165ba
@@ -36,6 +36,14 @@ DeleteUploaded = 'yes/no'::
69165ba
    or not.
69165ba
    The default value is 'no'.
69165ba
 
69165ba
+DebugLevel = '0-100':
69165ba
+   Allows ABRT tools to detect problems in ABRT itself. By increasing the value
69165ba
+   you can force ABRT to detect, process and report problems in ABRT. You have
69165ba
+   to bare in mind that ABRT might fall into an infinite loop when handling
69165ba
+   problems caused by itself.
69165ba
+   The default is 0 (non debug mode).
69165ba
+
69165ba
+
69165ba
 SEE ALSO
69165ba
 --------
69165ba
 abrtd(8)
69165ba
diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf
69165ba
index 2a83f8e..24df20b 100644
69165ba
--- a/src/daemon/abrt.conf
69165ba
+++ b/src/daemon/abrt.conf
69165ba
@@ -51,3 +51,11 @@ AutoreportingEnabled = no
69165ba
 #  THE PROBLEM DATA CONTAINS EXCERPTS OF /var/log/messages, dmesg AND sosreport
69165ba
 #  data GENERATED BY abrtd UNDER THE USER root.
69165ba
 PrivateReports = yes
69165ba
+
69165ba
+# Allows ABRT tools to detect problems in ABRT itself. By increasing the value
69165ba
+# you can force ABRT to detect, process and report problems in ABRT. You have
69165ba
+# to bare in mind that ABRT might fall into an infinite loop when handling
69165ba
+# problems caused by itself.
69165ba
+# The default is 0 (non debug mode).
69165ba
+#
69165ba
+# DebugLevel = 0
69165ba
diff --git a/src/include/libabrt.h b/src/include/libabrt.h
69165ba
index 3b17a64..21ce440 100644
69165ba
--- a/src/include/libabrt.h
69165ba
+++ b/src/include/libabrt.h
69165ba
@@ -70,6 +70,8 @@ extern char *        g_settings_autoreporting_event;
69165ba
 extern bool          g_settings_shortenedreporting;
69165ba
 #define g_settings_privatereports abrt_g_settings_privatereports
69165ba
 extern bool          g_settings_privatereports;
69165ba
+#define g_settings_debug_level abrt_g_settings_debug_level
69165ba
+extern unsigned int  g_settings_debug_level;
69165ba
 
69165ba
 
69165ba
 #define load_abrt_conf abrt_load_abrt_conf
69165ba
diff --git a/src/lib/abrt_conf.c b/src/lib/abrt_conf.c
69165ba
index c6aba58..4a49032 100644
69165ba
--- a/src/lib/abrt_conf.c
69165ba
+++ b/src/lib/abrt_conf.c
69165ba
@@ -28,6 +28,7 @@ bool          g_settings_autoreporting = 0;
69165ba
 char *        g_settings_autoreporting_event = NULL;
69165ba
 bool          g_settings_shortenedreporting = 0;
69165ba
 bool          g_settings_privatereports = true;
69165ba
+unsigned int  g_settings_debug_level = 0;
69165ba
 
69165ba
 void free_abrt_conf_data()
69165ba
 {
69165ba
@@ -110,6 +111,19 @@ static void ParseCommon(map_string_t *settings, const char *conf_filename)
69165ba
         remove_map_string_item(settings, "PrivateReports");
69165ba
     }
69165ba
 
69165ba
+    value = get_map_string_item_or_NULL(settings, "DebugLevel");
69165ba
+    if (value)
69165ba
+    {
69165ba
+        char *end;
69165ba
+        errno = 0;
69165ba
+        unsigned long ul = strtoul(value, &end, 10);
69165ba
+        if (errno || end == value || *end != '\0' || ul > INT_MAX)
69165ba
+            error_msg("Error parsing %s setting: '%s'", "DebugLevel", value);
69165ba
+        else
69165ba
+            g_settings_debug_level = ul;
69165ba
+        remove_map_string_item(settings, "DebugLevel");
69165ba
+    }
69165ba
+
69165ba
     GHashTableIter iter;
69165ba
     const char *name;
69165ba
     /*char *value; - already declared */
69165ba
-- 
69165ba
1.8.3.1
69165ba