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

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