doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0222-ccpp-exit-with-error-if-cannot-get-executable.patch

b225ea
From 80d2c8604e4dae2fccad721eae0b219376a6ffce Mon Sep 17 00:00:00 2001
b225ea
From: Matej Habrnal <mhabrnal@redhat.com>
b225ea
Date: Thu, 21 Apr 2016 11:20:40 +0200
b225ea
Subject: [PATCH] ccpp: exit with error if cannot get executable
b225ea
b225ea
Related to rhbz#1277849
b225ea
b225ea
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
b225ea
---
b225ea
 src/hooks/abrt-hook-ccpp.c | 11 +++++++++--
b225ea
 1 file changed, 9 insertions(+), 2 deletions(-)
b225ea
b225ea
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
b225ea
index c9fbf68..8afd0d3 100644
b225ea
--- a/src/hooks/abrt-hook-ccpp.c
b225ea
+++ b/src/hooks/abrt-hook-ccpp.c
b225ea
@@ -703,13 +703,16 @@ static void error_msg_not_process_crash(const char *pid_str, const char *process
b225ea
     char *message_full = xvasprintf(message, p);
b225ea
     va_end(p);
b225ea
 
b225ea
+    char *process_name = (process_str) ?  xasprintf(" (%s)", process_str) : xstrdup("");
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
+                        process_name, 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
+                        process_name, uid, signal_no, message_full);
b225ea
 
b225ea
+    free(process_name);
b225ea
     free(message_full);
b225ea
 
b225ea
     return;
b225ea
@@ -835,6 +838,10 @@ int main(int argc, char** argv)
b225ea
 
b225ea
     int src_fd_binary = -1;
b225ea
     char *executable = get_executable(pid, setting_SaveBinaryImage ? &src_fd_binary : NULL);
b225ea
+    if (executable == NULL)
b225ea
+        error_msg_not_process_crash(pid_str, NULL, (long unsigned)uid, signal_no,
b225ea
+                signame, "ignoring (can't read /proc/PID/exe link)");
b225ea
+
b225ea
     if (executable && strstr(executable, "/abrt-hook-ccpp"))
b225ea
     {
b225ea
         error_msg_and_die("PID %lu is '%s', not dumping it to avoid recursion",
b225ea
-- 
b225ea
1.8.3.1
b225ea