Blob Blame History Raw
From 51531e9ea72af09571688a20f00e55cad5fe9c3a Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 9 Feb 2016 17:55:29 +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 8f1b813..dfe9526 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -143,9 +143,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.
@@ -661,9 +661,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.
@@ -704,8 +704,8 @@ int main(int argc, char** argv)
         /* set to max possible >0 value */
         ulimit_c = ~((off_t)1 << (sizeof(off_t)*8-1));
     }
-    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]);
 
     user_pwd = get_cwd(pid); /* may be NULL on error */
     log_notice("user_pwd:'%s'", user_pwd);
@@ -867,7 +867,7 @@ int main(int argc, char** argv)
                 signal_no, signame, "dumping core");
 
     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