|
|
a60cd7 |
From 4f1770991a3b5da7dadd4c4e9b1a48c7d96f6808 Mon Sep 17 00:00:00 2001
|
|
|
a60cd7 |
From: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
a60cd7 |
Date: Mon, 21 Mar 2016 15:25:35 +0100
|
|
|
a60cd7 |
Subject: [PATCH] ccpp: add IgnoredPath option
|
|
|
a60cd7 |
|
|
|
a60cd7 |
ABRT will ignore crashes in executables for which absolute path matches one of
|
|
|
a60cd7 |
specified patterns.
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Related to rhbz#1277848
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
a60cd7 |
---
|
|
|
a60cd7 |
doc/abrt-CCpp.conf.txt | 4 +++
|
|
|
a60cd7 |
src/hooks/CCpp.conf | 5 ++++
|
|
|
a60cd7 |
src/hooks/abrt-hook-ccpp.c | 71 +++++++++++++++++++++++++++++++++-------------
|
|
|
a60cd7 |
3 files changed, 61 insertions(+), 19 deletions(-)
|
|
|
a60cd7 |
|
|
|
a60cd7 |
diff --git a/doc/abrt-CCpp.conf.txt b/doc/abrt-CCpp.conf.txt
|
|
|
a60cd7 |
index 42981fd..4db4b54 100644
|
|
|
a60cd7 |
--- a/doc/abrt-CCpp.conf.txt
|
|
|
a60cd7 |
+++ b/doc/abrt-CCpp.conf.txt
|
|
|
a60cd7 |
@@ -39,6 +39,10 @@ SaveFullCore = 'yes' / 'no' ...::
|
|
|
a60cd7 |
directory.
|
|
|
a60cd7 |
Default is 'yes'.
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+IgnoredPaths = /path/to/ignore/*, */another/ignored/path* ...::
|
|
|
a60cd7 |
+ ABRT will ignore crashes in executables whose absolute path matches one of
|
|
|
a60cd7 |
+ specified patterns.
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
VerboseLog = NUM::
|
|
|
a60cd7 |
Used to make the hook more verbose
|
|
|
a60cd7 |
|
|
|
a60cd7 |
diff --git a/src/hooks/CCpp.conf b/src/hooks/CCpp.conf
|
|
|
a60cd7 |
index 08d1b28..be55e05 100644
|
|
|
a60cd7 |
--- a/src/hooks/CCpp.conf
|
|
|
a60cd7 |
+++ b/src/hooks/CCpp.conf
|
|
|
a60cd7 |
@@ -32,3 +32,8 @@ SaveFullCore = yes
|
|
|
a60cd7 |
# Specify where you want to store debuginfos (default: /var/cache/abrt-di)
|
|
|
a60cd7 |
#
|
|
|
a60cd7 |
#DebuginfoLocation = /var/cache/abrt-di
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+# ABRT will ignore crashes in executables whose absolute path matches one of
|
|
|
a60cd7 |
+# specified patterns.
|
|
|
a60cd7 |
+#
|
|
|
a60cd7 |
+#IgnoredPaths =
|
|
|
a60cd7 |
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
|
|
|
a60cd7 |
index 9648b16..18cd608 100644
|
|
|
a60cd7 |
--- a/src/hooks/abrt-hook-ccpp.c
|
|
|
a60cd7 |
+++ b/src/hooks/abrt-hook-ccpp.c
|
|
|
a60cd7 |
@@ -18,6 +18,7 @@
|
|
|
a60cd7 |
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
a60cd7 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
a60cd7 |
*/
|
|
|
a60cd7 |
+#include <fnmatch.h>
|
|
|
a60cd7 |
#include <sys/utsname.h>
|
|
|
a60cd7 |
#include "libabrt.h"
|
|
|
a60cd7 |
#include <selinux/selinux.h>
|
|
|
a60cd7 |
@@ -631,6 +632,19 @@ finito:
|
|
|
a60cd7 |
return err;
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+static bool is_path_ignored(const GList *list, const char *path)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ const GList *li;
|
|
|
a60cd7 |
+ for (li = list; li != NULL; li = g_list_next(li))
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ if (fnmatch((char*)li->data, path, /*flags:*/ 0) == 0)
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ return true;
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
+ return false;
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
static int test_configuration(bool setting_SaveFullCore, bool setting_CreateCoreBacktrace)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
if (!setting_SaveFullCore && !setting_CreateCoreBacktrace)
|
|
|
a60cd7 |
@@ -643,6 +657,26 @@ static int test_configuration(bool setting_SaveFullCore, bool setting_CreateCore
|
|
|
a60cd7 |
return 0;
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+static void error_msg_not_process_crash(const char *pid_str, const char *process_str,
|
|
|
a60cd7 |
+ long unsigned uid, int signal_no, const char *signame, const char *message, ...)
|
|
|
a60cd7 |
+{
|
|
|
a60cd7 |
+ va_list p;
|
|
|
a60cd7 |
+ va_start(p, message);
|
|
|
a60cd7 |
+ char *message_full = xvasprintf(message, p);
|
|
|
a60cd7 |
+ va_end(p);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ if (signame)
|
|
|
a60cd7 |
+ error_msg("Process %s (%s) of user %lu killed by SIG%s - %s", pid_str,
|
|
|
a60cd7 |
+ process_str, uid, signame, message_full);
|
|
|
a60cd7 |
+ else
|
|
|
a60cd7 |
+ error_msg("Process %s (%s) of user %lu killed by signal %d - %s", pid_str,
|
|
|
a60cd7 |
+ process_str, uid, signal_no, message_full);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ free(message_full);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ return;
|
|
|
a60cd7 |
+}
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
int main(int argc, char** argv)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
int err = 1;
|
|
|
a60cd7 |
@@ -666,6 +700,7 @@ int main(int argc, char** argv)
|
|
|
a60cd7 |
bool setting_SaveBinaryImage;
|
|
|
a60cd7 |
bool setting_SaveFullCore;
|
|
|
a60cd7 |
bool setting_CreateCoreBacktrace;
|
|
|
a60cd7 |
+ GList *setting_ignored_paths = NULL;
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
map_string_t *settings = new_map_string();
|
|
|
a60cd7 |
load_abrt_plugin_conf_file("CCpp.conf", settings);
|
|
|
a60cd7 |
@@ -677,6 +712,10 @@ int main(int argc, char** argv)
|
|
|
a60cd7 |
value = get_map_string_item_or_NULL(settings, "SaveFullCore");
|
|
|
a60cd7 |
setting_SaveFullCore = value ? string_to_bool(value) : true;
|
|
|
a60cd7 |
value = get_map_string_item_or_NULL(settings, "CreateCoreBacktrace");
|
|
|
a60cd7 |
+ value = get_map_string_item_or_NULL(settings, "IgnoredPaths");
|
|
|
a60cd7 |
+ if (value)
|
|
|
a60cd7 |
+ setting_ignored_paths = parse_list(value);
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
setting_CreateCoreBacktrace = value ? string_to_bool(value) : true;
|
|
|
a60cd7 |
value = get_map_string_item_or_NULL(settings, "VerboseLog");
|
|
|
a60cd7 |
if (value)
|
|
|
a60cd7 |
@@ -712,6 +751,8 @@ int main(int argc, char** argv)
|
|
|
a60cd7 |
errno = 0;
|
|
|
a60cd7 |
const char* signal_str = argv[1];
|
|
|
a60cd7 |
int signal_no = xatoi_positive(signal_str);
|
|
|
a60cd7 |
+ const char *signame = NULL;
|
|
|
a60cd7 |
+ bool signal_is_fatal_bool = signal_is_fatal(signal_no, &signame);
|
|
|
a60cd7 |
off_t ulimit_c = strtoull(argv[2], NULL, 10);
|
|
|
a60cd7 |
if (ulimit_c < 0) /* unlimited? */
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
@@ -753,6 +794,15 @@ int main(int argc, char** argv)
|
|
|
a60cd7 |
(long)pid, executable);
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
+ const char *last_slash = strrchr(executable, '/');
|
|
|
a60cd7 |
+ if (executable && is_path_ignored(setting_ignored_paths, executable))
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ error_msg_not_process_crash(pid_str, last_slash + 1, (long unsigned)uid, signal_no,
|
|
|
a60cd7 |
+ signame, "ignoring (listed in 'IgnoredPaths')");
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ return 0;
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
user_pwd = get_cwd(pid);
|
|
|
a60cd7 |
log_notice("user_pwd:'%s'", user_pwd);
|
|
|
a60cd7 |
|
|
|
a60cd7 |
@@ -793,24 +843,8 @@ int main(int argc, char** argv)
|
|
|
a60cd7 |
return create_user_core(user_core_fd, pid, ulimit_c);
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
- const char *signame = NULL;
|
|
|
a60cd7 |
- switch (signal_no)
|
|
|
a60cd7 |
- {
|
|
|
a60cd7 |
- case SIGILL : signame = "ILL" ; break;
|
|
|
a60cd7 |
- case SIGFPE : signame = "FPE" ; break;
|
|
|
a60cd7 |
- case SIGSEGV: signame = "SEGV"; break;
|
|
|
a60cd7 |
- case SIGBUS : signame = "BUS" ; break; //Bus error (bad memory access)
|
|
|
a60cd7 |
- case SIGABRT: signame = "ABRT"; break; //usually when abort() was called
|
|
|
a60cd7 |
- // We have real-world reports from users who see buggy programs
|
|
|
a60cd7 |
- // dying with SIGTRAP, uncommented it too:
|
|
|
a60cd7 |
- case SIGTRAP: signame = "TRAP"; break; //Trace/breakpoint trap
|
|
|
a60cd7 |
- // These usually aren't caused by bugs:
|
|
|
a60cd7 |
- //case SIGQUIT: signame = "QUIT"; break; //Quit from keyboard
|
|
|
a60cd7 |
- //case SIGSYS : signame = "SYS" ; break; //Bad argument to routine (SVr4)
|
|
|
a60cd7 |
- //case SIGXCPU: signame = "XCPU"; break; //CPU time limit exceeded (4.2BSD)
|
|
|
a60cd7 |
- //case SIGXFSZ: signame = "XFSZ"; break; //File size limit exceeded (4.2BSD)
|
|
|
a60cd7 |
- default: return create_user_core(user_core_fd, pid, ulimit_c); // not a signal we care about
|
|
|
a60cd7 |
- }
|
|
|
a60cd7 |
+ if (!signal_is_fatal_bool)
|
|
|
a60cd7 |
+ return create_user_core(user_core_fd, pid, ulimit_c); // not a signal we care about
|
|
|
a60cd7 |
|
|
|
a60cd7 |
if (!daemon_is_ok())
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
@@ -839,7 +873,6 @@ int main(int argc, char** argv)
|
|
|
a60cd7 |
return create_user_core(user_core_fd, pid, ulimit_c);
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
- const char *last_slash = strrchr(executable, '/');
|
|
|
a60cd7 |
if (last_slash && strncmp(++last_slash, "abrt", 4) == 0)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
if (g_settings_debug_level == 0)
|
|
|
a60cd7 |
--
|
|
|
a60cd7 |
1.8.3.1
|
|
|
a60cd7 |
|