From 38bcfdd3ccc0e27ef82ea08dd926941a81d963a4 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Wed, 15 Jun 2011 09:21:21 +0200 Subject: [abrt] rhbz671354 - [RFE] Configurable core dump location Signed-off-by: Nikola Pajkovsky --- src/daemon/abrt.conf | 2 ++ src/hooks/abrt-install-ccpp-hook | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf index cb0dbbbe..0946d7cd 100644 --- a/src/daemon/abrt.conf +++ b/src/daemon/abrt.conf @@ -27,3 +27,5 @@ BlackListedPaths = /usr/share/doc/*,*/example* # Max size for crash storage [MiB] or 0 for unlimited # MaxCrashReportsSize = 1000 + +DumpLocation = /var/spool/abrt diff --git a/src/hooks/abrt-install-ccpp-hook b/src/hooks/abrt-install-ccpp-hook index 12a443f0..a245aa28 100755 --- a/src/hooks/abrt-install-ccpp-hook +++ b/src/hooks/abrt-install-ccpp-hook @@ -6,14 +6,24 @@ dry_run=false verbose=false +DEFAULT_LOCATION=/var/spool/abrt + +DUMP_LOCATION=`cat /etc/abrt/abrt.conf | grep '^[ ]*DumpLocation'` +DUMP_LOCATION=${DUMP_LOCATION#*DumpLocation*=} +DUMP_LOCATION=${DUMP_LOCATION// /} + +if [ "$DUMP_LOCATION" = "" ]; then + DUMP_LOCATION=$DEFAULT_LOCATION +fi + PATTERN_FILE="/proc/sys/kernel/core_pattern" SAVED_PATTERN_DIR="/var/run/abrt" SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern" HOOK_BIN="/usr/libexec/abrt-hook-ccpp" # Must match percent_specifiers[] order in abrt-hook-ccpp.c: -PATTERN="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t %e" +PATTERN="|$HOOK_BIN $DUMP_LOCATION %s %c %p %u %g %t %e" # Same, but with bogus "executable name" parameter -PATTERN1="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t e" +PATTERN1="|$HOOK_BIN $DUMP_LOCATION %s %c %p %u %g %t e" # core_pipe_limit specifies how many dump_helpers can run at the same time # 0 - means unlimited, but it's not guaranteed that /proc/ of crashing -- cgit From c0e01c96366682efa94ef6154579d1b2c984bb29 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Wed, 15 Jun 2011 09:32:20 +0200 Subject: [abrt] rename abrt-install-ccpp-hook to abrt-install-ccpp-hook.in Signed-off-by: Nikola Pajkovsky --- .gitignore | 1 + configure.ac | 1 + src/hooks/Makefile.am | 2 +- src/hooks/abrt-install-ccpp-hook | 107 ------------------------------------ src/hooks/abrt-install-ccpp-hook.in | 107 ++++++++++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+), 108 deletions(-) delete mode 100755 src/hooks/abrt-install-ccpp-hook create mode 100755 src/hooks/abrt-install-ccpp-hook.in diff --git a/.gitignore b/.gitignore index a0c88d8f..dd996566 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ src/cli/abrt-cli src/hooks/abrt_exception_handler.py src/hooks/abrt-hook-ccpp +src/hooks/abrt-install-ccpp-hook src/applet/abrt-applet.desktop src/gui-gtk/abrt.desktop diff --git a/configure.ac b/configure.ac index f2cde328..7c42f474 100644 --- a/configure.ac +++ b/configure.ac @@ -140,6 +140,7 @@ AC_CONFIG_FILES([ src/Makefile src/daemon/Makefile src/hooks/Makefile + src/hooks/abrt-install-ccpp-hook src/applet/Makefile src/gui-gtk/Makefile src/cli/Makefile diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am index 95cd3634..962e3265 100644 --- a/src/hooks/Makefile.am +++ b/src/hooks/Makefile.am @@ -27,7 +27,7 @@ abrt_hook_ccpp_LDADD = \ $(LIBREPORT_LIBS) python_PYTHON = abrt.pth abrt_exception_handler.py -EXTRA_DIST = abrt_exception_handler.py.in abrt-install-ccpp-hook $(man_MANS) +EXTRA_DIST = abrt_exception_handler.py.in abrt-install-ccpp-hook.in $(man_MANS) CLEANFILES := $(notdir $(wildcard *~)) $(notdir $(wildcard *\#)) $(notdir $(wildcard \.\#*)) $(notdir $(wildcard *.pyc)) diff --git a/src/hooks/abrt-install-ccpp-hook b/src/hooks/abrt-install-ccpp-hook deleted file mode 100755 index a245aa28..00000000 --- a/src/hooks/abrt-install-ccpp-hook +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -# Install coredump handler which saves segfault data - -# For debugging - -dry_run=false -verbose=false - -DEFAULT_LOCATION=/var/spool/abrt - -DUMP_LOCATION=`cat /etc/abrt/abrt.conf | grep '^[ ]*DumpLocation'` -DUMP_LOCATION=${DUMP_LOCATION#*DumpLocation*=} -DUMP_LOCATION=${DUMP_LOCATION// /} - -if [ "$DUMP_LOCATION" = "" ]; then - DUMP_LOCATION=$DEFAULT_LOCATION -fi - -PATTERN_FILE="/proc/sys/kernel/core_pattern" -SAVED_PATTERN_DIR="/var/run/abrt" -SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern" -HOOK_BIN="/usr/libexec/abrt-hook-ccpp" -# Must match percent_specifiers[] order in abrt-hook-ccpp.c: -PATTERN="|$HOOK_BIN $DUMP_LOCATION %s %c %p %u %g %t %e" -# Same, but with bogus "executable name" parameter -PATTERN1="|$HOOK_BIN $DUMP_LOCATION %s %c %p %u %g %t e" - -# core_pipe_limit specifies how many dump_helpers can run at the same time -# 0 - means unlimited, but it's not guaranteed that /proc/ of crashing -# process will be available for dump_helper. -# 4 - means that 4 dump_helpers can run at the same time (the rest will also -# run, but they will fail to read /proc/). -# -# This should be enough for ABRT, we can miss some crashes, but what are -# the odds that more processes crash at the same time? And moreover, -# do people want to save EVERY ONE of the crashes when they have -# a crash storm? I don't think so. -# The value of 4 has been recommended by nhorman. -# -CORE_PIPE_LIMIT_FILE="/proc/sys/kernel/core_pipe_limit" -CORE_PIPE_LIMIT="4" - -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 - # It is not installed - mkdir -p -- "$SAVED_PATTERN_DIR" - printf "%s\n" "$cur" >"$SAVED_PATTERN_FILE" - # Install new handler - $verbose && printf "Installing to %s:'%s'\n" "$PATTERN_FILE" "$PATTERN" - $dry_run || echo "$PATTERN" >"$PATTERN_FILE" - - # Check core_pipe_limit and change it if it's 0, - # otherwise the abrt-hook-ccpp won't be able to read /proc/ - # of the crashing process - if test x"`cat "$CORE_PIPE_LIMIT_FILE"`" = x"0"; then - echo "$CORE_PIPE_LIMIT" >"$CORE_PIPE_LIMIT_FILE" - fi - fi -} - -stop() { - if test -f "$SAVED_PATTERN_FILE"; then - $verbose && printf "Restoring to %s:'%s'\n" "$PATTERN_FILE" "`cat "$SAVED_PATTERN_FILE"`" - $dry_run || cat "$SAVED_PATTERN_FILE" >"$PATTERN_FILE" - fi -} - -status() { - cur=`cat "$PATTERN_FILE"` - cur_first=`printf "%s" "$cur" | sed 's/ .*//'` - # Is it already installed? - if test x"$cur_first" = x"|$HOOK_BIN"; then # yes - $verbose && printf "Installed\n" - return 0 - else - $verbose && printf "Not installed\n" - return 1 - fi -} - -case "$1" in -install) - start - ;; -uninstall) - stop - ;; -is-installed) - status - ;; -*) - echo $"Usage: $0 {install|uninstall|is-installed}" - return 2 -esac diff --git a/src/hooks/abrt-install-ccpp-hook.in b/src/hooks/abrt-install-ccpp-hook.in new file mode 100755 index 00000000..a245aa28 --- /dev/null +++ b/src/hooks/abrt-install-ccpp-hook.in @@ -0,0 +1,107 @@ +#!/bin/bash +# Install coredump handler which saves segfault data + +# For debugging + +dry_run=false +verbose=false + +DEFAULT_LOCATION=/var/spool/abrt + +DUMP_LOCATION=`cat /etc/abrt/abrt.conf | grep '^[ ]*DumpLocation'` +DUMP_LOCATION=${DUMP_LOCATION#*DumpLocation*=} +DUMP_LOCATION=${DUMP_LOCATION// /} + +if [ "$DUMP_LOCATION" = "" ]; then + DUMP_LOCATION=$DEFAULT_LOCATION +fi + +PATTERN_FILE="/proc/sys/kernel/core_pattern" +SAVED_PATTERN_DIR="/var/run/abrt" +SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern" +HOOK_BIN="/usr/libexec/abrt-hook-ccpp" +# Must match percent_specifiers[] order in abrt-hook-ccpp.c: +PATTERN="|$HOOK_BIN $DUMP_LOCATION %s %c %p %u %g %t %e" +# Same, but with bogus "executable name" parameter +PATTERN1="|$HOOK_BIN $DUMP_LOCATION %s %c %p %u %g %t e" + +# core_pipe_limit specifies how many dump_helpers can run at the same time +# 0 - means unlimited, but it's not guaranteed that /proc/ of crashing +# process will be available for dump_helper. +# 4 - means that 4 dump_helpers can run at the same time (the rest will also +# run, but they will fail to read /proc/). +# +# This should be enough for ABRT, we can miss some crashes, but what are +# the odds that more processes crash at the same time? And moreover, +# do people want to save EVERY ONE of the crashes when they have +# a crash storm? I don't think so. +# The value of 4 has been recommended by nhorman. +# +CORE_PIPE_LIMIT_FILE="/proc/sys/kernel/core_pipe_limit" +CORE_PIPE_LIMIT="4" + +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 + # It is not installed + mkdir -p -- "$SAVED_PATTERN_DIR" + printf "%s\n" "$cur" >"$SAVED_PATTERN_FILE" + # Install new handler + $verbose && printf "Installing to %s:'%s'\n" "$PATTERN_FILE" "$PATTERN" + $dry_run || echo "$PATTERN" >"$PATTERN_FILE" + + # Check core_pipe_limit and change it if it's 0, + # otherwise the abrt-hook-ccpp won't be able to read /proc/ + # of the crashing process + if test x"`cat "$CORE_PIPE_LIMIT_FILE"`" = x"0"; then + echo "$CORE_PIPE_LIMIT" >"$CORE_PIPE_LIMIT_FILE" + fi + fi +} + +stop() { + if test -f "$SAVED_PATTERN_FILE"; then + $verbose && printf "Restoring to %s:'%s'\n" "$PATTERN_FILE" "`cat "$SAVED_PATTERN_FILE"`" + $dry_run || cat "$SAVED_PATTERN_FILE" >"$PATTERN_FILE" + fi +} + +status() { + cur=`cat "$PATTERN_FILE"` + cur_first=`printf "%s" "$cur" | sed 's/ .*//'` + # Is it already installed? + if test x"$cur_first" = x"|$HOOK_BIN"; then # yes + $verbose && printf "Installed\n" + return 0 + else + $verbose && printf "Not installed\n" + return 1 + fi +} + +case "$1" in +install) + start + ;; +uninstall) + stop + ;; +is-installed) + status + ;; +*) + echo $"Usage: $0 {install|uninstall|is-installed}" + return 2 +esac -- cgit From bee2deb7f01362b5a2521ba7968adff090fa3f2c Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Wed, 15 Jun 2011 09:45:41 +0200 Subject: [abrt] dump locatation needs to know where configure puts config file from abrt Signed-off-by: Nikola Pajkovsky --- src/hooks/abrt-install-ccpp-hook.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/abrt-install-ccpp-hook.in b/src/hooks/abrt-install-ccpp-hook.in index a245aa28..9c7df750 100755 --- a/src/hooks/abrt-install-ccpp-hook.in +++ b/src/hooks/abrt-install-ccpp-hook.in @@ -8,7 +8,7 @@ verbose=false DEFAULT_LOCATION=/var/spool/abrt -DUMP_LOCATION=`cat /etc/abrt/abrt.conf | grep '^[ ]*DumpLocation'` +DUMP_LOCATION=`cat @sysconfdir@/abrt/abrt.conf | grep '^[ ]*DumpLocation'` DUMP_LOCATION=${DUMP_LOCATION#*DumpLocation*=} DUMP_LOCATION=${DUMP_LOCATION// /} -- cgit