Blob Blame Raw
From 3c4bbdee2059525fafdd6b32a6c85cf2358febe4 Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Wed, 10 Feb 2016 14:53:44 +0100
Subject: [PATCH] ccpp: drop %e from the core_pattern

The argument is no longer need and it must be placed either at the end
of the command or enclosed with '' as it can contain white space.

Threads can have an arbitrary name:
    man 3 pthread_setname_np

Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
 src/hooks/abrt-hook-ccpp.c          | 16 ++++++++--------
 src/hooks/abrt-install-ccpp-hook.in | 12 +-----------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
index 58d9c28..ac60840 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -142,9 +142,9 @@ static struct dump_dir *dd;
  * %u - uid
  * %g - gid
  * %t - UNIX time of dump
- * %e - executable filename
- * %i - crash thread tid
  * %P - global pid
+ * %I - crash thread tid
+ * %e - executable filename (can contain white spaces)
  * %% - output one "%"
  */
 /* Hook must be installed with exactly the same sequence of %c specifiers.
@@ -559,9 +559,9 @@ int main(int argc, char** argv)
 
     if (argc < 8)
     {
-        /* percent specifier:         %s   %c              %p  %u  %g  %t   %e          %P         %i*/
-        /* argv:                  [0] [1]  [2]             [3] [4] [5] [6]  [7]         [8]        [9]*/
-        error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME GLOBAL_PID [TID]", argv[0]);
+        /* percent specifier:         %s   %c              %p  %u  %g  %t   %P         %T        */
+        /* argv:                  [0] [1]  [2]             [3] [4] [5] [6]  [7]        [8]       */
+        error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME GLOBAL_PID GLOBAL_TID", argv[0]);
     }
 
     /* Not needed on 2.6.30.
@@ -604,11 +604,11 @@ int main(int argc, char** argv)
         else
             free(s);
     }
-    const char *global_pid_str = argv[8];
-    pid_t pid = xatoi_positive(argv[8]);
+    const char *global_pid_str = argv[7];
+    pid_t pid = xatoi_positive(argv[7]);
 
     pid_t tid = -1;
-    const char *tid_str = argv[9];
+    const char *tid_str = argv[8];
     if (tid_str)
     {
         tid = xatoi_positive(tid_str);
diff --git a/src/hooks/abrt-install-ccpp-hook.in b/src/hooks/abrt-install-ccpp-hook.in
index 707c57d..660c209 100755
--- a/src/hooks/abrt-install-ccpp-hook.in
+++ b/src/hooks/abrt-install-ccpp-hook.in
@@ -11,9 +11,7 @@ SAVED_PATTERN_DIR="@VAR_RUN@/abrt"
 SAVED_PATTERN_FILE="@VAR_RUN@/abrt/saved_core_pattern"
 HOOK_BIN="@libexecdir@/abrt-hook-ccpp"
 # Must match percent_specifiers[] order in abrt-hook-ccpp.c:
-PATTERN="|$HOOK_BIN %s %c %p %u %g %t %e %P %I"
-# Same, but with bogus "executable name" parameter
-PATTERN1="|$HOOK_BIN %s %c %p %u %g %t e %P %I"
+PATTERN="|$HOOK_BIN %s %c %p %u %g %t %P %I"
 
 # core_pipe_limit specifies how many dump_helpers can run at the same time
 # 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing
@@ -39,14 +37,6 @@ start() {
 	cur=`cat "$PATTERN_FILE"`
 	cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
 
-	# Is there a %e (executable name) in old pattern anywhere?
-	if test x"${cur#*%e}" = x"${cur}"; then
-		# No. Can use PATTERN with less risk of overflow
-		# on expansion (executable names can be LONG).
-		# Overflow would cause kernel to abort coredump. BAD.
-		PATTERN="$PATTERN1"
-	fi
-
 	$verbose && printf "cur:'%s'\n" "$cur"
 	# Is it already installed?
 	if test x"$cur_first" != x"|$HOOK_BIN"; then   # no
-- 
2.5.0