From 7b8e2407da1fc306d71baa4cb0089ca3b770eddd Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 6 May 2010 17:56:08 +0200 Subject: Add BlackListedPaths option to abrt.conf. Fixes #582421 Signed-off-by: Denys Vlasenko --- src/Daemon/MiddleWare.cpp | 30 +++++++++++++++++++++++++++++- src/Daemon/Settings.cpp | 6 ++++++ src/Daemon/Settings.h | 1 + src/Daemon/abrt.conf | 2 ++ src/Daemon/abrt.conf.5 | 5 +++++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index 33052de1..436078ff 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -18,6 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include +#include #include "abrtlib.h" #include "abrt_types.h" #include "Daemon.h" @@ -27,7 +29,6 @@ #include "ABRTException.h" #include "CommLayerInner.h" #include "MiddleWare.h" -#include using namespace std; @@ -633,6 +634,21 @@ static char *get_argv1_if_full_path(const char* cmdline) return NULL; } +static bool is_path_blacklisted(const char *path) +{ + set_string_t::iterator it = g_settings_setBlackListedPaths.begin(); + while (it != g_settings_setBlackListedPaths.end()) + { + if (fnmatch(it->c_str(), path, /*flags:*/ 0) == 0) + { + return true; + } + it++; + } + return false; +} + + /** * Get a package name from executable name and save * package description to particular debugdump directory of a crash. @@ -656,6 +672,12 @@ static mw_result_t SavePackageDescriptionToDebugDump( } else { + if (is_path_blacklisted(pExecutable)) + { + log("Blacklisted executable '%s'", pExecutable); + return MW_BLACKLISTED; + } + char *rpm_pkg = GetPackage(pExecutable); if (rpm_pkg == NULL) { @@ -718,6 +740,12 @@ static mw_result_t SavePackageDescriptionToDebugDump( scriptName = script_name; pExecutable = scriptName.c_str(); knownOrigin = true; + /* pExecutable has changed, check it again */ + if (is_path_blacklisted(pExecutable)) + { + log("Blacklisted executable '%s'", pExecutable); + return MW_BLACKLISTED; + } } free(script_name); } diff --git a/src/Daemon/Settings.cpp b/src/Daemon/Settings.cpp index 1df1d773..ba150142 100644 --- a/src/Daemon/Settings.cpp +++ b/src/Daemon/Settings.cpp @@ -54,6 +54,7 @@ bool g_settings_bOpenGPGCheck = false; /* one line: "OpenGPGPublicKeys = value1,value2" */ set_string_t g_settings_setOpenGPGPublicKeys; set_string_t g_settings_setBlackListedPkgs; +set_string_t g_settings_setBlackListedPaths; std::string g_settings_sDatabase; unsigned int g_settings_nMaxCrashReportsSize = 1000; bool g_settings_bProcessUnpackaged = false; @@ -175,6 +176,11 @@ static void ParseCommon() { g_settings_setBlackListedPkgs = ParseList(it->second.c_str()); } + it = s_mapSectionCommon.find("BlackListedPaths"); + if (it != end) + { + g_settings_setBlackListedPaths = ParseList(it->second.c_str()); + } it = s_mapSectionCommon.find("Database"); if (it != end) { diff --git a/src/Daemon/Settings.h b/src/Daemon/Settings.h index c85ee893..0395ed72 100644 --- a/src/Daemon/Settings.h +++ b/src/Daemon/Settings.h @@ -27,6 +27,7 @@ typedef map_map_string_t map_abrt_settings_t; extern set_string_t g_settings_setOpenGPGPublicKeys; extern set_string_t g_settings_setBlackListedPkgs; +extern set_string_t g_settings_setBlackListedPaths; extern unsigned int g_settings_nMaxCrashReportsSize; extern bool g_settings_bOpenGPGCheck; extern bool g_settings_bProcessUnpackaged; diff --git a/src/Daemon/abrt.conf b/src/Daemon/abrt.conf index 2cbbb544..137107a9 100644 --- a/src/Daemon/abrt.conf +++ b/src/Daemon/abrt.conf @@ -8,6 +8,8 @@ OpenGPGCheck = yes BlackList = nspluginwrapper, valgrind, strace, avant-window-navigator # Process crashes in executables which do not belong to any package? ProcessUnpackaged = no +# Blacklisted executable paths (shell patterns) +BlackListedPaths = /usr/share/doc/*, */example* # Which database plugin to use Database = SQLite3 # Max size for crash storage [MiB] diff --git a/src/Daemon/abrt.conf.5 b/src/Daemon/abrt.conf.5 index 5e520a3b..5046b096 100644 --- a/src/Daemon/abrt.conf.5 +++ b/src/Daemon/abrt.conf.5 @@ -30,6 +30,11 @@ to report them if "OpenGPGCheck = yes". .I abrt will ignore packages in this list and will not handle their crashes. .TP +.B BlackListedPaths = \fI/path/to/ignore/*\fP, \fI*/another/ignored/path*\fP ... +.I abrt +will ignore crashes in executables whose absolute path matches +one of specified patterns. +.TP .B Database = \fIdatabasePlugin\fP This specifies which database plugin .I abrt -- cgit