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