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

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