Blame SOURCES/0179-conf-introduce-DebugLevel.patch

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