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

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